Skip to content

Commit

Permalink
fix(BLE): Update PAL_UART to recover from error (#999)
Browse files Browse the repository at this point in the history
Co-authored-by: EricB-ADI <EricB-ADI@users.noreply.github.com>
  • Loading branch information
EricB-ADI and EricB-ADI authored May 10, 2024
1 parent 323668c commit 62377a9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 33 deletions.
50 changes: 33 additions & 17 deletions Libraries/Cordio/platform/targets/maxim/max32655/sources/pal_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,51 @@ static struct {
* \return None.
*/
/*************************************************************************************************/
void UART_CommonHandler(mxc_uart_regs_t *uart)
{
const int32_t err = MXC_UART_AsyncHandler(uart);

if(err == E_INVALID)
{
// If the uart is the console, we can try to recover since it is not critical
if(MXC_UART_GET_IDX(uart) == CONSOLE_UART)
{
MXC_UART_ClearRXFIFO(uart);
}
else
{
PAL_SYS_ASSERT(err == E_NO_ERROR);
}
}

}
void UART0_IRQHandler(void)
{
int result0;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result0 = MXC_UART_AsyncHandler(MXC_UART0);
(void)result0;
PAL_SYS_ASSERT(result0 == 0);
UART_CommonHandler(MXC_UART0);

}
void UART1_IRQHandler(void)
{
int result1;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result1 = MXC_UART_AsyncHandler(MXC_UART1);
(void)result1;
PAL_SYS_ASSERT(result1 == 0);
UART_CommonHandler(MXC_UART1);

}
void UART2_IRQHandler(void)
{
int result2;
{

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result2 = MXC_UART_AsyncHandler(MXC_UART2);
(void)result2;
PAL_SYS_ASSERT(result2 == 0);
UART_CommonHandler(MXC_UART2);

}
void UART3_IRQHandler(void)
{
int result3;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result3 = MXC_UART_AsyncHandler(MXC_UART3);
(void)result3;
PAL_SYS_ASSERT(result3 == 0);
UART_CommonHandler(MXC_UART3);

}

/*************************************************************************************************/
Expand Down Expand Up @@ -159,6 +173,8 @@ void RISCV_IRQHandler(void)
/*************************************************************************************************/
void palUartCallback(mxc_uart_req_t* req, int error)
{


int i;
for(i = 0; i < PAL_UARTS; i++) {
/* Find the corresponding rqeuest and call the callback */
Expand Down
46 changes: 30 additions & 16 deletions Libraries/Cordio/platform/targets/maxim/max32690/sources/pal_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,51 @@ static struct {
* \return None.
*/
/*************************************************************************************************/
void UART_CommonHandler(mxc_uart_regs_t *uart)
{
const int32_t err = MXC_UART_AsyncHandler(uart);

if(err == E_INVALID)
{
// If the uart is the console, we can try to recover since it is not critical
if(MXC_UART_GET_IDX(uart) == CONSOLE_UART)
{
MXC_UART_ClearRXFIFO(uart);
}
else
{
PAL_SYS_ASSERT(err == E_NO_ERROR);
}
}

}
void UART0_IRQHandler(void)
{
int result0;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result0 = MXC_UART_AsyncHandler(MXC_UART0);
(void)result0;
PAL_SYS_ASSERT(result0 == 0);
UART_CommonHandler(MXC_UART0);

}
void UART1_IRQHandler(void)
{
int result1;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result1 = MXC_UART_AsyncHandler(MXC_UART1);
(void)result1;
PAL_SYS_ASSERT(result1 == 0);
UART_CommonHandler(MXC_UART1);

}
void UART2_IRQHandler(void)
{
int result2;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result2 = MXC_UART_AsyncHandler(MXC_UART2);
(void)result2;
PAL_SYS_ASSERT(result2 == 0);
UART_CommonHandler(MXC_UART2);

}
void UART3_IRQHandler(void)
{
int result3;

PalLedOn(PAL_LED_ID_CPU_ACTIVE);
result3 = MXC_UART_AsyncHandler(MXC_UART3);
(void)result3;
PAL_SYS_ASSERT(result3 == 0);
UART_CommonHandler(MXC_UART3);

}

/*************************************************************************************************/
Expand Down

0 comments on commit 62377a9

Please sign in to comment.