Chapter 2. API Reference
• ESP_OK RMT Tx done successfully
• ESP_ERR_TIMEOUT Exceeded the ‘wait_time’given
• ESP_ERR_INVALID_ARG Parameter error
• ESP_FAIL Driver not installed
Parameters
• channel: RMT channel
• wait_time: Maximum time in ticks to wait for transmission to be complete. If set 0, return
immediately with ESP_ERR_TIMEOUT if TX is busy (polling).
esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t *buf_handle)
Get ringbuffer from RMT.
Users can get the RMT RX ringbuffer handle, and process the RX data.
Return
• ESP_ERR_INVALID_ARG Parameter error
• ESP_OK Success
Parameters
• channel: RMT channel
• buf_handle: Pointer to buffer handle to accept RX ringbuffer handle.
esp_err_t rmt_translator_init(rmt_channel_t channel, sample_to_rmt_t fn)
Init rmt translator and register user callback. The callback will convert the raw data that needs to be sent to
rmt format. If a channel is initialized more than once, tha user callback will be replaced by the later.
Return
• ESP_FAIL Init fail.
• ESP_OK Init success.
Parameters
• channel: RMT channel .
• fn: Point to the data conversion function.
esp_err_t rmt_translator_set_context(rmt_channel_t channel, void *context)
Set user context for the translator of specific channel.
Return
• ESP_FAIL Set context fail
• ESP_OK Set context success
Parameters
• channel: RMT channel number
• context: User context
esp_err_t rmt_translator_get_context(const size_t *item_num, void **context)
Get the user context set by ‘rmt_translator_set_context’.
Note This API must be invoked in the RMT translator callback function, and the first argument must be the
actual parameter ‘item_num’you got in that callback function.
Return
• ESP_FAIL Get context fail
• ESP_OK Get context success
Parameters
• item_num: Address of the memory which contains the number of translated items (It’s from
driver’s internal memroy)
• context: Returned User context
esp_err_t rmt_write_sample(rmt_channel_t channel, const uint8_t *src, size_t src_size, bool
wait_tx_done)
Translate uint8_t type of data into rmt format and send it out. Requires rmt_translator_init to init the translator
first.
Return
• ESP_FAIL Send fail
• ESP_OK Send success
Parameters
Espressif Systems 351
Submit Document Feedback
Release v4.4