RC5 Demo
|
Class that detects bits using the manchester coding. More...
#include <bitdetector.h>
Classes | |
class | BitHandler |
Public Member Functions | |
BitDetector (TimerManager *timerManager, InputPin *samplePin, ExternalInterrupt *extInterrupt, BitHandler *handler) | |
~BitDetector (void) | |
void | init (void) |
void | deinit (void) |
virtual void | onExternalInterrupt (void) override |
virtual void | onEvent (const Event &event) override |
Private Types | |
enum | EventIds { SAMPLE_TIMEOUT_ELAPSED } |
Events used by this component. More... | |
enum | State { NOT_INITIALIZED, WAIT_FOR_FALLING_EDGE, WAIT_FOR_RISING_EDGE, WAIT_FOR_SAMPLE } |
States of internal state machine. More... | |
Private Member Functions | |
void | setState (State state) |
Private Attributes | |
TimerManager * | m_timerManager |
Reference to TimerManager. More... | |
InputPin * | m_samplePin |
Reference to pin to sample. More... | |
ExternalInterrupt * | m_extInterrupt |
Reference to interrupt control object. More... | |
BitHandler * | m_handler |
Reference to handler for detected bits. More... | |
OneShotTimer< uint8_t > | m_sampleTimeout |
Timer to monitor telegram timeout. More... | |
State | m_state |
State of internal state machine. More... | |
Class that detects bits using the manchester coding.
The BitDetector uses an InputPin and an ExternalInterrupt instance to detect signal edges that encode a bit using the manchester coding. The procedure is:
This also forms the internal state machine:
|
private |
|
private |
|
inline |
Constructor.
[in] | timerManager | TimerManager instance to use |
[in] | samplePin | InputPin connected to TSOP IC |
[in] | extInterrupt | ExternalInterrupt instance to manage interrupts on samplePin line |
[in] | handler | Handler that receives the detected bits |
|
inline |
Destructor to make sure that interrupt handler is unregistered.
|
inline |
Deinitialization. Enters NOT_INITIALIZED state and disables interrupt.
|
inline |
Initialization. Starts with waiting for a ONE start bit.
|
inlineoverridevirtual |
Event handler. Receives the notification event when the timeout elapsed. Implements state transition back to either WAIT_FOR_FALLING_EDGE or WAIT_FOR_RISING_EDGE depending on current input level.
[in] | event | Event to handle |
|
inlineoverridevirtual |
Handler for external interrupts.
|
inlineprivate |
Sets internal state machine state. Implements the On Entry actions.
[in] | state | State to set |
|
private |
Reference to interrupt control object.
|
private |
Reference to handler for detected bits.
|
private |
Reference to pin to sample.
|
private |
Timer to monitor telegram timeout.
|
private |
State of internal state machine.
|
private |
Reference to TimerManager.