1 /*
2  * Copyright 2021-2022 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _BOARD_H_
9 #define _BOARD_H_
10 
11 #include "clock_config.h"
12 #include "fsl_gpio.h"
13 
14 /*******************************************************************************
15  * Definitions
16  ******************************************************************************/
17 /*! @brief The board name */
18 #define BOARD_NAME "KW45B41Z-EVK"
19 
20 /* The UART to use for debug messages. */
21 #define BOARD_USE_LPUART
22 #define BOARD_DEBUG_UART_TYPE     kSerialPort_Uart
23 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1
24 #define BOARD_DEBUG_UART_INSTANCE 1U
25 #define BOARD_DEBUG_UART_CLK_FREQ (CLOCK_GetFreq(kCLOCK_ScgSircClk))
26 
27 #ifndef BOARD_DEBUG_UART_BAUDRATE
28 #define BOARD_DEBUG_UART_BAUDRATE (115200U)
29 #endif /* BOARD_DEBUG_UART_BAUDRATE */
30 
31 /*! @brief The LPSPI channel used for the external NOR flash */
32 #define BOARD_EEPROM_LPSPI_BASEADDR  LPSPI1
33 #define BOARD_LPSPI_CLK_FREQ         16000000U
34 #define BOARD_LPSPI_MRCC_ADDRESS     kCLOCK_Lpspi1
35 #define BOARD_LPSPI_CLKSRC           kCLOCK_IpSrcFro192M
36 #define BOARD_LPSPI_PCS_FOR_INIT     kLPSPI_Pcs0
37 #define BOARD_LPSPI_PCS_FOR_TRANSFER kLPSPI_MasterPcs0
38 #define BOARD_LPSPI_MRCC_CLK_DIV     1U
39 #define BOARD_LPSPI_NOR_BAUDRATE     4000000U
40 
41 /*! @brief The TPM channel used for board */
42 #define BOARD_TPM_CHANNEL 0U
43 
44 #define LOGIC_LED_ON  1U
45 #define LOGIC_LED_OFF 0U
46 
47 #ifndef BOARD_LED1_GPIO
48 #define BOARD_LED1_GPIO GPIOA
49 #endif
50 #ifndef BOARD_LED1_GPIO_PIN
51 #define BOARD_LED1_GPIO_PIN 19U
52 #endif
53 
54 #ifndef BOARD_LED2_GPIO
55 #define BOARD_LED2_GPIO GPIOA
56 #endif
57 #ifndef BOARD_LED2_GPIO_PIN
58 #define BOARD_LED2_GPIO_PIN 20U
59 #endif
60 
61 #ifndef BOARD_LED3_GPIO
62 #define BOARD_LED3_GPIO GPIOA
63 #endif
64 #ifndef BOARD_LED3_GPIO_PIN
65 #define BOARD_LED3_GPIO_PIN 21U
66 #endif
67 
68 #define LED1_INIT(output)                                        \
69     GPIO_PinWrite(BOARD_LED1_GPIO, BOARD_LED1_GPIO_PIN, output); \
70     BOARD_LED1_GPIO->PDDR |= (1U << BOARD_LED1_GPIO_PIN)                          /*!< Enable target LED1 */
71 #define LED1_ON()     GPIO_PortSet(BOARD_LED1_GPIO, 1U << BOARD_LED1_GPIO_PIN)    /*!< Turn on target LED1 */
72 #define LED1_OFF()    GPIO_PortClear(BOARD_LED1_GPIO, 1U << BOARD_LED1_GPIO_PIN)  /*!< Turn off target LED1 */
73 #define LED1_TOGGLE() GPIO_PortToggle(BOARD_LED1_GPIO, 1U << BOARD_LED1_GPIO_PIN) /*!< Toggle on target LED1 */
74 
75 #define LED2_INIT(output)                                        \
76     GPIO_PinWrite(BOARD_LED2_GPIO, BOARD_LED2_GPIO_PIN, output); \
77     BOARD_LED2_GPIO->PDDR |= (1U << BOARD_LED2_GPIO_PIN)                          /*!< Enable target LED2 */
78 #define LED2_ON()     GPIO_PortSet(BOARD_LED2_GPIO, 1U << BOARD_LED2_GPIO_PIN)    /*!< Turn on target LED2 */
79 #define LED2_OFF()    GPIO_PortClear(BOARD_LED2_GPIO, 1U << BOARD_LED2_GPIO_PIN)  /*!< Turn off target LED2 */
80 #define LED2_TOGGLE() GPIO_PortToggle(BOARD_LED2_GPIO, 1U << BOARD_LED2_GPIO_PIN) /*!< Toggle on target LED2 */
81 
82 #define LED3_INIT(output)                                        \
83     GPIO_PinWrite(BOARD_LED3_GPIO, BOARD_LED3_GPIO_PIN, output); \
84     BOARD_LED3_GPIO->PDDR |= (1U << BOARD_LED3_GPIO_PIN)                          /*!< Enable target LED3 */
85 #define LED3_ON()     GPIO_PortSet(BOARD_LED3_GPIO, 1U << BOARD_LED3_GPIO_PIN)    /*!< Turn on target LED3 */
86 #define LED3_OFF()    GPIO_PortClear(BOARD_LED3_GPIO, 1U << BOARD_LED3_GPIO_PIN)  /*!< Turn off target LED3 */
87 #define LED3_TOGGLE() GPIO_PortToggle(BOARD_LED3_GPIO, 1U << BOARD_LED3_GPIO_PIN) /*!< Toggle on target LED3 */
88 
89 #define BOARD_SW2_NAME        "SW2"
90 #define BOARD_SW2_GPIO        GPIOD
91 #define BOARD_SW2_GPIO_PIN    1U
92 #define BOARD_SW2_IRQ         GPIOD_INT0_IRQn
93 #define BOARD_SW2_IRQ_HANDLER GPIOD_INT0_IRQHandler
94 
95 #define BOARD_SW3_NAME        "SW3"
96 #define BOARD_SW3_GPIO        GPIOC
97 #define BOARD_SW3_GPIO_PIN    6U
98 #define BOARD_SW3_IRQ         GPIOC_INT0_IRQn
99 #define BOARD_SW3_IRQ_HANDLER GPIOC_INT0_IRQHandler
100 
101 #define BOARD_SW4_NAME        "SW4"
102 #define BOARD_SW4_GPIO        GPIOA
103 #define BOARD_SW4_GPIO_PIN    4U
104 #define BOARD_SW4_IRQ         GPIOA_INT0_IRQn
105 #define BOARD_SW4_IRQ_HANDLER GPIOA_INT0_IRQHandler
106 
107 #define BOARD_ACCEL_I2C_BASEADDR LPI2C1
108 
109 #if defined(__cplusplus)
110 extern "C" {
111 #endif /* __cplusplus */
112 
113 /*******************************************************************************
114  * API
115  ******************************************************************************/
116 
117 void BOARD_InitDebugConsole(void);
118 
119 #if defined(__cplusplus)
120 }
121 #endif /* __cplusplus */
122 
123 #endif /* _BOARD_H_ */
124