Arduino PulseWire Transceiver Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
pulsewire::RxDriverRP2040 Class Referenceabstract

High-performance RP2040 IR RX driver using PIO for edge capture. More...

#include <RxDriverRP2040.h>

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

Public Member Functions

 RxDriverRP2040 (Codec &codec, uint8_t pin, uint32_t freqHz=1000, bool useChecksum=false, uint32_t timeoutUs=1000000)
 
void setFrameSize (uint8_t size) override
 
bool begin (uint8_t frameSize) override
 
bool begin () override
 
void pollPIO ()
 
void checkTimeout ()
 
size_t readBytes (uint8_t *buffer, size_t length) override
 
int available () override
 Get the number of bytes available in the internal buffer.
 
virtual void setFrameSize (uint16_t size)=0
 Set the expected frame size for dynamic data reception.
 
virtual bool begin (uint16_t bitFrequencyHz)=0
 Start the receiver.
 
virtual void end ()=0
 Stop the receiver.
 
virtual void setRxBufferSize (size_t size)=0
 Set the size of the internal RX buffer.
 

Protected Member Functions

bool decodeFrame (uint8_t *buffer, size_t frameSize)
 

Protected Attributes

Codec_codec
 
uint8_t _rxPin
 
uint32_t _freqHz
 
uint16_t _frameSize = 20
 
Vector< uint8_t_frameBuffer
 
Vector< uint32_t_edgeDurations
 
Vector< bool_edgeLevels
 
uint32_t dmaBuf [DMA_BUF_SIZE]
 
volatile size_t dmaBufHead = 0
 
int dmaChannel = -1
 
bool _useChecksum = false
 
uint32_t _timeoutUs = 1000000
 
uint32_t _lastEdgeTime = 0
 

Static Protected Attributes

static constexpr size_t DMA_BUF_SIZE = 128
 
static const uint16_t ir_rx_program [4]
 

Detailed Description

High-performance RP2040 IR RX driver using PIO for edge capture.

Uses a PIO state machine to capture IR signal edges and their timing. Buffers edge durations and levels for protocol-agnostic decoding. Compatible with modular Codec/Preamble architecture.

Note
Supports sending and receiving on the same microcontroller without conflicts.

Definition at line 19 of file RxDriverRP2040.h.

Constructor & Destructor Documentation

◆ RxDriverRP2040()

pulsewire::RxDriverRP2040::RxDriverRP2040 ( Codec codec,
uint8_t  pin,
uint32_t  freqHz = 1000,
bool  useChecksum = false,
uint32_t  timeoutUs = 1000000 
)
inline
Parameters
codecIR codec
pinRX pin
freqHzBit frequency
useChecksumIf true, validate checksum (default: false)
timeoutUsTimeout in microseconds to flush frame if no edge received (default: 1000000)

Definition at line 29 of file RxDriverRP2040.h.

Member Function Documentation

◆ available()

int pulsewire::RxDriverRP2040::available ( )
inlineoverridevirtual

Get the number of bytes available in the internal buffer.

Implements pulsewire::RxDriver.

Definition at line 134 of file RxDriverRP2040.h.

◆ begin() [1/3]

bool pulsewire::RxDriverRP2040::begin ( )
inlineoverride

Definition at line 46 of file RxDriverRP2040.h.

◆ begin() [2/3]

virtual bool pulsewire::RxDriver::begin ( uint16_t  bitFrequencyHz)
pure virtualinherited

Start the receiver.

Implemented in pulsewire::RxDriverArduino.

◆ begin() [3/3]

bool pulsewire::RxDriverRP2040::begin ( uint8_t  frameSize)
inlineoverride

Definition at line 41 of file RxDriverRP2040.h.

◆ checkTimeout()

void pulsewire::RxDriverRP2040::checkTimeout ( )
inline

Definition at line 90 of file RxDriverRP2040.h.

◆ decodeFrame()

bool pulsewire::RxDriverRP2040::decodeFrame ( uint8_t buffer,
size_t  frameSize 
)
inlineprotected

Definition at line 165 of file RxDriverRP2040.h.

◆ end()

