From a49ab427442a41d07e19024fcc216c4094c72f22 Mon Sep 17 00:00:00 2001 From: "ANALOG\\OKilic" Date: Tue, 3 Dec 2024 16:09:17 +0300 Subject: [PATCH] fix(Examples,PeriphDrivers): Fix clock option value setting for UART-IBRO and UART-ERTCO clocks in MAX78000. --- Examples/MAX78000/UART/main.c | 7 ++++++- Libraries/PeriphDrivers/Source/UART/uart_ai85.c | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Examples/MAX78000/UART/main.c b/Examples/MAX78000/UART/main.c index 1250a042d04..b46e4a4628d 100644 --- a/Examples/MAX78000/UART/main.c +++ b/Examples/MAX78000/UART/main.c @@ -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; diff --git a/Libraries/PeriphDrivers/Source/UART/uart_ai85.c b/Libraries/PeriphDrivers/Source/UART/uart_ai85.c index 11ca9567843..ead00fc63b6 100644 --- a/Libraries/PeriphDrivers/Source/UART/uart_ai85.c +++ b/Libraries/PeriphDrivers/Source/UART/uart_ai85.c @@ -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: @@ -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;