|
BCNP 3.2.1
Batched Command Network Protocol
|
SPI transport adapter for legacy SPI-based communication. More...
#include <spi_adapter.h>
Public Types | |
| using | ReceiveChunkFn = std::function<std::size_t(uint8_t* dst, std::size_t maxLen)> |
| Callback type for receiving SPI data chunks. | |
| using | SendBytesFn = std::function<bool(const uint8_t* data, std::size_t length)> |
| Callback type for sending raw bytes over SPI. | |
Public Member Functions | |
| SpiStreamAdapter (ReceiveChunkFn receive, SendBytesFn send, StreamParser &parser) | |
| Construct an SPI adapter with receive/send callbacks. | |
| void | Poll () |
| Poll for incoming SPI data. | |
| void | PushChunk (const uint8_t *data, std::size_t length) |
| Push a data chunk directly to the parser. | |
| template<typename MsgType > | |
| bool | SendPacket (const TypedPacket< MsgType > &packet) |
| Send a typed packet over SPI. | |
SPI transport adapter for legacy SPI-based communication.
Provides a polling-based interface for SPI communication with the BCNP stream parser. Handles both receiving data chunks and sending typed packets over an SPI bus.
Definition at line 34 of file spi_adapter.h.
| using bcnp::SpiStreamAdapter::ReceiveChunkFn = std::function<std::size_t(uint8_t* dst, std::size_t maxLen)> |
Callback type for receiving SPI data chunks.
| dst | Destination buffer to fill |
| maxLen | Maximum bytes to read |
Definition at line 42 of file spi_adapter.h.
| using bcnp::SpiStreamAdapter::SendBytesFn = std::function<bool(const uint8_t* data, std::size_t length)> |
Callback type for sending raw bytes over SPI.
| data | Data to transmit |
| length | Number of bytes to send |
Definition at line 50 of file spi_adapter.h.
| bcnp::SpiStreamAdapter::SpiStreamAdapter | ( | ReceiveChunkFn | receive, |
| SendBytesFn | send, | ||
| StreamParser & | parser ) |
Construct an SPI adapter with receive/send callbacks.
| receive | Function to call to receive data chunks |
| send | Function to call to transmit data |
| parser | Reference to StreamParser for received data |
Definition at line 10 of file spi_adapter.cpp.
| void bcnp::SpiStreamAdapter::Poll | ( | ) |
Poll for incoming SPI data.
Calls the receive callback repeatedly until no more data is available, feeding each chunk to the parser. Call this periodically in your main loop.
Definition at line 14 of file spi_adapter.cpp.
| void bcnp::SpiStreamAdapter::PushChunk | ( | const uint8_t * | data, |
| std::size_t | length ) |
Push a data chunk directly to the parser.
Bypasses the receive callback for manual data injection.
| data | Pointer to received data |
| length | Number of bytes received |
Definition at line 28 of file spi_adapter.cpp.
|
inline |
Send a typed packet over SPI.
Encodes the packet to wire format and transmits using the send callback.
| MsgType | Message type in the packet |
| packet | The packet to send |
Definition at line 89 of file spi_adapter.h.