RC5 Demo
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
BitDetector Class Reference

Class that detects bits using the manchester coding. More...

#include <bitdetector.h>

Inheritance diagram for BitDetector:

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

TimerManagerm_timerManager
 Reference to TimerManager. More...
 
InputPin * m_samplePin
 Reference to pin to sample. More...
 
ExternalInterrupt * m_extInterrupt
 Reference to interrupt control object. More...
 
BitHandlerm_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...
 

Detailed Description

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:

Member Enumeration Documentation

◆ EventIds

enum BitDetector::EventIds
private

Events used by this component.

Enumerator
SAMPLE_TIMEOUT_ELAPSED 

Event for elapsed sample timeout.

◆ State

enum BitDetector::State
private

States of internal state machine.

Enumerator
NOT_INITIALIZED 

Not initialized.

WAIT_FOR_FALLING_EDGE 

Waiting for falling edge.

WAIT_FOR_RISING_EDGE 

Waiting for rising edge.

WAIT_FOR_SAMPLE 

Waiting for timeout to sample input.

Constructor & Destructor Documentation

◆ BitDetector()

BitDetector::BitDetector ( TimerManager timerManager,
InputPin *  samplePin,
ExternalInterrupt *  extInterrupt,
BitHandler handler 
)
inline

Constructor.

Parameters
[in]timerManagerTimerManager instance to use
[in]samplePinInputPin connected to TSOP IC
[in]extInterruptExternalInterrupt instance to manage interrupts on samplePin line
[in]handlerHandler that receives the detected bits

◆ ~BitDetector()

BitDetector::~BitDetector ( void  )
inline

Destructor to make sure that interrupt handler is unregistered.

Member Function Documentation

◆ deinit()

void BitDetector::deinit ( void  )
inline

Deinitialization. Enters NOT_INITIALIZED state and disables interrupt.

◆ init()

void BitDetector::init ( void  )
inline

Initialization. Starts with waiting for a ONE start bit.

◆ onEvent()

virtual void BitDetector::onEvent ( const Event &  event)
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.

Parameters
[in]eventEvent to handle

◆ onExternalInterrupt()

virtual void BitDetector::onExternalInterrupt ( void  )
inlineoverridevirtual

Handler for external interrupts.

◆ setState()

void BitDetector::setState ( State  state)
inlineprivate

Sets internal state machine state. Implements the On Entry actions.

Parameters
[in]stateState to set

Member Data Documentation

◆ m_extInterrupt

ExternalInterrupt* BitDetector::m_extInterrupt
private

Reference to interrupt control object.

◆ m_handler

BitHandler* BitDetector::m_handler
private

Reference to handler for detected bits.

◆ m_samplePin

InputPin* BitDetector::m_samplePin
private

Reference to pin to sample.

◆ m_sampleTimeout

OneShotTimer<uint8_t> BitDetector::m_sampleTimeout
private

Timer to monitor telegram timeout.

◆ m_state

State BitDetector::m_state
private

State of internal state machine.

◆ m_timerManager

TimerManager* BitDetector::m_timerManager
private

Reference to TimerManager.


The documentation for this class was generated from the following file: