esp32/esp32_rmt: Select correct last RMT channel on S2, S3, C3 variants.

For example the ESP32-C3 has 2 TX channels and 2 RX channels in total, and
in this case channel 1 must be the default for bitstream.

Signed-off-by: Damien George <damien@micropython.org>
pull/8245/head
Damien George 2022-02-01 16:58:56 +11:00
rodzic 15e65b77eb
commit 1f04a9a1fc
1 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -47,6 +47,13 @@
// This current MicroPython implementation lacks some major features, notably receive pulses
// and carrier output.
// Last available RMT channel that can transmit.
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 4, 0)
#define RMT_LAST_TX_CHANNEL (RMT_CHANNEL_MAX - 1)
#else
#define RMT_LAST_TX_CHANNEL (SOC_RMT_TX_CANDIDATES_PER_GROUP - 1)
#endif
// Forward declaration
extern const mp_obj_type_t esp32_rmt_type;
@ -62,7 +69,7 @@ typedef struct _esp32_rmt_obj_t {
// Current channel used for machine.bitstream, in the machine_bitstream_high_low_rmt
// implementation. A value of -1 means do not use RMT.
int8_t esp32_rmt_bitstream_channel_id = RMT_CHANNEL_MAX - 1;
int8_t esp32_rmt_bitstream_channel_id = RMT_LAST_TX_CHANNEL;
#if MP_TASK_COREID == 0
@ -336,7 +343,7 @@ STATIC mp_obj_t esp32_rmt_bitstream_channel(size_t n_args, const mp_obj_t *args)
esp32_rmt_bitstream_channel_id = -1;
} else {
mp_int_t channel_id = mp_obj_get_int(args[0]);
if (channel_id < 0 || channel_id >= RMT_CHANNEL_MAX) {
if (channel_id < 0 || channel_id > RMT_LAST_TX_CHANNEL) {
mp_raise_ValueError(MP_ERROR_TEXT("invalid channel"));
}
esp32_rmt_bitstream_channel_id = channel_id;