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 19 /*! @brief The board name */ 20 #define BOARD_NAME "FRDM-KE02Z40M" 21 22 /*! @brief The UART to use for debug messages. */ 23 #define BOARD_USE_UART 24 #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart 25 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART1 26 #define BOARD_DEBUG_UART_INSTANCE 1U 27 #define BOARD_DEBUG_UART_CLKSRC kCLOCK_BusClk 28 #define BOARD_UART_IRQ UART1_IRQn 29 #define BOARD_UART_IRQ_HANDLER UART1_IRQHandler 30 31 #ifndef BOARD_DEBUG_UART_BAUDRATE 32 #define BOARD_DEBUG_UART_BAUDRATE 115200 33 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 34 35 /*! @brief The i2c instance used for i2c connection by default */ 36 #define BOARD_I2C_BASEADDR I2C0 37 38 #define BOARD_ACCEL_I2C_BASEADDR I2C0 39 40 /*! @brief The rtc instance used for board. */ 41 #define BOARD_RTC_FUNC_BASEADDR RTC 42 43 /*! @brief Indexes of the TSI channels for on-board electrodes */ 44 #ifndef BOARD_TSI_ELECTRODE_1 45 #define BOARD_TSI_ELECTRODE_1 22U 46 #endif 47 #ifndef BOARD_TSI_ELECTRODE_2 48 #define BOARD_TSI_ELECTRODE_2 23U 49 #endif 50 51 /*! @brief Indexes of the TSI mutual channels for FRDM-TOUCH board */ 52 #define BOARD_TSI_MUTUAL_TX_ELECTRODE_1 2U 53 #define BOARD_TSI_MUTUAL_RX_ELECTRODE_1 6U 54 55 /* Board RGB LED color mapping */ 56 #define LOGIC_LED_ON 0U 57 #define LOGIC_LED_OFF 1U 58 59 #define BOARD_LED_RED_GPIO_PORT kGPIO_PORTH 60 #ifndef BOARD_LED_RED_GPIO_PIN 61 #define BOARD_LED_RED_GPIO_PIN 1U 62 #endif 63 64 #define BOARD_LED_GREEN_GPIO_PORT kGPIO_PORTH 65 #ifndef BOARD_LED_GREEN_GPIO_PIN 66 #define BOARD_LED_GREEN_GPIO_PIN 2U 67 #endif 68 69 #define BOARD_LED_BLUE_GPIO_PORT kGPIO_PORTE 70 #ifndef BOARD_LED_BLUE_GPIO_PIN 71 #define BOARD_LED_BLUE_GPIO_PIN 7U 72 #endif 73 74 #define LED_RED1_INIT(output) \ 75 GPIO_PinWrite(BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, output); \ 76 GPIOB->PDDR |= (1U << (BOARD_LED_RED_GPIO_PIN + ((BOARD_LED_RED_GPIO_PORT % 4) * 8))) /*!< Enable target LED_RED1 \ 77 */ 78 #define LED_RED1_ON() \ 79 GPIO_PortClear(BOARD_LED_RED_GPIO_PORT, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED1 */ 80 #define LED_RED1_OFF() \ 81 GPIO_PortSet(BOARD_LED_RED_GPIO_PORT, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED1 */ 82 #define LED_RED1_TOGGLE() \ 83 GPIO_PortToggle(BOARD_LED_RED_GPIO_PORT, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED1 */ 84 85 #define LED_GREEN1_INIT(output) \ 86 GPIO_PinWrite(BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, output); \ 87 GPIOB->PDDR |= \ 88 (1U << (BOARD_LED_GREEN_GPIO_PIN + ((BOARD_LED_GREEN_GPIO_PORT % 4) * 8))) /*!< Enable target LED_GREEN1 */ 89 #define LED_GREEN1_ON() \ 90 GPIO_PortClear(BOARD_LED_GREEN_GPIO_PORT, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN1 */ 91 #define LED_GREEN1_OFF() \ 92 GPIO_PortSet(BOARD_LED_GREEN_GPIO_PORT, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN1 */ 93 #define LED_GREEN1_TOGGLE() \ 94 GPIO_PortToggle(BOARD_LED_GREEN_GPIO_PORT, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN1 */ 95 96 #define LED_BLUE_INIT(output) \ 97 GPIO_PinWrite(BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, output); \ 98 GPIOB->PDDR |= \ 99 (1U << (BOARD_LED_BLUE_GPIO_PIN + ((BOARD_LED_BLUE_GPIO_PORT % 4) * 8))) /*!< Enable target LED_BLUE */ 100 #define LED_BLUE_ON() \ 101 GPIO_PortClear(BOARD_LED_BLUE_GPIO_PORT, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 102 #define LED_BLUE_OFF() \ 103 GPIO_PortSet(BOARD_LED_BLUE_GPIO_PORT, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 104 #define LED_BLUE_TOGGLE() \ 105 GPIO_PortToggle(BOARD_LED_BLUE_GPIO_PORT, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 106 107 #if defined(__cplusplus) 108 extern "C" { 109 #endif /* __cplusplus */ 110 111 /******************************************************************************* 112 * API 113 ******************************************************************************/ 114 115 void BOARD_InitDebugConsole(void); 116 117 #if defined(__cplusplus) 118 } 119 #endif /* __cplusplus */ 120 121 #endif /* _BOARD_H_ */ 122