1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2018 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _BOARD_H_
10 #define _BOARD_H_
11 
12 #include "clock_config.h"
13 #include "fsl_gpio.h"
14 
15 /*******************************************************************************
16  * Definitions
17  ******************************************************************************/
18 /*! @brief The board name */
19 #define BOARD_NAME "HVP-KV31F120M"
20 
21 /*! @brief The UART to use for debug messages. */
22 #define BOARD_USE_UART
23 #define BOARD_DEBUG_UART_TYPE     kSerialPort_Uart
24 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART0
25 #define BOARD_DEBUG_UART_INSTANCE 0U
26 #define BOARD_DEBUG_UART_CLKSRC   kCLOCK_CoreSysClk
27 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetCoreSysClkFreq()
28 #define BOARD_UART_IRQ            UART0_RX_TX_IRQn
29 #define BOARD_UART_IRQ_HANDLER    UART0_RX_TX_IRQHandler
30 
31 #ifndef BOARD_DEBUG_UART_BAUDRATE
32 #define BOARD_DEBUG_UART_BAUDRATE 115200
33 #endif /* BOARD_DEBUG_UART_BAUDRATE */
34 
35 /* Board led color mapping */
36 #define LOGIC_LED_ON  0U
37 #define LOGIC_LED_OFF 1U
38 #ifndef BOARD_LED_RED_GPIO
39 #define BOARD_LED_RED_GPIO GPIOA
40 #endif
41 #define BOARD_LED_RED_GPIO_PORT PORTA
42 #ifndef BOARD_LED_RED_GPIO_PIN
43 #define BOARD_LED_RED_GPIO_PIN 5U
44 #endif
45 #ifndef BOARD_LED_GREEN_GPIO
46 #define BOARD_LED_GREEN_GPIO GPIOB
47 #endif
48 #define BOARD_LED_GREEN_GPIO_PORT PORTB
49 #ifndef BOARD_LED_GREEN_GPIO_PIN
50 #define BOARD_LED_GREEN_GPIO_PIN 19U
51 #endif
52 
53 #define LED_RED_INIT(output)                                           \
54     GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \
55     BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN)                         /*!< Enable target LED_RED */
56 #define LED_RED_ON()  GPIO_PortClear(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */
57 #define LED_RED_OFF() GPIO_PortSet(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN)   /*!< Turn off target LED_RED */
58 #define LED_RED_TOGGLE() \
59     GPIO_PortToggle(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */
60 
61 #define LED_GREEN_INIT(output)                                             \
62     GPIO_PinWrite(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \
63     BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN */
64 #define LED_GREEN_ON() \
65     GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */
66 #define LED_GREEN_OFF() \
67     GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */
68 #define LED_GREEN_TOGGLE() \
69     GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */
70 
71 #if defined(__cplusplus)
72 extern "C" {
73 #endif /* __cplusplus */
74 
75 /*******************************************************************************
76  * API
77  ******************************************************************************/
78 
79 void BOARD_InitDebugConsole(void);
80 
81 #if defined(__cplusplus)
82 }
83 #endif /* __cplusplus */
84 
85 #endif /* _BOARD_H_ */
86