This repository was archived by the owner on Sep 16, 2024. It is now read-only.
File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,16 @@ typedef struct {
119
119
120
120
typedef intr_handle_t rmt_isr_handle_t ;
121
121
122
+ typedef void (* rmt_tx_end_fn_t )(rmt_channel_t channel , void * arg );
123
+
124
+ /**
125
+ * @brief Structure encapsulating a RMT TX end callback
126
+ */
127
+ typedef struct {
128
+ rmt_tx_end_fn_t function ; /*!< Function which is called on RMT TX end */
129
+ void * arg ; /*!< Optional argument passed to function */
130
+ } rmt_tx_end_callback_t ;
131
+
122
132
/**
123
133
* @brief Set RMT clock divider, channel clock is divided from source clock.
124
134
*
@@ -702,6 +712,21 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
702
712
*/
703
713
esp_err_t rmt_get_ringbuf_handle (rmt_channel_t channel , RingbufHandle_t * buf_handle );
704
714
715
+ /**
716
+ * @brief Registers a callback that will be called when transmission ends.
717
+ *
718
+ * Called by rmt_driver_isr_default in interrupt context.
719
+ *
720
+ * @note Requires rmt_driver_install to install the default ISR handler.
721
+ *
722
+ * @param function Function to be called from the default interrupt handler or NULL.
723
+ * @param arg Argument which will be provided to the callback when it is called.
724
+ *
725
+ * @return the previous callback settings (members will be set to NULL if there was none)
726
+ */
727
+ rmt_tx_end_callback_t rmt_register_tx_end_callback (rmt_tx_end_fn_t function , void * arg );
728
+
729
+
705
730
/*
706
731
* ----------------EXAMPLE OF RMT INTERRUPT ------------------
707
732
* @code{c}
Original file line number Diff line number Diff line change @@ -75,6 +75,9 @@ typedef struct {
75
75
76
76
rmt_obj_t * p_rmt_obj [RMT_CHANNEL_MAX ] = {0 };
77
77
78
+ // Event called when transmission is ended
79
+ static rmt_tx_end_callback_t rmt_tx_end_callback ;
80
+
78
81
static void rmt_set_tx_wrap_en (rmt_channel_t channel , bool en )
79
82
{
80
83
portENTER_CRITICAL (& rmt_spinlock );
@@ -548,6 +551,9 @@ static void IRAM_ATTR rmt_driver_isr_default(void* arg)
548
551
p_rmt -> tx_len_rem = 0 ;
549
552
p_rmt -> tx_offset = 0 ;
550
553
p_rmt -> tx_sub_len = 0 ;
554
+ if (rmt_tx_end_callback .function != NULL ) {
555
+ rmt_tx_end_callback .function (channel , rmt_tx_end_callback .arg );
556
+ }
551
557
break ;
552
558
//RX_END
553
559
case 1 :
@@ -771,3 +777,10 @@ esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_han
771
777
return ESP_OK ;
772
778
}
773
779
780
+ rmt_tx_end_callback_t rmt_register_tx_end_callback (rmt_tx_end_fn_t function , void * arg )
781
+ {
782
+ rmt_tx_end_callback_t previous = rmt_tx_end_callback ;
783
+ rmt_tx_end_callback .function = function ;
784
+ rmt_tx_end_callback .arg = arg ;
785
+ return previous ;
786
+ }
You can’t perform that action at this time.
0 commit comments