Skip to content

Commit

Permalink
fix(Examples,PeriphDrivers): Fix LPUART clock source settings for MAX…
Browse files Browse the repository at this point in the history
…78000 (#1284)
  • Loading branch information
kilicomercan authored Dec 4, 2024
1 parent 6a8efe1 commit ff1b441
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Examples/MAX78000/UART/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ int main(void)
printf("-->Example Failed\n");
return error;
}

#if defined(BOARD_EVKIT_V1)
if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK)) != E_NO_ERROR) {
#elif defined(BOARD_FTHR_REVA)
// We define UART3(LPUART) as WRITING_UART for FTHR Board.
// LPUART can use IBRO and ERTCO clocks.
if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_IBRO_CLK)) != E_NO_ERROR) {
#endif
printf("-->Error initializing UART: %d\n", error);
printf("-->Example Failed\n");
return error;
Expand Down
8 changes: 4 additions & 4 deletions Libraries/PeriphDrivers/Source/UART/uart_ai85.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock)
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 2;
clock_option = 0;
break;

case MXC_UART_ERTCO_CLK:
#ifndef MSDK_NO_GPIO_CLK_INIT
retval = MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
#endif // MSDK_NO_GPIO_CLK_INIT
clock_option = 3;
clock_option = 1;
break;

default:
Expand Down Expand Up @@ -316,9 +316,9 @@ mxc_uart_clock_t MXC_UART_GetClockSource(mxc_uart_regs_t *uart)
break;
case 3:
switch (clock_option) {
case 2:
case 0:
return MXC_UART_IBRO_CLK;
case 3:
case 1:
return MXC_UART_ERTCO_CLK;
default:
return E_BAD_STATE;
Expand Down

0 comments on commit ff1b441

Please sign in to comment.