...rmt class objects

This commit is contained in:
Wastl Kraus 2025-06-19 00:43:59 +02:00
parent 4e8930c8fc
commit f1cce0faa7
2 changed files with 10 additions and 10 deletions

View File

@ -18,7 +18,7 @@ void DShotRMT::begin()
// RX RMT Channel Configuration (for BiDirectional DShot)
if (_isBidirectional)
{
rmt_rx_channel_config_t rmt_rx_channel_config = {
_rmt_rx_channel_config = {
.gpio_num = _gpio,
.clk_src = DSHOT_CLOCK_SRC_DEFAULT,
.resolution_hz = DSHOT_RMT_RESOLUTION,
@ -27,15 +27,15 @@ void DShotRMT::begin()
.invert_in = false,
.with_dma = false}};
rmt_new_rx_channel(&rmt_rx_channel_config, &_rmt_rx_channel);
rmt_new_rx_channel(&_rmt_rx_channel_config, &_rmt_rx_channel);
rmt_enable(_rmt_rx_channel);
_receive_config.signal_range_min_ns = 100;
_receive_config.signal_range_max_ns = 10000;
_receive_config.signal_range_min_ns = 1000;
_receive_config.signal_range_max_ns = 15000;
}
// TX RMT Channel Configuration
rmt_tx_channel_config_t rmt_tx_channel_config = {
_rmt_tx_channel_config = {
.gpio_num = _gpio,
.clk_src = DSHOT_CLOCK_SRC_DEFAULT,
.resolution_hz = DSHOT_RMT_RESOLUTION,
@ -46,7 +46,7 @@ void DShotRMT::begin()
.invert_out = _isBidirectional,
.with_dma = false}};
rmt_new_tx_channel(&rmt_tx_channel_config, &_rmt_tx_channel);
rmt_new_tx_channel(&_rmt_tx_channel_config, &_rmt_tx_channel);
rmt_enable(_rmt_tx_channel);
// Use a copy encoder to send raw symbols
@ -80,10 +80,8 @@ void DShotRMT::setThrottle(uint16_t throttle)
size_t count = 0;
encodeDShotTX(_tx_packet, _tx_symbols, count);
// Restart transmission with new data
rmt_disable(_rmt_tx_channel);
rmt_enable(_rmt_tx_channel);
rmt_transmit(_rmt_tx_channel, _dshot_encoder, _tx_symbols, count * sizeof(rmt_symbol_word_t), &_transmit_config);
}

View File

@ -29,10 +29,10 @@ static constexpr auto NO_ERPM_SIGNAL = 0;
// RMT configuration parameters
static constexpr auto DSHOT_CLOCK_SRC_DEFAULT = RMT_CLK_SRC_DEFAULT;
static constexpr auto DSHOT_RMT_RESOLUTION = 10 * 1000 * 1000; // 10 MHz
static constexpr auto DSHOT_RMT_RESOLUTION = 10 * 1000 * 1000; // 10 MHz - 0.1 µs Tick
static constexpr auto TX_BUFFER_SIZE = DSHOT_BITS_PER_FRAME;
static constexpr auto RX_BUFFER_SIZE = DSHOT_BITS_PER_FRAME + 4; // Padding for RX decoding
static constexpr auto RX_BUFFER_SIZE = 32; // Padding for RX decoding
// --- DShot Mode Selection ---
// Select the appropriate bit timing for the protocol
@ -92,6 +92,8 @@ private:
// --- RMT Channel ---
rmt_channel_handle_t _rmt_rx_channel = nullptr;
rmt_channel_handle_t _rmt_tx_channel = nullptr;
rmt_rx_channel_config_t _rmt_rx_channel_config = {};
rmt_tx_channel_config_t _rmt_tx_channel_config = {};
// --- DShot RMT Encoder ---
rmt_encoder_handle_t _dshot_encoder = nullptr;