1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 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 
14 /*******************************************************************************
15  * Definitions
16  ******************************************************************************/
17 
18 /*! @brief The board name */
19 #define BOARD_NAME "FRDM-KE04Z"
20 
21 /*! @brief The UART to use for debug messages. */
22 #define BOARD_USE_UART
23 #define BOARD_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_UART
24 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART0
25 #define BOARD_DEBUG_UART_INSTANCE 0U
26 #define BOARD_DEBUG_UART_CLKSRC kCLOCK_BusClk
27 #define BOARD_UART_IRQ UART0_IRQn
28 #define BOARD_UART_IRQ_HANDLER UART0_IRQHandler
29 
30 #ifndef BOARD_DEBUG_UART_BAUDRATE
31 #define BOARD_DEBUG_UART_BAUDRATE 115200
32 #endif /* BOARD_DEBUG_UART_BAUDRATE */
33 
34 /*! @brief The i2c instance used for i2c connection by default */
35 #define BOARD_I2C_BASEADDR I2C0
36 
37 #define BOARD_ACCEL_I2C_BASEADDR I2C0
38 
39 /*! @brief The rtc instance used for board. */
40 #define BOARD_RTC_FUNC_BASEADDR RTC
41 
42 /*! @brief Indexes of the TSI channels for on-board electrodes */
43 #ifndef BOARD_TSI_ELECTRODE_1
44 #define BOARD_TSI_ELECTRODE_1 22U
45 #endif
46 #ifndef BOARD_TSI_ELECTRODE_2
47 #define BOARD_TSI_ELECTRODE_2 23U
48 #endif
49 
50 /*! @brief Indexes of the TSI mutual channels for FRDM-TOUCH board */
51 #define BOARD_TSI_MUTUAL_TX_ELECTRODE_1 2U
52 #define BOARD_TSI_MUTUAL_RX_ELECTRODE_1 6U
53 
54 /* Board RGB LED color mapping */
55 #define LOGIC_LED_ON 0U
56 #define LOGIC_LED_OFF 1U
57 #ifndef BOARD_LED_RED_GPIO
58 #define BOARD_LED_RED_GPIO GPIOA
59 #endif
60 #define BOARD_LED_RED_GPIO_PORT PORTC
61 #ifndef BOARD_LED_RED_GPIO_PIN
62 #define BOARD_LED_RED_GPIO_PIN 21U
63 #endif
64 #ifndef BOARD_LED_GREEN_GPIO
65 #define BOARD_LED_GREEN_GPIO GPIOC
66 #endif
67 #define BOARD_LED_GREEN_GPIO_PORT PORTA
68 #ifndef BOARD_LED_GREEN_GPIO_PIN
69 #define BOARD_LED_GREEN_GPIO_PIN 20U
70 #endif
71 #ifndef BOARD_LED_BLUE_GPIO
72 #define BOARD_LED_BLUE_GPIO GPIOB
73 #endif
74 #define BOARD_LED_BLUE_GPIO_PORT PORTA
75 #ifndef BOARD_LED_BLUE_GPIO_PIN
76 #define BOARD_LED_BLUE_GPIO_PIN 11U
77 #endif
78 
79 #define LED_RED1_INIT(output)                                                \
80     GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \
81     BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED1 */
82 #define LED_RED1_ON() \
83     GPIO_PortClear(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED1 */
84 #define LED_RED1_OFF() \
85     GPIO_PortSet(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED1 */
86 #define LED_RED1_TOGGLE() \
87     GPIO_PortToggle(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED1 */
88 
89 #define LED_GREEN1_INIT(output)                                                  \
90     GPIO_PinWrite(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \
91     BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN1 */
92 #define LED_GREEN1_ON() \
93     GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN1 */
94 #define LED_GREEN1_OFF() \
95     GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN1 */
96 #define LED_GREEN1_TOGGLE() \
97     GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN1 */
98 
99 #define LED_BLUE_INIT(output)                                                  \
100     GPIO_PinWrite(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, output); \
101     BOARD_LED_BLUE_GPIO->PDDR |= (1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Enable target LED_BLUE */
102 #define LED_BLUE_ON() \
103     GPIO_PortClear(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */
104 #define LED_BLUE_OFF() \
105     GPIO_PortSet(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */
106 #define LED_BLUE_TOGGLE() \
107     GPIO_PortToggle(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */
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