1 /* 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * Copyright 2016-2018 NXP 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _BOARD_H_ 9 #define _BOARD_H_ 10 11 #include "clock_config.h" 12 #include "fsl_gpio.h" 13 14 /******************************************************************************* 15 * Definitions 16 ******************************************************************************/ 17 /*! @brief The board name */ 18 #define BOARD_NAME "TWR-KM34Z75M" 19 20 /*! @brief The UART to use for debug messages. */ 21 #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart 22 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART2 23 #define BOARD_DEBUG_UART_INSTANCE 2U 24 #define BOARD_DEBUG_UART_CLKSRC BUS_CLK 25 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetBusClkFreq() 26 #define BOARD_UART_IRQ UART0_UART1_UART2_UART3_IRQn 27 #define BOARD_UART_IRQ_HANDLER UART0_UART1_UART2_UART3_IRQHandler 28 29 #ifndef BOARD_DEBUG_UART_BAUDRATE 30 #define BOARD_DEBUG_UART_BAUDRATE 115200 31 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 32 33 #ifndef BOARD_LPUART_CLOCK_SOURCE 34 #define BOARD_LPUART_CLOCK_SOURCE kClockLpuartSrcOsc0erClk 35 #endif 36 37 /*! @brief The spi instance used for board. */ 38 #define BOARD_SPI_BASEADDR SPI0 39 40 /*! @brief The i2c instance used for board. */ 41 #define BOARD_I2C_BASEADDR I2C0 42 43 /*! @brief ADC0 input channel */ 44 #define BOARD_ADC0_INPUT_CHANNEL 0U 45 46 /*! @brief The CMP instance/channel used for board. */ 47 #define BOARD_CMP_BASEADDR CMP2 48 #define BOARD_CMP_CHANNEL 4U 49 50 /*! @brief The rtc instance used for board. */ 51 #define BOARD_RTC_FUNC_BASEADDR RTC 52 53 /*! @brief Define the port interrupt number for the board switches */ 54 #ifndef BOARD_SW1_GPIO 55 #define BOARD_SW1_GPIO GPIOA 56 #endif 57 #ifndef BOARD_SW1_PORT 58 #define BOARD_SW1_PORT PORTA 59 #endif 60 #ifndef BOARD_SW1_GPIO_PIN 61 #define BOARD_SW1_GPIO_PIN 4U 62 #endif 63 #define BOARD_SW1_IRQ PTx_IRQn 64 #define BOARD_SW1_IRQ_HANDLER PTx_IRQHandler 65 #define BOARD_SW1_NAME "SW1" 66 67 /* Board led color mapping */ 68 #define LOGIC_LED_ON 0U 69 #define LOGIC_LED_OFF 1U 70 #ifndef BOARD_LED_RED_GPIO 71 #define BOARD_LED_RED_GPIO GPIOJ 72 #endif 73 #define BOARD_LED_RED_GPIO_PORT PORTJ 74 #ifndef BOARD_LED_RED_GPIO_PIN 75 #define BOARD_LED_RED_GPIO_PIN 4U 76 #endif 77 #ifndef BOARD_LED_GREEN_GPIO 78 #define BOARD_LED_GREEN_GPIO GPIOJ 79 #endif 80 #define BOARD_LED_GREEN_GPIO_PORT PORTJ 81 #ifndef BOARD_LED_GREEN_GPIO_PIN 82 #define BOARD_LED_GREEN_GPIO_PIN 3U 83 #endif 84 #ifndef BOARD_LED_ORANGE_GPIO 85 #define BOARD_LED_ORANGE_GPIO GPIOD 86 #endif 87 #define BOARD_LED_ORANGE_GPIO_PORT PORTD 88 #ifndef BOARD_LED_ORANGE_GPIO_PIN 89 #define BOARD_LED_ORANGE_GPIO_PIN 0U 90 #endif 91 92 #define LED_RED_INIT(output) \ 93 GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \ 94 BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED */ 95 #define LED_RED_ON() GPIO_PortClear(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ 96 #define LED_RED_OFF() GPIO_PortSet(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ 97 #define LED_RED_TOGGLE() \ 98 GPIO_PortToggle(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 99 100 #define LED_GREEN_INIT(output) \ 101 GPIO_PinWrite(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \ 102 BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN */ 103 #define LED_GREEN_ON() \ 104 GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */ 105 #define LED_GREEN_OFF() \ 106 GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ 107 #define LED_GREEN_TOGGLE() \ 108 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 109 110 #define LED_ORANGE_INIT(output) \ 111 GPIO_PinWrite(BOARD_LED_ORANGE_GPIO, BOARD_LED_ORANGE_GPIO_PIN, output); \ 112 BOARD_LED_ORANGE_GPIO->PDDR |= (1U << BOARD_LED_ORANGE_GPIO_PIN) /*!< Enable target LED_ORANGE */ 113 #define LED_ORANGE_ON() \ 114 GPIO_PortClear(BOARD_LED_ORANGE_GPIO, 1U << BOARD_LED_ORANGE_GPIO_PIN) /*!< Turn on target LED_ORANGE */ 115 #define LED_ORANGE_OFF() \ 116 GPIO_PortSet(BOARD_LED_ORANGE_GPIO, 1U << BOARD_LED_ORANGE_GPIO_PIN) /*!< Turn off target LED_ORANGE */ 117 #define LED_ORANGE_TOGGLE() \ 118 GPIO_PortToggle(BOARD_LED_ORANGE_GPIO, 1U << BOARD_LED_ORANGE_GPIO_PIN) /*!< Toggle on target LED_ORANGE */ 119 120 #define BOARD_ACCEL_I2C_BASEADDR I2C0 121 122 #if defined(__cplusplus) 123 extern "C" { 124 #endif /* __cplusplus */ 125 126 /******************************************************************************* 127 * API 128 ******************************************************************************/ 129 130 void BOARD_InitDebugConsole(void); 131 132 #if defined(__cplusplus) 133 } 134 #endif /* __cplusplus */ 135 136 #endif /* _BOARD_H_ */ 137