virtual void pulsewire::RxDriver::end ( )
pure virtualinherited

Stop the receiver.

Implemented in pulsewire::RxDriverArduino, and pulsewire::RxDriverESP32.

◆ pollPIO()

void pulsewire::RxDriverRP2040::pollPIO ( )
inline

Definition at line 76 of file RxDriverRP2040.h.

◆ readBytes()

size_t pulsewire::RxDriverRP2040::readBytes ( uint8_t data,
size_t  size 
)
inlineoverridevirtual

Read up to 'size' bytes from the internal buffer into 'data'. Returns number of bytes read.

Implements pulsewire::RxDriver.

Definition at line 118 of file RxDriverRP2040.h.

◆ setFrameSize() [1/2]

virtual void pulsewire::RxDriver::setFrameSize ( uint16_t  size)
pure virtualinherited

Set the expected frame size for dynamic data reception.

Implemented in pulsewire::RxDriverArduino.

◆ setFrameSize() [2/2]

void pulsewire::RxDriverRP2040::setFrameSize ( uint8_t  size)
inlineoverride

Definition at line 39 of file RxDriverRP2040.h.

◆ setRxBufferSize()

virtual void pulsewire::RxDriver::setRxBufferSize ( size_t  size)
pure virtualinherited

Set the size of the internal RX buffer.

Implemented in pulsewire::RxDriverArduino, and pulsewire::RxDriverESP32.

Field Documentation

◆ _codec

Codec& pulsewire::RxDriverRP2040::_codec
protected

Definition at line 141 of file RxDriverRP2040.h.

◆ _edgeDurations

Vector<uint32_t> pulsewire::RxDriverRP2040::_edgeDurations
protected

Definition at line 146 of file RxDriverRP2040.h.

◆ _edgeLevels

Vector<bool> pulsewire::RxDriverRP2040::_edgeLevels
protected

Definition at line 147 of file RxDriverRP2040.h.

◆ _frameBuffer

Vector<uint8_t> pulsewire::RxDriverRP2040::_frameBuffer
protected

Definition at line 145 of file RxDriverRP2040.h.

◆ _frameSize

uint16_t pulsewire::RxDriverRP2040::_frameSize = 20
protected

Definition at line 144 of file RxDriverRP2040.h.

◆ _freqHz

uint32_t pulsewire::RxDriverRP2040::_freqHz
protected

Definition at line 143 of file RxDriverRP2040.h.

◆ _lastEdgeTime

uint32_t pulsewire::RxDriverRP2040::_lastEdgeTime = 0
protected

Definition at line 155 of file RxDriverRP2040.h.

◆ _rxPin

uint8_t pulsewire::RxDriverRP2040::_rxPin
protected

Definition at line 142 of file RxDriverRP2040.h.

◆ _timeoutUs

uint32_t pulsewire::RxDriverRP2040::_timeoutUs = 1000000
protected

Definition at line 154 of file RxDriverRP2040.h.

◆ _useChecksum

bool pulsewire::RxDriverRP2040::_useChecksum = false
protected

Definition at line 153 of file RxDriverRP2040.h.

◆ DMA_BUF_SIZE

constexpr size_t pulsewire::RxDriverRP2040::DMA_BUF_SIZE = 128
staticconstexprprotected

Definition at line 149 of file RxDriverRP2040.h.

◆ dmaBuf

uint32_t pulsewire::RxDriverRP2040::dmaBuf[DMA_BUF_SIZE]
protected

Definition at line 150 of file RxDriverRP2040.h.

◆ dmaBufHead

volatile size_t pulsewire::RxDriverRP2040::dmaBufHead = 0
protected

Definition at line 151 of file RxDriverRP2040.h.

◆ dmaChannel

int pulsewire::RxDriverRP2040::dmaChannel = -1
protected

Definition at line 152 of file RxDriverRP2040.h.

◆ ir_rx_program

const uint16_t pulsewire::RxDriverRP2040::ir_rx_program[4]
staticprotected
Initial value:
= {
0x2020,
0xa042,
0x2021,
0xa042,
}

Definition at line 157 of file RxDriverRP2040.h.


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