Skip to content

Commit 49c9a79

Browse files
committed
esp32/bitstream: Update bitsream code to leave output value
Signed-off-by: Rick Sorensen <[email protected]>
1 parent d6ad358 commit 49c9a79

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

ports/esp32/esp32_common.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ target_link_options(${MICROPY_TARGET} PUBLIC
237237
target_include_directories(${MICROPY_TARGET} PUBLIC
238238
${IDF_PATH}/components/bt/host/nimble/nimble
239239
)
240+
if (IDF_VERSION VERSION_LESS "5.3")
241+
# Additional include directories needed for private RMT header.
242+
# IDF 5.x versions before 5.3.1
243+
message(STATUS "Using private rmt headers for ${IDF_VERSION}")
244+
target_include_directories(${MICROPY_TARGET} PRIVATE
245+
${IDF_PATH}/components/driver/rmt
246+
)
247+
endif()
240248

241249
# Add additional extmod and usermod components.
242250
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)

ports/esp32/machine_bitstream.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ static void IRAM_ATTR machine_bitstream_high_low_bitbang(mp_hal_pin_obj_t pin, u
9393
/******************************************************************************/
9494
// RMT implementation
9595

96+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,3,0)
97+
#include "rmt_private.h" //RJS need to add rmt_private path in _common.cmake
98+
#endif
9699
#include "driver/rmt_tx.h"
97100
#include "driver/rmt_encoder.h"
98101

@@ -147,14 +150,16 @@ static void machine_bitstream_high_low_rmt(mp_hal_pin_obj_t pin, uint32_t *timin
147150
rmt_encoder_reset(encoder);
148151
check_esp_err(rmt_transmit(channel, encoder, buf, len, &tx_config));
149152

150-
// Wait 50% longer than we expect (if every bit takes the maximum time).
151-
uint32_t timeout_ms = (3 * len / 2) * (1 + (8 * MAX(timing_ns[0] + timing_ns[1], timing_ns[2] + timing_ns[3])) / 1000000) + 9;
152-
check_esp_err(rmt_tx_wait_all_done(channel, timeout_ms));
153+
check_esp_err(rmt_tx_wait_all_done(channel, -1));
153154

154155
// Disable and release channel.
155156
check_esp_err(rmt_del_encoder(encoder));
156157
rmt_disable(channel);
157-
rmt_del_channel(channel);
158+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,3,0)
159+
channel->del(channel);
160+
#else
161+
rmt_del_channel(channel); // RJS untested
162+
#endif
158163

159164
// Cancel RMT output to GPIO pin.
160165
esp_rom_gpio_connect_out_signal(pin, SIG_GPIO_OUT_IDX, false, false);

0 commit comments

Comments
 (0)