mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
rmt: support rmt user context in translator
Merges https://github.com/espressif/esp-idf/pull/6002
This commit is contained in:
@@ -171,6 +171,22 @@ typedef struct {
|
||||
*/
|
||||
typedef void (*sample_to_rmt_t)(const void *src, rmt_item32_t *dest, size_t src_size, size_t wanted_num, size_t *translated_size, size_t *item_num);
|
||||
|
||||
/**
|
||||
* @brief IDF 4.x Workaround callback function for sample_to_rmt_t that lets user pass in context for rmt_write_sample
|
||||
*
|
||||
* @param src Pointer to the buffer storing the raw data that needs to be converted to rmt format.
|
||||
* @param[out] dest Pointer to the buffer storing the rmt format data.
|
||||
* @param src_size The raw data size.
|
||||
* @param wanted_num The number of rmt format data that wanted to get.
|
||||
* @param[out] translated_size The size of the raw data that has been converted to rmt format,
|
||||
* it should return 0 if no data is converted in user callback.
|
||||
* @param[out] item_num The number of the rmt format data that actually converted to,
|
||||
* it can be less than wanted_num if there is not enough raw data, but cannot exceed wanted_num.
|
||||
* it should return 0 if no data was converted.
|
||||
* @param context User context pointer
|
||||
*/
|
||||
typedef void (*sample_with_context_to_rmt_t)(const void *src, rmt_item32_t *dest, size_t src_size, size_t wanted_num, size_t *translated_size, size_t *item_num, void *context);
|
||||
|
||||
/**
|
||||
* @brief Set RMT clock divider, channel clock is divided from source clock.
|
||||
*
|
||||
@@ -762,6 +778,29 @@ esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t *buf_han
|
||||
*/
|
||||
esp_err_t rmt_translator_init(rmt_channel_t channel, sample_to_rmt_t fn);
|
||||
|
||||
/**
|
||||
* @brief Workaround for IDF 4.x
|
||||
* TODO: Add context to sample_to_rmt_t callback signature and allow user to pass in context
|
||||
* on rmt_translator_init
|
||||
*
|
||||
* @param channel RMT channel .
|
||||
* @param fn Point to the data conversion function.
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Init fail.
|
||||
* - ESP_OK Init success.
|
||||
*/
|
||||
esp_err_t rmt_translator_init_with_context(rmt_channel_t channel, sample_with_context_to_rmt_t fn, void* context);
|
||||
|
||||
/**
|
||||
* @brief Sets the user context for the translator
|
||||
* Requires rmt_translator_init_with_context to init the translator first
|
||||
* @return
|
||||
* - ESP_FAIL Set context fail
|
||||
* - ESP_OK Set context success
|
||||
*/
|
||||
esp_err_t rmt_set_translator_context(rmt_channel_t channel, void* context);
|
||||
|
||||
/**
|
||||
* @brief Translate uint8_t type of data into rmt format and send it out.
|
||||
* Requires rmt_translator_init to init the translator first.
|
||||
|
Reference in New Issue
Block a user