Skip to content

Commit

Permalink
Adding error checks to the esp32 rmt_* api invocations (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
atanisoft authored and Makuna committed Aug 30, 2019
1 parent a833fb4 commit d6f7ad3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/internal/NeoEsp32RmtMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ License along with NeoPixel. If not, see
/* General Reference documentation for the APIs used in this implementation
LOW LEVEL: (what is actually used)
DOCS: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/rmt.html
EXAMPLE: https://github.com/espressif/esp-idf/blob/826ff7186ae07dc81e960a8ea09ebfc5304bfb3b/examples/peripherals/rmt_tx/main/rmt_tx_main.c
EXAMPLE: https://github.com/espressif/esp-idf/blob/826ff7186ae07dc81e960a8ea09ebfc5304bfb3b/examples/peripherals/rmt_tx/main/rmt_tx_main.c
HIGHER LEVEL:
NO TRANSLATE SUPPORT so this was not used
NOTE: https://github.com/espressif/arduino-esp32/commit/50d142950d229b8fabca9b749dc4a5f2533bc426
Expand Down Expand Up @@ -178,9 +179,9 @@ template<typename T_SPEED, typename T_CHANNEL> class NeoEsp32RmtMethodBase
{
// wait until the last send finishes before destructing everything
// arbitrary time out of 10 seconds
rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS));

rmt_driver_uninstall(T_CHANNEL::RmtChannelNumber);
ESP_ERROR_CHECK(rmt_driver_uninstall(T_CHANNEL::RmtChannelNumber));

free(_pixelsEditing);
free(_pixelsSending);
Expand Down Expand Up @@ -210,20 +211,20 @@ template<typename T_SPEED, typename T_CHANNEL> class NeoEsp32RmtMethodBase

config.clk_div = T_SPEED::RmtClockDivider;

rmt_config(&config);
rmt_driver_install(T_CHANNEL::RmtChannelNumber, 0, 0);
rmt_translator_init(T_CHANNEL::RmtChannelNumber, _translate);
ESP_ERROR_CHECK(rmt_config(&config));
ESP_ERROR_CHECK(rmt_driver_install(T_CHANNEL::RmtChannelNumber, 0, 0));
ESP_ERROR_CHECK(rmt_translator_init(T_CHANNEL::RmtChannelNumber, _translate));
}

void Update(bool maintainBufferConsistency)
{
// wait for not actively sending data
// this will time out at 10 seconds, an arbitrarily long period of time
// and do nothing if this happens
if (ESP_OK == rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS))
if (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS)))
{
// now start the RMT transmit with the editing buffer before we swap
rmt_write_sample(T_CHANNEL::RmtChannelNumber, _pixelsEditing, _pixelsSize, false);
ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_write_sample(T_CHANNEL::RmtChannelNumber, _pixelsEditing, _pixelsSize, false));

if (maintainBufferConsistency)
{
Expand Down Expand Up @@ -366,4 +367,4 @@ typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeed400Kbps, NeoEsp32RmtChannel7> NeoE
// RMT is NOT the default method for Esp32,
// you are required to use a specific channel listed above

#endif
#endif

0 comments on commit d6f7ad3

Please sign in to comment.