2 #include "AudioTools/CoreAudio/BaseStream.h"
3 #include "RHGenericDriver.h"
19 void setDriver(RHGenericDriver &driver) { p_driver = &driver; }
22 if (p_driver ==
nullptr)
return false;
23 p_driver->setMode(mode == RX_MODE ? RHGenericDriver::RHMode::RHModeRx
24 : RHGenericDriver::RHMode::RHModeTx);
25 return p_driver->init();
28 void end() { p_driver->setMode(RHGenericDriver::RHMode::RHModeSleep); }
30 int available()
override {
31 if (mode == TX_MODE)
return 0;
32 return p_driver->available() ? p_driver->maxMessageLength() : 0;
35 size_t readBytes(uint8_t *data,
size_t len)
override {
36 if (mode == TX_MODE)
return 0;
40 uint8_t av = available();
42 p_driver->recv(data + processed, &av);
49 int availableForWrite()
override {
50 if (mode == RX_MODE)
return 0;
51 return p_driver->maxMessageLength();
54 size_t write(
const uint8_t *data,
size_t len)
override {
55 if (mode == RX_MODE)
return 0;
61 p_driver->send(data + processed, av);
69 RHGenericDriver *p_driver =
nullptr;
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition: AudioTypes.h:28