Arduino PulseWire Transceiver Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes
pulsewire::TxProtocolGeneric Class Reference

Generic implementation that is supported by all Arduino cores. More...

#include <TxProtocol.h>

Inheritance diagram for pulsewire::TxProtocolGeneric:
Inheritance graph
[legend]
Collaboration diagram for pulsewire::TxProtocolGeneric:
Collaboration graph
[legend]

Public Member Functions

 TxProtocolGeneric (SignalBase *p_signal)
 Constructs a TxProtocolGeneric instance with the specified signal implementation.
 
bool begin (uint16_t bitFrequencyHz, Codec *p_codec, uint8_t pin)
 Initializes the protocol with the specified codec and transmission pin.
 
void setFrameSize (uint16_t size)
 Configures the size of the data to be transmitted.
 
void sendPreamble ()
 Sends the preamble for the transmission.
 
void sendData (const uint8_t *data, uint8_t len)
 Encodes and transmits the data.
 
void sendEnd (bool &_useChecksum, bool isDelayAfterFrame)
 Sends the end signal for the transmission.
 
bool isFrameClosed () const
 Checks whether the transmission frame is closed.
 

Protected Member Functions

void delayUs (uint32_t us)
 

Protected Attributes

uint8_t check_sum = 0
 Checksum for data integrity.
 
bool is_frame_closed = true
 Indicates whether the frame is closed.
 
SignalBasep_signal = nullptr
 Pointer to the signal implementation.
 
Vector< OutputEdge_output_buffer
 Buffer for storing encoded signal edges.
 
Codec_codec = nullptr
 Pointer to the codec used for encoding data.
 
uint16_t _bitFrequencyHz = 0
 
uint16_t _bitPeriod = 0
 

Detailed Description

Generic implementation that is supported by all Arduino cores.

The TxProtocolGeneric class provides a concrete implementation of the TxProtocol interface, enabling the transmission of data using a specified SignalBase implementation. It handles the encoding of data, preamble, and checksum, and manages the state of the transmission frame.

Responsibilities of the TxProtocolGeneric class include:

This class is designed to work with a SignalBase implementation for physical signal transmission and a Codec for encoding data into signal edges and timings.

Definition at line 154 of file TxProtocol.h.

Constructor & Destructor Documentation

◆ TxProtocolGeneric()

pulsewire::TxProtocolGeneric::TxProtocolGeneric ( SignalBase p_signal)
inline

Constructs a TxProtocolGeneric instance with the specified signal implementation.

Parameters
p_signalPointer to the SignalBase implementation for signal transmission.

Definition at line 162 of file TxProtocol.h.

Member Function Documentation

◆ begin()

bool pulsewire::TxProtocolGeneric::begin ( uint16_t  bitFrequencyHz,
Codec p_codec,
uint8_t  pin 
)
inlinevirtual

Initializes the protocol with the specified codec and transmission pin.

Parameters
p_codecPointer to the Codec used for encoding data.
pinTransmission pin for the signal.

Implements pulsewire::TxProtocol.

Definition at line 170 of file TxProtocol.h.

◆ delayUs()

void pulsewire::TxProtocolGeneric::delayUs ( uint32_t  us)
inlineprotected

Definition at line 304 of file TxProtocol.h.

◆ isFrameClosed()

bool pulsewire::TxProtocolGeneric::isFrameClosed ( ) const
inlinevirtual

Checks whether the transmission frame is closed.

Returns
true if the frame is closed, false otherwise.

Implements pulsewire::TxProtocol.

Definition at line 292 of file TxProtocol.h.

◆ sendData()

void pulsewire::TxProtocolGeneric::sendData ( const uint8_t data,
uint8_t  len 
)
inlinevirtual

Encodes and transmits the data.

Parameters
dataPointer to the data to be transmitted.
lenLength of the data in bytes.
bitPeriodDuration of each bit in microseconds.

Implements pulsewire::TxProtocol.

Definition at line 224 of file TxProtocol.h.

◆ sendEnd()

void pulsewire::TxProtocolGeneric::sendEnd ( bool _useChecksum,
bool  isDelayAfterFrame 
)
inlinevirtual

Sends the end signal for the transmission.

Optionally includes a checksum and adds a delay to signify the end of the frame.

Parameters
_useChecksumWhether to include the checksum in the transmission.
isDelayAfterFrameWhether to add a delay after the frame.
bitPeriodDuration of each bit in microseconds.

Implements pulsewire::TxProtocol.

Definition at line 254 of file TxProtocol.h.

◆ sendPreamble()

void pulsewire::TxProtocolGeneric::sendPreamble ( )
inlinevirtual

Sends the preamble for the transmission.

The preamble is encoded using the codec and transmitted using the signal implementation. The checksum is reset at the start of a new frame.

Implements pulsewire::TxProtocol.

Definition at line 195 of file TxProtocol.h.

◆ setFrameSize()

void pulsewire::TxProtocolGeneric::setFrameSize ( uint16_t  size)
inlinevirtual

Configures the size of the data to be transmitted.

Parameters
sizeThe size of the data in bytes.

Implements pulsewire::TxProtocol.

Definition at line 183 of file TxProtocol.h.

Field Documentation

◆ _bitFrequencyHz

uint16_t pulsewire::TxProtocolGeneric::_bitFrequencyHz = 0
protected

Definition at line 301 of file TxProtocol.h.

◆ _bitPeriod

uint16_t pulsewire::TxProtocolGeneric::_bitPeriod = 0
protected

Definition at line 302 of file TxProtocol.h.

◆ _codec

Codec* pulsewire::TxProtocolGeneric::_codec = nullptr
protected

Pointer to the codec used for encoding data.

Definition at line 300 of file TxProtocol.h.

◆ _output_buffer

Vector<OutputEdge> pulsewire::TxProtocolGeneric::_output_buffer
protected

Buffer for storing encoded signal edges.

Definition at line 299 of file TxProtocol.h.

◆ check_sum

uint8_t pulsewire::TxProtocolGeneric::check_sum = 0
protected

Checksum for data integrity.

Definition at line 295 of file TxProtocol.h.

◆ is_frame_closed

bool pulsewire::TxProtocolGeneric::is_frame_closed = true
protected

Indicates whether the frame is closed.

Definition at line 296 of file TxProtocol.h.

◆ p_signal

SignalBase* pulsewire::TxProtocolGeneric::p_signal = nullptr
protected

Pointer to the signal implementation.

Definition at line 297 of file TxProtocol.h.


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