1 /* 2 * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016 NXP 4 * All rights reserved. 5 * 6 * 7 * SPDX-License-Identifier: BSD-3-Clause 8 */ 9 10 #include "fsl_common.h" 11 #include "fsl_debug_console.h" 12 #include "board.h" 13 14 /******************************************************************************* 15 * Variables 16 ******************************************************************************/ 17 18 /******************************************************************************* 19 * Code 20 ******************************************************************************/ 21 22 /* Get debug console frequency. */ BOARD_DebugConsoleSrcFreq(void)23uint32_t BOARD_DebugConsoleSrcFreq(void) 24 { 25 uint32_t freq; 26 27 /* To make it simple, we assume default PLL and divider settings, and the only variable 28 from application is use PLL3 source or OSC source */ 29 if (CLOCK_GetMux(kCLOCK_UartMux) == 0) /* PLL3 div6 80M */ 30 { 31 freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); 32 } 33 else 34 { 35 freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); 36 } 37 38 return freq; 39 } 40 41 /* Initialize debug console. */ BOARD_InitDebugConsole(void)42void BOARD_InitDebugConsole(void) 43 { 44 uint32_t uartClkSrcFreq = BOARD_DebugConsoleSrcFreq(); 45 46 DbgConsole_Init(BOARD_DEBUG_UART_BASEADDR, BOARD_DEBUG_UART_BAUDRATE, BOARD_DEBUG_UART_TYPE, uartClkSrcFreq); 47 } 48