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