rmt: Adds a simple handler that can be called when transmission ends.

Merges https://github.com/espressif/esp-idf/pull/1174
This commit is contained in:
Krzysztof Bociurko 2017-10-27 15:23:07 +02:00 committed by Angus Gratton
parent 30aacb79d5
commit 1066c74b74
2 changed files with 28 additions and 0 deletions

View file

@ -119,6 +119,8 @@ typedef struct {
typedef intr_handle_t rmt_isr_handle_t;
typedef void (*rmt_tx_end_t)(rmt_channel_t channel);
/**
* @brief Set RMT clock divider, channel clock is divided from source clock.
*
@ -702,6 +704,20 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
*/
esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_handle);
/**
* @brief Registers a callback that will be called when transmission ends.
*
* Called by rmt_driver_isr_default in interrupt context.
*
* @note Requires rmt_driver_install to install the default ISR handler.
*
* @param fn Function to be called from the default interrupt handler or NULL.
*
* @return the previous handler (or NULL if there was none)
*/
rmt_tx_end_t rmt_register_tx_end_callback(rmt_tx_end_t fn);
/*
* ----------------EXAMPLE OF RMT INTERRUPT ------------------
* @code{c}

View file

@ -75,6 +75,9 @@ typedef struct {
rmt_obj_t* p_rmt_obj[RMT_CHANNEL_MAX] = {0};
// Event called when transmission is ended
static rmt_tx_end_t rmt_tx_end_callback = NULL;
static void rmt_set_tx_wrap_en(rmt_channel_t channel, bool en)
{
portENTER_CRITICAL(&rmt_spinlock);
@ -548,6 +551,9 @@ static void IRAM_ATTR rmt_driver_isr_default(void* arg)
p_rmt->tx_len_rem = 0;
p_rmt->tx_offset = 0;
p_rmt->tx_sub_len = 0;
if(rmt_tx_end_callback != NULL) {
rmt_tx_end_callback(channel);
}
break;
//RX_END
case 1:
@ -771,3 +777,9 @@ esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_han
return ESP_OK;
}
rmt_tx_end_t rmt_register_tx_end_callback(rmt_tx_end_t handler)
{
rmt_tx_end_t previous = rmt_tx_end_callback;
rmt_tx_end_callback = handler;
return previous;
}