Skip to content

Commit

Permalink
static_assert: SignalA SignalB @ same GPIO port
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSaw committed Mar 21, 2021
1 parent 2e3800e commit e6ffb6a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/modm/driver/encoder/bitbang_encoder_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
namespace modm
{
/**
* @ingroup modm_driver_bitbang_encoder_input
* @author Thomas Sommer
* @ingroup modm_driver_bitbang_encoder_input
* @author Thomas Sommer
*
* @brief This driver decodes a AB (incremental) encoder signal
*
* @tparam SignalA First modm::platform::Gpio pin to input the encoder signal.
* @tparam SignalB Second modm::platform::Gpio pin to input the encoder signal.
* @tparam POSTSCALER n_cycles to count as one in-/decrement.
* @tparam DeltaType Must be signed integer and fit at least POSTSCALER. The Bigger
* @tparam DeltaType Must be signed integer and fit at least POSTSCALER. The Bigger
* DeltaType, the more inc-/decrements can be stored temporarily.
*/
template<typename SignalA, typename SignalB, uint8_t POSTSCALER = 4,
Expand All @@ -38,9 +38,12 @@ class BitBangEncoderInput
"POSTSCALER must be an integer to basis 2 and not 0: 1, 2, 4, 8, 16, ...");
static_assert(POSTSCALER <= std::numeric_limits<DeltaType>::max(),
"DeltaType is to small for POSTSCALER.");

using Phases = modm::platform::SoftwareGpioPort<SignalA, SignalB>;

static_assert(Phases::number_of_ports() == 1,
"Signal A/B must be on the same GPIO port to prevent signal tearing!");

uint8_t inline getRaw();

public:
Expand Down
4 changes: 2 additions & 2 deletions src/modm/driver/encoder/bitbang_encoder_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace modm
{

/**
* @ingroup modm_driver_bitbang_encoder_output
* @author Raphael Lehmann
* @ingroup modm_driver_bitbang_encoder_output
* @author Raphael Lehmann
*
* @brief This driver generates a AB (incremental) encoder signal to
* emulate a hardware encoder with a microcontroller.
Expand Down
2 changes: 1 addition & 1 deletion src/modm/driver/encoder/bitbang_encoder_output_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
// ----------------------------------------------------------------------------

#ifndef MODM_BITBANG_ENCODER_OUTPUT_IMPL_HPP
#ifndef MODM_BITBANG_ENCODER_OUTPUT_HPP
#error "Don't include this file directly, use 'bitbang_encoder_output.hpp' instead!"
#endif
#include "bitbang_encoder_output.hpp"
Expand Down

0 comments on commit e6ffb6a

Please sign in to comment.