Skip to content

Commit c31ea22

Browse files
committed
toggle UART ISR on CPU change
1 parent 7443fe2 commit c31ea22

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cores/esp32/esp32-hal-cpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ bool addApbChangeCallback(void * arg, apb_change_cb_t cb){
7878
while(r->next){
7979
r = r->next;
8080
if(r->cb == cb && r->arg == arg){
81+
free(c);
8182
goto unlock_and_exit;
8283
}
8384
}

cores/esp32/esp32-hal-uart.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,10 @@ static void uart_on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old
362362
{
363363
uart_t* uart = (uart_t*)arg;
364364
if(ev_type == APB_BEFORE_CHANGE){
365-
//todo:
366365
UART_MUTEX_LOCK();
367-
// detach RX
366+
//disabple interrupt
367+
uart->dev->int_ena.val = 0;
368+
uart->dev->int_clr.val = 0xffffffff;
368369
// read RX fifo
369370
uint8_t c;
370371
BaseType_t xHigherPriorityTaskWoken;
@@ -384,7 +385,11 @@ static void uart_on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old
384385
clk_div = ((new_apb<<4)/baud_rate);
385386
uart->dev->clk_div.div_int = clk_div>>4 ;
386387
uart->dev->clk_div.div_frag = clk_div & 0xf;
387-
// attach rx
388+
//enable interrupts
389+
uart->dev->int_ena.rxfifo_full = 1;
390+
uart->dev->int_ena.frm_err = 1;
391+
uart->dev->int_ena.rxfifo_tout = 1;
392+
uart->dev->int_clr.val = 0xffffffff;
388393
UART_MUTEX_UNLOCK();
389394
}
390395
}

0 commit comments

Comments
 (0)