-
Notifications
You must be signed in to change notification settings - Fork 7.6k
RMT refactoring based on IDF #6024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cores/esp32/esp32-hal-rmt.c
Outdated
|
||
// USE SOC_RMT_CHANNELS_PER_GROUP | ||
// LOOK to https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/rmt_types.h#L32 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "soc/soc_caps.h"
#define MAX_CHANNELS (SOC_RMT_GROUPS * SOC_RMT_CHANNELS_PER_GROUP)
#define MAX_DATA_PER_CHANNEL SOC_RMT_MEM_WORDS_PER_CHANNEL
#define MAX_DATA_PER_ITTERATION (MAX_DATA_PER_CHANNEL - 2)
It is then chip independent. We should try to have as few chips specific things as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Done.
cores/esp32/esp32-hal-rmt.c
Outdated
rmt_get_status(channel, &status); | ||
rmt_get_source_clk(channel, &srcClk); | ||
|
||
ESP_LOGD(tag, "Status for RMT channel %d", channel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use ESP_LOGx in Arduino. Use log_x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Done.
cores/esp32/esp32-hal-rmt.c
Outdated
RMT.apb_conf.fifo_mask = 1; | ||
rmt_config_t config = RMT_DEFAULT_ARD_CONFIG_RX(pin, channel, buffers); | ||
ESP_ERROR_CHECK(rmt_config(&config)); | ||
ESP_ERROR_CHECK(rmt_driver_install(config.channel, 1024, 0)); //, rxBufferSize, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rxBufferSize
is ignored here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved by keeping 1024 to all SoCs. Tested it with ESP32, S2 and C3.
One possible solution is to use default values in the function signature, but that would require changing to change esp32-hal-rmt.c to cpp instead.
Overall very good, but here are a few things:
|
OK. All done. |
cores/esp32/esp32-hal-rmt.c
Outdated
return _rmtSendOnce(rmt, data, size, false); | ||
} | ||
RMT_MUTEX_LOCK(channel); | ||
ESP_ERROR_CHECK(rmt_tx_stop(channel)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESP_ERROR_CHECK
is also an IDF API that boils down to ESP_LOGx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually ESP_ERROR_CHECK
boils down directly to esp_rom_printf()
, which seems to be a ROM function, thus, it should be fine for Arduino.
What do you say? Let's keep it?
I like the error message with all necessary details about code line, function name and so on.
https://github.com/espressif/esp-idf/blob/master/components/esp_common/include/esp_err.h#L121-L127
https://github.com/espressif/esp-idf/blob/master/components/esp_system/esp_err.c#L23-L33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what it looks like is that it will abort and produce some IDF formatted message. Let's stick to Arduino constructs and log_e if not ESP_OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Done.
I removed ESP_ERROR_CHECK()
from IDF function calls that only checked IDF parameters and left it on the function call that really could return error on IDF operations.
Compile with Arduino Lib Builder does fail with this PR |
With IDF 4.4? Could you please share the log? |
@SuGlider Here is the log. Yes with IDF4.4. Lib Builder https://github.com/Jason2866/esp32-arduino-lib-builder |
Thanks @Jason2866! @me-no-dev @VojtechBartoska - |
Summary
RMT HAL refactoring based on IDF.
Impact
Improves RMT by adding IDF v4.4 support.
Receiving RMT can handle any size of data.
rmtInit() has a new parameter - RxBufferSize - to hold any number of data when receiving RMT.
rmtWrite() has a new parameter - wait_tx_done - to block writing until sending all data.
Related links
fix #5905