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_CLKSRC kCLOCK_McgIrc48MClk 26 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetPeriphClkFreq() 27 #define BOARD_UART_IRQ LPUART0_IRQn 28 #define BOARD_UART_IRQ_HANDLER LPUART0_IRQHandler 29 30 #ifndef BOARD_DEBUG_UART_BAUDRATE 31 #define BOARD_DEBUG_UART_BAUDRATE 115200 32 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 33 34 /* Define the port macros for the board switches */ 35 #define BOARD_SW1_GPIO GPIOA 36 #define BOARD_SW1_PORT PORTA 37 #define BOARD_SW1_GPIO_PIN 4U 38 #define BOARD_SW1_IRQ PORTA_IRQn 39 #define BOARD_SW1_IRQ_HANDLER PORTA_IRQHandler 40 #define BOARD_SW1_NAME "SW1" 41 42 #define BOARD_SW3_GPIO GPIOC 43 #define BOARD_SW3_PORT PORTC 44 #define BOARD_SW3_GPIO_PIN 1U 45 #define BOARD_SW3_IRQ PORTB_PORTC_PORTD_PORTE_IRQn 46 #define BOARD_SW3_IRQ_HANDLER PORTB_PORTC_PORTD_PORTE_IRQHandler 47 #define BOARD_SW3_NAME "SW3" 48 49 #define LLWU_SW_GPIO BOARD_SW3_GPIO 50 #define LLWU_SW_PORT BOARD_SW3_PORT 51 #define LLWU_SW_GPIO_PIN BOARD_SW3_GPIO_PIN 52 #define LLWU_SW_IRQ BOARD_SW3_IRQ 53 #define LLWU_SW_IRQ_HANDLER BOARD_SW3_IRQ_HANDLER 54 #define LLWU_SW_NAME BOARD_SW3_NAME 55 56 /* Board led color mapping */ 57 #define LOGIC_LED_ON 0U 58 #define LOGIC_LED_OFF 1U 59 #define BOARD_LED_RED_GPIO GPIOB 60 #define BOARD_LED_RED_GPIO_PORT PORTB 61 #define BOARD_LED_RED_GPIO_PIN 18U 62 #define BOARD_LED_GREEN_GPIO GPIOB 63 #define BOARD_LED_GREEN_GPIO_PORT PORTB 64 #define BOARD_LED_GREEN_GPIO_PIN 19U 65 #define BOARD_LED_BLUE_GPIO GPIOA 66 #define BOARD_LED_BLUE_GPIO_PORT PORTA 67 #define BOARD_LED_BLUE_GPIO_PIN 13U 68 69 #define LED_RED_INIT(output) \ 70 GPIO_WritePinOutput(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \ 71 BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED */ 72 #define LED_RED_ON() \ 73 GPIO_ClearPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ 74 #define LED_RED_OFF() \ 75 GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ 76 #define LED_RED_TOGGLE() \ 77 GPIO_TogglePinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 78 79 #define LED_GREEN_INIT(output) \ 80 GPIO_WritePinOutput(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \ 81 BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN */ 82 #define LED_GREEN_ON() \ 83 GPIO_ClearPinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */ 84 #define LED_GREEN_OFF() \ 85 GPIO_SetPinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ 86 #define LED_GREEN_TOGGLE() \ 87 GPIO_TogglePinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 88 89 #define LED_BLUE_INIT(output) \ 90 GPIO_WritePinOutput(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, output); \ 91 BOARD_LED_BLUE_GPIO->PDDR |= (1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Enable target LED_BLUE */ 92 #define LED_BLUE_ON() \ 93 GPIO_ClearPinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 94 #define LED_BLUE_OFF() \ 95 GPIO_SetPinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 96 #define LED_BLUE_TOGGLE() \ 97 GPIO_TogglePinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 98 99 #define BOARD_ACCEL_I2C_BASEADDR I2C1 100 101 /* ERPC SPI configuration */ 102 #define ERPC_BOARD_SPI_BASEADDR SPI0 103 #define ERPC_BOARD_SPI_BAUDRATE 500000U 104 #define ERPC_BOARD_SPI_CLKSRC SPI0_CLK_SRC 105 #define ERPC_BOARD_SPI_CLK_FREQ CLOCK_GetFreq(SPI0_CLK_SRC) 106 #define ERPC_BOARD_SPI_INT_GPIO GPIOB 107 #define ERPC_BOARD_SPI_INT_PORT PORTB 108 #define ERPC_BOARD_SPI_INT_PIN 0U 109 #define ERPC_BOARD_SPI_INT_PIN_IRQ PORTB_PORTC_PORTD_PORTE_IRQn 110 #define ERPC_BOARD_SPI_INT_PIN_IRQ_HANDLER PORTB_PORTC_PORTD_PORTE_IRQHandler 111 112 /* Board accelerometer driver */ 113 #define BOARD_ACCEL_MMA 114 115 #if defined(__cplusplus) 116 extern "C" { 117 #endif /* __cplusplus */ 118 119 /******************************************************************************* 120 * API 121 ******************************************************************************/ 122 123 void BOARD_InitDebugConsole(void); 124 125 #if defined(__cplusplus) 126 } 127 #endif /* __cplusplus */ 128 129 #endif /* _BOARD_H_ */ 130