typedef intr_handle_t rmt_isr_handle_t;
-typedef void (*rmt_tx_end_t)(rmt_channel_t channel);
+typedef void (*rmt_tx_end_fn_t)(rmt_channel_t channel, void *arg);
+
+/**
+ * @brief Structure encapsulating a RMT TX end callback
+ */
+typedef struct {
+ rmt_tx_end_fn_t function; /*!< Function which is called on RMT TX end */
+ void *arg; /*!< Optional argument passed to function */
+} rmt_tx_end_callback_t;
/**
* @brief Set RMT clock divider, channel clock is divided from source clock.
*
* @note Requires rmt_driver_install to install the default ISR handler.
*
- * @param fn Function to be called from the default interrupt handler or NULL.
+ * @param function Function to be called from the default interrupt handler or NULL.
+ * @param arg Argument which will be provided to the callback when it is called.
*
- * @return the previous handler (or NULL if there was none)
+ * @return the previous callback settings (members will be set to NULL if there was none)
*/
-rmt_tx_end_t rmt_register_tx_end_callback(rmt_tx_end_t fn);
+rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, void *arg);
/*
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 rmt_tx_end_callback_t rmt_tx_end_callback;
static void rmt_set_tx_wrap_en(rmt_channel_t channel, bool en)
{
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);
+ if(rmt_tx_end_callback.function != NULL) {
+ rmt_tx_end_callback.function(channel, rmt_tx_end_callback.arg);
}
break;
//RX_END
return ESP_OK;
}
-rmt_tx_end_t rmt_register_tx_end_callback(rmt_tx_end_t handler)
+rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, void *arg)
{
- rmt_tx_end_t previous = rmt_tx_end_callback;
- rmt_tx_end_callback = handler;
+ rmt_tx_end_callback_t previous = rmt_tx_end_callback;
+ rmt_tx_end_callback.function = function;
+ rmt_tx_end_callback.arg = arg;
return previous;
}