diff --git a/examples/lighting-app/bouffalolab/common/AppTask.cpp b/examples/lighting-app/bouffalolab/common/AppTask.cpp index 16b4d732ac3c7f..9d514cb76cca39 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/common/AppTask.cpp @@ -644,18 +644,17 @@ void AppTask::ButtonEventHandler(void * arg) uint32_t presstime; if (ButtonPressed()) { - hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_NEG_LEVEL, GetAppTask().ButtonEventHandler, NULL); + bl_set_gpio_intmod(gpio_key.port, 1, HOSAL_IRQ_TRIG_NEG_LEVEL); GetAppTask().mButtonPressedTime = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); GetAppTask().PostEvent(APP_EVENT_BTN_FACTORY_RESET_PRESS); } else { - hosal_gpio_irq_set(&gpio_key, HOSAL_IRQ_TRIG_POS_PULSE, GetAppTask().ButtonEventHandler, NULL); + bl_set_gpio_intmod(gpio_key.port, 1, HOSAL_IRQ_TRIG_POS_PULSE); if (GetAppTask().mButtonPressedTime) { - presstime = chip::System::SystemClock().GetMonotonicMilliseconds64().count() - GetAppTask().mButtonPressedTime; if (presstime >= APP_BUTTON_PRESS_LONG) { diff --git a/examples/platform/bouffalolab/common/plat/uart.c b/examples/platform/bouffalolab/common/plat/uart.c index b51c39d49083f5..8f2742f0296f5b 100644 --- a/examples/platform/bouffalolab/common/plat/uart.c +++ b/examples/platform/bouffalolab/common/plat/uart.c @@ -51,15 +51,14 @@ static int uartTxCallback(void * p_arg) static int uartRxCallback(void * p_arg) { - uint32_t len = 0, readlen = 0; + uint32_t len = 0; BaseType_t xHigherPriorityTaskWoken = 1; if (chipUart_var.head >= chipUart_var.tail) { if (chipUart_var.head < MAX_BUFFER_SIZE) { - readlen = len = - hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); + len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, MAX_BUFFER_SIZE - chipUart_var.head); chipUart_var.head = (chipUart_var.head + len) % MAX_BUFFER_SIZE; } @@ -67,17 +66,15 @@ static int uartRxCallback(void * p_arg) { len = hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf, chipUart_var.tail - 1); chipUart_var.head += len; - readlen += len; } } else { - readlen = + chipUart_var.head += hosal_uart_receive(&uart_stdio, chipUart_var.rxbuf + chipUart_var.head, chipUart_var.tail - chipUart_var.head - 1); - chipUart_var.head += readlen; } - if (0 == readlen || (chipUart_var.head + 1) % MAX_BUFFER_SIZE == chipUart_var.tail) + if (chipUart_var.head != chipUart_var.tail) { xSemaphoreGiveFromISR(chipUart_var.sema, &xHigherPriorityTaskWoken); }