1 /* 2 * Copyright (c) 2015, 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 19 /* The board name */ 20 #define BOARD_NAME "FRDM-KL27Z" 21 22 /* The LPUART to use for debug messages. */ 23 #define BOARD_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_LPUART 24 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART0 25 #define BOARD_DEBUG_UART_INSTANCE 0U 26 #define BOARD_DEBUG_UART_CLKSRC kCLOCK_McgIrc48MClk 27 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetPeriphClkFreq() 28 #define BOARD_UART_IRQ LPUART0_IRQn 29 #define BOARD_UART_IRQ_HANDLER LPUART0_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 GPIOB 40 #endif 41 #define BOARD_LED_RED_GPIO_PORT PORTB 42 #ifndef BOARD_LED_RED_GPIO_PIN 43 #define BOARD_LED_RED_GPIO_PIN 18U 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 #ifndef BOARD_LED_BLUE_GPIO 53 #define BOARD_LED_BLUE_GPIO GPIOA 54 #endif 55 #define BOARD_LED_BLUE_GPIO_PORT PORTA 56 #ifndef BOARD_LED_BLUE_GPIO_PIN 57 #define BOARD_LED_BLUE_GPIO_PIN 13U 58 #endif 59 60 #define LED_RED_INIT(output) \ 61 GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \ 62 BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED */ 63 #define LED_RED_ON() \ 64 GPIO_PortClear(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ 65 #define LED_RED_OFF() \ 66 GPIO_PortSet(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ 67 #define LED_RED_TOGGLE() \ 68 GPIO_PortToggle(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 69 70 #define LED_GREEN_INIT(output) \ 71 GPIO_PinWrite(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \ 72 BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN */ 73 #define LED_GREEN_ON() \ 74 GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */ 75 #define LED_GREEN_OFF() \ 76 GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ 77 #define LED_GREEN_TOGGLE() \ 78 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 79 80 #define LED_BLUE_INIT(output) \ 81 GPIO_PinWrite(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, output); \ 82 BOARD_LED_BLUE_GPIO->PDDR |= (1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Enable target LED_BLUE */ 83 #define LED_BLUE_ON() \ 84 GPIO_PortClear(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 85 #define LED_BLUE_OFF() \ 86 GPIO_PortSet(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 87 #define LED_BLUE_TOGGLE() \ 88 GPIO_PortToggle(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 89 90 #define BOARD_ACCEL_I2C_BASEADDR I2C1 91 92 /* ERPC SPI configuration */ 93 #define ERPC_BOARD_SPI_BASEADDR SPI0 94 #define ERPC_BOARD_SPI_BAUDRATE 500000U 95 #define ERPC_BOARD_SPI_CLKSRC SPI0_CLK_SRC 96 #define ERPC_BOARD_SPI_CLK_FREQ CLOCK_GetFreq(SPI0_CLK_SRC) 97 #define ERPC_BOARD_SPI_INT_GPIO GPIOB 98 #define ERPC_BOARD_SPI_INT_PORT PORTB 99 #define ERPC_BOARD_SPI_INT_PIN 0U 100 #define ERPC_BOARD_SPI_INT_PIN_IRQ PORTB_PORTC_PORTD_PORTE_IRQn 101 #define ERPC_BOARD_SPI_INT_PIN_IRQ_HANDLER PORTB_PORTC_PORTD_PORTE_IRQHandler 102 103 /* Board accelerometer driver */ 104 #define BOARD_ACCEL_MMA 105 106 #if defined(__cplusplus) 107 extern "C" { 108 #endif /* __cplusplus */ 109 110 /******************************************************************************* 111 * API 112 ******************************************************************************/ 113 114 void BOARD_InitDebugConsole(void); 115 116 #if defined(__cplusplus) 117 } 118 #endif /* __cplusplus */ 119 120 #endif /* _BOARD_H_ */ 121