1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2018 NXP
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include <stdint.h>
9 #include "fsl_common.h"
10 #include "clock_config.h"
11 #include "board.h"
12 #include "fsl_debug_console.h"
13 
14 /*******************************************************************************
15  * Variables
16  ******************************************************************************/
17 
18 /* Clock rate on the CLKIN pin */
19 const uint32_t ExtClockIn = BOARD_EXTCLKINRATE;
20 
21 /*******************************************************************************
22  * Code
23  ******************************************************************************/
24 /* Initialize debug console. */
BOARD_InitDebugConsole(void)25 status_t BOARD_InitDebugConsole(void)
26 {
27 #if ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART))
28     status_t result;
29     /* Enable clock of uart0. */
30     CLOCK_EnableClock(kCLOCK_Uart0);
31     /* Ser DIV of uart0. */
32     CLOCK_SetClkDivider(kCLOCK_DivUsartClk, 1U);
33     RESET_PeripheralReset(BOARD_DEBUG_USART_RST);
34     result = DbgConsole_Init(BOARD_DEBUG_USART_INSTANCE, BOARD_DEBUG_USART_BAUDRATE, BOARD_DEBUG_USART_TYPE,
35                              BOARD_DEBUG_USART_CLK_FREQ);
36     assert(kStatus_Success == result);
37     return result;
38 #else
39     return kStatus_Success;
40 #endif
41 }
42