Skip to content

Commit

Permalink
[Bouffalolab] Fix crash issue caused by button action and fix UART tx…
Browse files Browse the repository at this point in the history
…/rx for command line (#25267)

* fix crash caused by short press on button

* fix uart command line

* update pin defines for BL602 night light new hardware

* fix restyled

* remove commented code
  • Loading branch information
wy-hh authored and pull[bot] committed Dec 5, 2023
1 parent 5829e72 commit 44cba2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 2 additions & 3 deletions examples/lighting-app/bouffalolab/common/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
11 changes: 4 additions & 7 deletions examples/platform/bouffalolab/common/plat/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,30 @@ 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;
}

if (0 == chipUart_var.head)
{
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);
}
Expand Down

0 comments on commit 44cba2c

Please sign in to comment.