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 #include "fsl_gpio.h" 14 15 /******************************************************************************* 16 * Definitions 17 ******************************************************************************/ 18 /*! @brief FRDM-TOUCH board defines */ 19 /* Push buttons - mutual electrodes */ 20 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_TX_ELECTRODE_1 TF_TSI_MUTUAL_CAP_TX_CHANNEL_3 /* PTE11 */ 21 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_RX_ELECTRODE_1 TF_TSI_MUTUAL_CAP_RX_CHANNEL_6 /* PTD5 */ 22 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_TX_ELECTRODE_2 TF_TSI_MUTUAL_CAP_TX_CHANNEL_3 /* PTE11 */ 23 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_RX_ELECTRODE_2 TF_TSI_MUTUAL_CAP_RX_CHANNEL_7 /* PTD6 */ 24 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_TX_ELECTRODE_3 TF_TSI_MUTUAL_CAP_TX_CHANNEL_2 /* PTE10 */ 25 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_RX_ELECTRODE_3 TF_TSI_MUTUAL_CAP_RX_CHANNEL_6 /* PTD5 */ 26 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_TX_ELECTRODE_4 TF_TSI_MUTUAL_CAP_TX_CHANNEL_2 /* PTE10 */ 27 #define FRDM_TOUCH_BOARD_TSI_MUTUAL_RX_ELECTRODE_4 TF_TSI_MUTUAL_CAP_RX_CHANNEL_7 /* PTD6 */ 28 29 /* Slider - self electrodes */ 30 #define FRDM_TOUCH_BOARD_TSI_SLIDER_ELECTRODE_1 TF_TSI_SELF_CAP_CHANNEL_10 /* PTD1 */ 31 #define FRDM_TOUCH_BOARD_TSI_SLIDER_ELECTRODE_2 TF_TSI_SELF_CAP_CHANNEL_5 /* PTD7 */ 32 33 /* Rotary - self electrodes */ 34 #define FRDM_TOUCH_BOARD_TSI_ROTARY_ELECTRODE_1 TF_TSI_SELF_CAP_CHANNEL_0 /* PTE5 */ 35 #define FRDM_TOUCH_BOARD_TSI_ROTARY_ELECTRODE_2 TF_TSI_SELF_CAP_CHANNEL_1 /* PTE4 */ 36 #define FRDM_TOUCH_BOARD_TSI_ROTARY_ELECTRODE_3 TF_TSI_SELF_CAP_CHANNEL_9 /* PTB5 */ 37 #define FRDM_TOUCH_BOARD_TSI_ROTARY_ELECTRODE_4 TF_TSI_SELF_CAP_CHANNEL_8 /* PTB4 */ 38 39 /*! @brief The board name */ 40 #define BOARD_NAME "FRDM-KE15Z" 41 42 /*! @brief The UART to use for debug messages. */ 43 #define BOARD_USE_UART 44 #define BOARD_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_LPUART 45 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1 46 #define BOARD_DEBUG_UART_INSTANCE 1U 47 #define BOARD_DEBUG_UART_CLKSRC kCLOCK_IpSrcSysOscAsync 48 #define BOARD_UART_IRQ LPUART1_IRQn 49 #define BOARD_UART_IRQ_HANDLER LPUART1_IRQHandler 50 51 #ifndef BOARD_DEBUG_UART_BAUDRATE 52 #define BOARD_DEBUG_UART_BAUDRATE 115200 53 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 54 55 /*! @brief The i2c instance used for i2c connection by default */ 56 #define BOARD_I2C_BASEADDR I2C0 57 58 /*! @brief The CMP instance/channel used for board. */ 59 #define BOARD_CMP_BASEADDR CMP0 60 #define BOARD_CMP_CHANNEL 7U 61 62 /*! @brief The rtc instance used for board. */ 63 #define BOARD_RTC_FUNC_BASEADDR RTC 64 65 /*! @brief Indexes of the TSI channels for on-board electrodes */ 66 #ifndef BOARD_TSI_ELECTRODE_1 67 #define BOARD_TSI_ELECTRODE_1 22U 68 #endif 69 #ifndef BOARD_TSI_ELECTRODE_2 70 #define BOARD_TSI_ELECTRODE_2 23U 71 #endif 72 73 /*! @brief Indexes of the TSI mutual channels for FRDM-TOUCH board */ 74 #define BOARD_TSI_MUTUAL_TX_ELECTRODE_1 2U 75 #define BOARD_TSI_MUTUAL_RX_ELECTRODE_1 6U 76 77 /* Board RGB LED color mapping */ 78 #define LOGIC_LED_ON 0U 79 #define LOGIC_LED_OFF 1U 80 #ifndef BOARD_LED_RED_GPIO 81 #define BOARD_LED_RED_GPIO GPIOD 82 #endif 83 #define BOARD_LED_RED_GPIO_PORT PORTD 84 #ifndef BOARD_LED_RED_GPIO_PIN 85 #define BOARD_LED_RED_GPIO_PIN 0U 86 #endif 87 #ifndef BOARD_LED_GREEN_GPIO 88 #define BOARD_LED_GREEN_GPIO GPIOD 89 #endif 90 #define BOARD_LED_GREEN_GPIO_PORT PORTD 91 #ifndef BOARD_LED_GREEN_GPIO_PIN 92 #define BOARD_LED_GREEN_GPIO_PIN 16U 93 #endif 94 #ifndef BOARD_LED_BLUE_GPIO 95 #define BOARD_LED_BLUE_GPIO GPIOD 96 #endif 97 #define BOARD_LED_BLUE_GPIO_PORT PORTD 98 #ifndef BOARD_LED_BLUE_GPIO_PIN 99 #define BOARD_LED_BLUE_GPIO_PIN 15U 100 #endif 101 102 #define LED_RED1_INIT(output) \ 103 GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \ 104 BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED1 */ 105 #define LED_RED1_ON() \ 106 GPIO_PortClear(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED1 */ 107 #define LED_RED1_OFF() \ 108 GPIO_PortSet(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED1 */ 109 #define LED_RED1_TOGGLE() \ 110 GPIO_PortToggle(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED1 */ 111 112 #define LED_GREEN1_INIT(output) \ 113 GPIO_PinWrite(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \ 114 BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN1 */ 115 #define LED_GREEN1_ON() \ 116 GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN1 */ 117 #define LED_GREEN1_OFF() \ 118 GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN1 */ 119 #define LED_GREEN1_TOGGLE() \ 120 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN1 */ 121 122 #define LED_BLUE_INIT(output) \ 123 GPIO_PinWrite(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, output); \ 124 BOARD_LED_BLUE_GPIO->PDDR |= (1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Enable target LED_BLUE */ 125 #define LED_BLUE_ON() \ 126 GPIO_PortClear(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 127 #define LED_BLUE_OFF() \ 128 GPIO_PortSet(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 129 #define LED_BLUE_TOGGLE() \ 130 GPIO_PortToggle(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 131 132 #if defined(__cplusplus) 133 extern "C" { 134 #endif /* __cplusplus */ 135 136 /******************************************************************************* 137 * API 138 ******************************************************************************/ 139 140 void BOARD_InitDebugConsole(void); 141 142 #if defined(__cplusplus) 143 } 144 #endif /* __cplusplus */ 145 146 #endif /* _BOARD_H_ */ 147