arduino-emulator
|
Provides a virtualized hardware communication service for SPI, I2C, I2S, and GPIO over a stream. More...
#include <HardwareService.h>
Public Member Functions | |
void | flush () |
operator boolean () | |
uint16_t | receive (void *data, int len) |
uint16_t | receive16 () |
uint32_t | receive32 () |
uint64_t | receive64 () |
uint8_t | receive8 () |
void | send (bool data) |
void | send (HWCalls call) |
void | send (int32_t dataIn) |
void | send (int64_t dataIn) |
void | send (uint16_t dataIn) |
void | send (uint32_t dataIn) |
void | send (uint64_t dataIn) |
void | send (uint8_t data) |
void | send (void *data, size_t len) |
void | setStream (Stream *str) |
Protected Member Functions | |
uint16_t | blockingRead (void *data, int len, int timeout=1000) |
bool | is_big_endian (void) |
int16_t | swap_int16 (int16_t val) |
Byte swap short. | |
int32_t | swap_int32 (int32_t val) |
Byte swap int. | |
int64_t | swap_int64 (int64_t val) |
uint16_t | swap_uint16 (uint16_t val) |
Byte swap unsigned short. | |
uint32_t | swap_uint32 (uint32_t val) |
Byte swap unsigned int. | |
uint64_t | swap_uint64 (uint64_t val) |
Protected Attributes | |
Stream * | io = nullptr |
bool | isLittleEndian = !is_big_endian() |
int | timeout_ms = 1000 |
Provides a virtualized hardware communication service for SPI, I2C, I2S, and GPIO over a stream.
This class encapsulates the logic to tunnel hardware protocol messages (SPI, I2C, I2S, GPIO, Serial, etc.) over a generic stream interface. It handles serialization and deserialization of protocol calls and data, ensuring correct endianness (little endian by default for embedded devices). The class provides methods to send and receive various data types, manage the underlying stream, and perform byte-swapping as needed.
Key features:
Usage: