1 /* 2 * @brief Common board API functions 3 * 4 * @note 5 * Copyright(C) NXP Semiconductors, 2013 6 * All rights reserved. 7 * 8 * @par 9 * Software that is described herein is for illustrative purposes only 10 * which provides customers with programming information regarding the 11 * LPC products. This software is supplied "AS IS" without any warranties of 12 * any kind, and NXP Semiconductors and its licensor disclaim any and 13 * all warranties, express or implied, including all implied warranties of 14 * merchantability, fitness for a particular purpose and non-infringement of 15 * intellectual property rights. NXP Semiconductors assumes no responsibility 16 * or liability for the use of the software, conveys no license or rights under any 17 * patent, copyright, mask work right, or any other intellectual property rights in 18 * or to any products. NXP Semiconductors reserves the right to make changes 19 * in the software without notification. NXP Semiconductors also makes no 20 * representation or warranty that such application will be suitable for the 21 * specified use without further testing or modification. 22 * 23 * @par 24 * Permission to use, copy, modify, and distribute this software and its 25 * documentation is hereby granted, under NXP Semiconductors' and its 26 * licensor's relevant copyrights in the software, without fee, provided that it 27 * is used in conjunction with NXP Semiconductors microcontrollers. This 28 * copyright, permission, and disclaimer notice must appear in all copies of 29 * this code. 30 */ 31 32 #ifndef __BOARD_API_H_ 33 #define __BOARD_API_H_ 34 35 #include "lpc_types.h" 36 #include <stdio.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /** @defgroup BOARD_COMMON_API BOARD: Common board functions 43 * @ingroup BOARD_Common 44 * This file contains common board definitions that are shared across 45 * boards and devices. All of these functions do not need to be 46 * implemented for a specific board, but if they are implemented, they 47 * should use this API standard. 48 * @{ 49 */ 50 51 /** 52 * @brief Setup and initialize hardware prior to call to main() 53 * @return None 54 * @note Board_SystemInit() is called prior to the application and sets up system 55 * clocking, memory, and any resources needed prior to the application 56 * starting. 57 */ 58 void Board_SystemInit(void); 59 60 /** 61 * @brief Setup pin multiplexer per board schematics 62 * @return None 63 * @note Board_SetupMuxing() should be called from SystemInit() prior to application 64 * main() is called. So that the PINs are set in proper state. 65 */ 66 void Board_SetupMuxing(void); 67 68 /** 69 * @brief Setup system clocking 70 * @return None 71 * @note This sets up board clocking. 72 */ 73 void Board_SetupClocking(void); 74 75 /** 76 * @brief Setup external system memory 77 * @return None 78 * @note This function is typically called after pin mux setup and clock setup and 79 * sets up any external memory needed by the system (DRAM, SRAM, etc.). Not all 80 * boards need this function. 81 */ 82 void Board_SetupExtMemory(void); 83 84 /** 85 * @brief Set up and initialize all required blocks and functions related to the board hardware. 86 * @return None 87 */ 88 void Board_Init(void); 89 90 /** 91 * @brief Initializes board UART for output, required for printf redirection 92 * @return None 93 */ 94 void Board_Debug_Init(void); 95 96 /** 97 * @brief Sends a single character on the UART, required for printf redirection 98 * @param ch : character to send 99 * @return None 100 */ 101 void Board_UARTPutChar(char ch); 102 103 /** 104 * @brief Get a single character from the UART, required for scanf input 105 * @return EOF if not character was received, or character value 106 */ 107 int Board_UARTGetChar(void); 108 109 /** 110 * @brief Prints a string to the UART 111 * @param str : Terminated string to output 112 * @return None 113 */ 114 void Board_UARTPutSTR(char *str); 115 116 /** 117 * @brief Sets the state of a board LED to on or off 118 * @param LEDNumber : LED number to set state for 119 * @param State : true for on, false for off 120 * @return None 121 */ 122 void Board_LED_Set(uint8_t LEDNumber, bool State); 123 124 /** 125 * @brief Returns the current state of a board LED 126 * @param LEDNumber : LED number to set state for 127 * @return true if the LED is on, otherwise false 128 */ 129 bool Board_LED_Test(uint8_t LEDNumber); 130 131 /** 132 * @brief Toggles the current state of a board LED 133 * @param LEDNumber : LED number to change state for 134 * @return None 135 */ 136 void Board_LED_Toggle(uint8_t LEDNumber); 137 138 /** 139 * @brief Turn on Board LCD Backlight 140 * @param Intensity : Backlight intensity (0 = off, >=1 = on) 141 * @return None 142 * @note On boards where a GPIO is used to control backlight on/off state, a '0' or '1' 143 * value will turn off or on the backlight. On some boards, a non-0 value will 144 * control backlight intensity via a PWN. For PWM systems, the intensity value 145 * is a percentage value between 0 and 100%. 146 */ 147 void Board_SetLCDBacklight(uint8_t Intensity); 148 149 /** 150 * @brief Function prototype for a MS delay function. Board layers or example code may 151 * define this function as needed. 152 */ 153 typedef void (*p_msDelay_func_t)(uint32_t); 154 155 /* The DEBUG* functions are selected based on system configuration. 156 Code that uses the DEBUG* functions will have their I/O routed to 157 the UART, semihosting, or nowhere. */ 158 #if defined(DEBUG_ENABLE) 159 #if defined(DEBUG_SEMIHOSTING) 160 #define DEBUGINIT() 161 #define DEBUGOUT(...) printf(__VA_ARGS__) 162 #define DEBUGSTR(str) printf(str) 163 #define DEBUGIN() (int) EOF 164 165 #else 166 #define DEBUGINIT() Board_Debug_Init() 167 #define DEBUGOUT(...) printf(__VA_ARGS__) 168 #define DEBUGSTR(str) Board_UARTPutSTR(str) 169 #define DEBUGIN() Board_UARTGetChar() 170 #endif /* defined(DEBUG_SEMIHOSTING) */ 171 172 #else 173 #define DEBUGINIT() 174 #define DEBUGOUT(...) 175 #define DEBUGSTR(str) 176 #define DEBUGIN() (int) EOF 177 #endif /* defined(DEBUG_ENABLE) */ 178 179 /** 180 * @} 181 */ 182 183 #ifdef __cplusplus 184 } 185 #endif 186 187 #endif /* __BOARD_API_H_ */ 188