RC5 Demo
|
Class that accumulates individual bits into RC5 telegrams. More...
#include <rc5receiver.h>
Classes | |
class | TelegramHandler |
Public Member Functions | |
RC5Receiver (TimerManager *timerManager, InputPin *samplePin, ExternalInterrupt *extInterrupt, TelegramHandler *handler) | |
void | init (void) |
void | deinit (void) |
virtual void | onBitDetected (Bit bit) override |
virtual void | onEvent (const Event &event) override |
Private Types | |
enum | EventIds { TELEGRAM_TIMEOUT_ELAPSED } |
Events used by this component. More... | |
enum | State { NOT_INITIALIZED, WAIT_FOR_START_BIT, RECEIVE_BIT_STREAM } |
States of internal state machine. More... | |
Private Member Functions | |
void | setState (State state) |
Private Attributes | |
TimerManager * | m_timerManager |
Reference to TimerManager. More... | |
TelegramHandler * | m_handler |
Reference to TelegramHandler. More... | |
BitDetector | m_detector |
BitDetector instance. More... | |
BitBuffer< uint16_t, 14 > | m_buffer |
Internal buffer to accumulate bits in telegram. More... | |
OneShotTimer< uint8_t > | m_telegramTimeout |
Timer to monitor telegram timeout. More... | |
State | m_state |
State of internal state machine. More... | |
Class that accumulates individual bits into RC5 telegrams.
The RC5Receiver implements the BitHandler interface provided by the BitDetector. It takes the bits and stores them inside a BitBuffer until a set of 14 bits forming a RC5 telegram is complete. Then it is wrapped inside a RC5Telegram instance and passed via the TelegramHandler interface.
When the first bit of a telegram is detected, a 30ms timer is started. In case this timer elapses, reception of the current RC5 telegram is discarded and the BitBuffer is cleared (a regular telegram should not exceed 24,889 ms in length). This makes the application more robust against faulty transmissions and noise on the signal line.
The RC5Receiver implements this state machine:
|
private |
|
private |
|
inline |
Constructor. Most of the parameters are passed to the BitDetector member.
[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 accumulated RC5 telegrams |
|
inline |
Deinitialization. Enters NOT_INITIALIZED state and deinitializes BitDetector.
|
inline |
Initialization. Enters WAIT_FOR_START_BIT state and initializes BitDetector.
|
inlineoverridevirtual |
Handler for detected bits. Implements the state transitions triggered by detected bits.
[in] | bit | Detected bit |
Implements BitDetector::BitHandler.
|
inlineoverridevirtual |
Event handler. Receives the notification event when the timeout elapsed. Implements state transition back to WAIT_FOR_START_BIT.
[in] | event | Event to handle |
|
inlineprivate |
Sets internal state machine state. Implements the On Entry actions.
[in] | state | State to set |
|
private |
Internal buffer to accumulate bits in telegram.
|
private |
BitDetector instance.
|
private |
Reference to TelegramHandler.
|
private |
State of internal state machine.
|
private |
Timer to monitor telegram timeout.
|
private |
Reference to TimerManager.