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 /*! @brief The board name */ 19 #define BOARD_NAME "FRDM-K22F" 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) UART1 25 #define BOARD_DEBUG_UART_CLKSRC SYS_CLK 26 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetCoreSysClkFreq() 27 #define BOARD_UART_IRQ UART1_RX_TX_IRQn 28 #define BOARD_UART_IRQ_HANDLER UART1_RX_TX_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 bubble level demo information */ 35 #define BOARD_FXOS8700_ADDR 0x1C 36 #define BOARD_ACCEL_ADDR BOARD_FXOS8700_ADDR 37 #define BOARD_ACCEL_BAUDRATE 100 38 #define BOARD_ACCEL_I2C_BASEADDR I2C0 39 40 /*! @brief The i2c instance used for i2c connection by default */ 41 #define BOARD_I2C_BASEADDR I2C0 42 43 /*! @brief The CMP instance/channel used for board. */ 44 #define BOARD_CMP_BASEADDR CMP0 45 #define BOARD_CMP_CHANNEL 0U 46 47 /*! @brief The rtc instance used for board. */ 48 #define BOARD_RTC_FUNC_BASEADDR RTC 49 50 /*! @brief Define the port interrupt number for the board switches */ 51 #define BOARD_SW3_GPIO GPIOB 52 #define BOARD_SW3_PORT PORTB 53 #define BOARD_SW3_GPIO_PIN 17 54 #define BOARD_SW3_IRQ PORTB_IRQn 55 #define BOARD_SW3_IRQ_HANDLER PORTB_IRQHandler 56 #define BOARD_SW3_NAME "SW3" 57 58 #define BOARD_SW2_GPIO GPIOC 59 #define BOARD_SW2_PORT PORTC 60 #define BOARD_SW2_GPIO_PIN 1 61 #define BOARD_SW2_IRQ PORTC_IRQn 62 #define BOARD_SW2_IRQ_HANDLER PORTC_IRQHandler 63 #define BOARD_SW2_NAME "SW2" 64 65 /* Board led color mapping */ 66 #define LOGIC_LED_ON 0U 67 #define LOGIC_LED_OFF 1U 68 #define BOARD_LED_RED_GPIO GPIOA 69 #define BOARD_LED_RED_GPIO_PORT PORTA 70 #define BOARD_LED_RED_GPIO_PIN 1U 71 #define BOARD_LED_GREEN_GPIO GPIOA 72 #define BOARD_LED_GREEN_GPIO_PORT PORTA 73 #define BOARD_LED_GREEN_GPIO_PIN 2U 74 #define BOARD_LED_BLUE_GPIO GPIOD 75 #define BOARD_LED_BLUE_GPIO_PORT PORTD 76 #define BOARD_LED_BLUE_GPIO_PIN 5U 77 78 #define LED_RED_INIT(output) \ 79 GPIO_WritePinOutput(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \ 80 BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED */ 81 #define LED_RED_ON() \ 82 GPIO_ClearPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ 83 #define LED_RED_OFF() \ 84 GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ 85 #define LED_RED_TOGGLE() \ 86 GPIO_TogglePinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 87 88 #define LED_GREEN_INIT(output) \ 89 GPIO_WritePinOutput(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \ 90 BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN */ 91 #define LED_GREEN_ON() \ 92 GPIO_ClearPinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */ 93 #define LED_GREEN_OFF() \ 94 GPIO_SetPinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ 95 #define LED_GREEN_TOGGLE() \ 96 GPIO_TogglePinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 97 98 #define LED_BLUE_INIT(output) \ 99 GPIO_WritePinOutput(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, output); \ 100 BOARD_LED_BLUE_GPIO->PDDR |= (1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Enable target LED_BLUE */ 101 #define LED_BLUE_ON() \ 102 GPIO_ClearPinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 103 #define LED_BLUE_OFF() \ 104 GPIO_SetPinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 105 #define LED_BLUE_TOGGLE() \ 106 GPIO_TogglePinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 107 108 /* ERPC DSPI configuration */ 109 #define ERPC_BOARD_DSPI_BASEADDR SPI0 110 #define ERPC_BOARD_DSPI_BAUDRATE 500000U 111 #define ERPC_BOARD_DSPI_CLKSRC DSPI0_CLK_SRC 112 #define ERPC_BOARD_DSPI_CLK_FREQ CLOCK_GetFreq(DSPI0_CLK_SRC) 113 #define ERPC_BOARD_DSPI_INT_GPIO GPIOB 114 #define ERPC_BOARD_DSPI_INT_PORT PORTB 115 #define ERPC_BOARD_DSPI_INT_PIN 2U 116 #define ERPC_BOARD_DSPI_INT_PIN_IRQ PORTB_IRQn 117 #define ERPC_BOARD_DSPI_INT_PIN_IRQ_HANDLER PORTB_IRQHandler 118 119 /* @brief The SDSPI disk PHY configuration. */ 120 #define BOARD_SDSPI_SPI_BASE SPI0_BASE /*!< SPI base address for SDSPI */ 121 #define BOARD_SDSPI_CD_GPIO_BASE GPIOB /*!< Port related to card detect pin for SDSPI */ 122 #define BOARD_SDSPI_CD_PIN 16U /*!< Card detect pin for SDSPI */ 123 #define BOARD_SDSPI_CD_LOGIC_RISING /*!< Logic of card detect pin for SDSPI */ 124 125 /* DAC base address */ 126 #define BOARD_DAC_BASEADDR DAC0 127 128 /* Board accelerometer driver */ 129 #define BOARD_ACCEL_FXOS 130 131 #if defined(__cplusplus) 132 extern "C" { 133 #endif /* __cplusplus */ 134 135 /******************************************************************************* 136 * API 137 ******************************************************************************/ 138 139 void BOARD_InitDebugConsole(void); 140 141 #if defined(__cplusplus) 142 } 143 #endif /* __cplusplus */ 144 145 #endif /* _BOARD_H_ */ 146