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