rmt/driver: Sped the rmt_driver_isr_default ISR
Used __builtin_ctz function to sped ISR.
@@ -555,17 +555,17 @@ static int IRAM_ATTR rmt_get_mem_len(rmt_channel_t channel)
static void IRAM_ATTR rmt_driver_isr_default(void* arg)
{
- uint32_t intr_st = RMT.int_st.val;
- uint32_t i = 0;
+ const uint32_t intr_st = RMT.int_st.val;
+ uint32_t status = intr_st;
uint8_t channel;
portBASE_TYPE HPTaskAwoken = 0;
- for(i = 0; i < 32; i++) {
+ while (status) {
+ int i = __builtin_ffs(status) - 1;
+ status &= ~(1 << i);
if(i < 24) {
- if(intr_st & BIT(i)) {
channel = i / 3;
rmt_obj_t* p_rmt = p_rmt_obj[channel];
if(NULL == p_rmt) {
- RMT.int_clr.val = BIT(i);
continue;
}
switch(i % 3) {
@@ -613,13 +613,9 @@ static void IRAM_ATTR rmt_driver_isr_default(void* arg)
default:
break;
}
- RMT.int_clr.val = BIT(i);
- }
} else {
- if(intr_st & (BIT(i))) {
channel = i - 24;
rmt_obj_t* p_rmt = p_rmt_obj[channel];
- RMT.int_clr.val = BIT(i);
if(p_rmt->tx_data == NULL) {
//skip
@@ -664,7 +660,7 @@ static void IRAM_ATTR rmt_driver_isr_default(void* arg)
}
}
}
- }
+ RMT.int_clr.val = intr_st;
if(HPTaskAwoken == pdTRUE) {
portYIELD_FROM_ISR();
}
