Skip to content

Commit b641b9b

Browse files
committed
Add RMT channel and handle getters to GPIO adapter
1 parent 435f10d commit b641b9b

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/m5_unit_component/adapter_gpio.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,27 @@ class AdapterGPIOBase : public Adapter {
6666
return false;
6767
}
6868

69+
//! @brief Get the RMT TX channel (V1: rmt_channel_t, V2: -1)
70+
virtual int rmtTxChannel() const
71+
{
72+
return -1;
73+
}
74+
//! @brief Get the RMT RX channel (V1: rmt_channel_t, V2: -1)
75+
virtual int rmtRxChannel() const
76+
{
77+
return -1;
78+
}
79+
//! @brief Get the RMT TX handle (V2: rmt_channel_handle_t, V1: nullptr)
80+
virtual void* rmtTxHandle() const
81+
{
82+
return nullptr;
83+
}
84+
//! @brief Get the RMT RX handle (V2: rmt_channel_handle_t, V1: nullptr)
85+
virtual void* rmtRxHandle() const
86+
{
87+
return nullptr;
88+
}
89+
6990
//
7091
inline virtual m5::hal::error::error_t pinModeRX(const gpio::Mode m) override
7192
{

src/m5_unit_component/adapter_gpio_v1.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ class GPIOImplV1 : public AdapterGPIOBase::GPIOImpl {
121121
_rx_config.channel = RMT_CHANNEL_MAX;
122122
_tx_config.channel = RMT_CHANNEL_MAX;
123123
}
124+
int rmtTxChannel() const override
125+
{
126+
return _tx_config.channel;
127+
}
128+
int rmtRxChannel() const override
129+
{
130+
return _rx_config.channel;
131+
}
132+
124133
virtual ~GPIOImplV1()
125134
{
126135
if (_tx_config.channel != RMT_CHANNEL_MAX) {

src/m5_unit_component/adapter_gpio_v2.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ class GPIOImplV2 : public AdapterGPIO::GPIOImpl {
143143
: AdapterGPIOBase::GPIOImpl(rx_pin, tx_pin), _sem(xSemaphoreCreateMutex())
144144
{
145145
}
146+
void *rmtTxHandle() const override
147+
{
148+
return _tx_handle;
149+
}
150+
void *rmtRxHandle() const override
151+
{
152+
return _rx_handle;
153+
}
154+
146155
virtual ~GPIOImplV2()
147156
{
148157
if (_tx_handle) {

0 commit comments

Comments
 (0)