|
Open Model Railroad Network (OpenMRN)
|
State machine for decoding a DCC packet flow. More...
#include <Receiver.hxx>
Classes | |
| struct | Timing |
| Represents the timing of a half-wave of the digital track signal. More... | |
Public Types | |
| enum | State : uint8_t { UNKNOWN , DCC_PREAMBLE , DCC_END_OF_PREAMBLE , DCC_DATA , DCC_DATA_ONE , DCC_DATA_ZERO , DCC_MAYBE_CUTOUT , DCC_CUTOUT , DCC_PACKET_FINISHED , MM_DATA , MM_ZERO , MM_ONE , MM_PACKET_FINISHED } |
| Internal states of the decoding state machine. More... | |
Public Member Functions | |
| DccDecoder (unsigned tick_per_usec) | |
| State | state () |
| void | set_packet (DCCPacket *pkt) |
| Sets where to write the decoded DCC data to. | |
| DCCPacket * | pkt () |
| Retrieves the last applied DCC packet pointer. | |
| void | process_data (uint32_t value) |
| Call this function for each time the polarity of the signal changes. | |
| bool | before_dcc_cutout () |
| Returns true if we are close to the DCC cutout. | |
Private Types | |
| enum | TimingInfo { DCC_ONE = 0 , DCC_ZERO , MM_PREAMBLE , MM_SHORT , MM_LONG , MAX_TIMINGS } |
| Indexes the timing array. More... | |
Private Member Functions | |
| void | clear_packet () |
| Sets the input DCC packet to empty. | |
Private Attributes | |
| uint8_t | parseCount_ = 0 |
| Counter that works through bit patterns. | |
| uint8_t | havePacket_: 1 |
| True if we have storage in the right time for the current packet. | |
| uint8_t | checkCRC_: 1 |
| True if we need to check CRC. | |
| uint8_t | xorState_ |
| Checksum state for XOR checksum. | |
| Crc8DallasMaxim | crcState_ |
| Checksum state for CRC8 checksum. | |
| State | parseState_ = UNKNOWN |
| State machine for parsing. | |
| DCCPacket * | pkt_ = nullptr |
| Storage for the current packet. | |
| Timing | timings_ [MAX_TIMINGS] |
| The various timings by the standards. | |
State machine for decoding a DCC packet flow.
Supports both DCC and Marklin-Motorola packets.
Definition at line 60 of file Receiver.hxx.
| enum dcc::DccDecoder::State : uint8_t |
Internal states of the decoding state machine.
Definition at line 75 of file Receiver.hxx.
|
private |
Indexes the timing array.
Definition at line 432 of file Receiver.hxx.
|
inline |
| tick_per_usec | specifies how many timer capture ticks happen per usec. The default value assumes the timer does not have a prescaler. |
Definition at line 65 of file Receiver.hxx.
|
inline |
Returns true if we are close to the DCC cutout.
This situation is recognized by having seen the first half of the end-of-packet one bit.
Definition at line 366 of file Receiver.hxx.
|
inlineprivate |
Sets the input DCC packet to empty.
Definition at line 388 of file Receiver.hxx.
|
inline |
Retrieves the last applied DCC packet pointer.
Definition at line 114 of file Receiver.hxx.
|
inline |
Call this function for each time the polarity of the signal changes.
| value | is the number of clock cycles since the last polarity change. |
Definition at line 122 of file Receiver.hxx.
|
inline |
Sets where to write the decoded DCC data to.
If this function is not called before a packet preamble starts, the packet will be discarded.
| pkt | where to store the incoming payload bytes. This packet will be reset to an empty packet. |
Definition at line 102 of file Receiver.hxx.
|
inline |
Definition at line 93 of file Receiver.hxx.
|
private |
True if we need to check CRC.
Definition at line 377 of file Receiver.hxx.
|
private |
Checksum state for CRC8 checksum.
Definition at line 381 of file Receiver.hxx.
|
private |
True if we have storage in the right time for the current packet.
Definition at line 375 of file Receiver.hxx.
|
private |
Counter that works through bit patterns.
Definition at line 373 of file Receiver.hxx.
|
private |
State machine for parsing.
Definition at line 383 of file Receiver.hxx.
|
private |
Storage for the current packet.
Definition at line 385 of file Receiver.hxx.
|
private |
The various timings by the standards.
Definition at line 442 of file Receiver.hxx.
|
private |
Checksum state for XOR checksum.
Definition at line 379 of file Receiver.hxx.