ChibiOS/RT Architecture - Reference Manual - Guides |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. 00003 00004 This file is part of ChibiOS/RT. 00005 00006 ChibiOS/RT is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 ChibiOS/RT is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 --- 00020 00021 A special exception to the GPL can be applied should you wish to distribute 00022 a combined work that includes ChibiOS/RT, without being obliged to provide 00023 the source code for any proprietary components. See the file exception.txt 00024 for full details of how and when the exception can be applied. 00025 */ 00026 00027 /** 00028 * @file templates/pal_lld.h 00029 * @brief PAL subsystem low level driver header template. 00030 * 00031 * @addtogroup PAL_LLD 00032 * @{ 00033 */ 00034 00035 #ifndef _PAL_LLD_H_ 00036 #define _PAL_LLD_H_ 00037 00038 #if CH_HAL_USE_PAL || defined(__DOXYGEN__) 00039 00040 /*===========================================================================*/ 00041 /* Unsupported modes and specific modes */ 00042 /*===========================================================================*/ 00043 00044 /*===========================================================================*/ 00045 /* I/O Ports Types and constants. */ 00046 /*===========================================================================*/ 00047 00048 /** 00049 * @brief Generic I/O ports static initializer. 00050 * @details An instance of this structure must be passed to @p palInit() at 00051 * system startup time in order to initialized the digital I/O 00052 * subsystem. This represents only the initial setup, specific pads 00053 * or whole ports can be reprogrammed at later time. 00054 * @note This structure content is architecture dependent. The nome should 00055 * be changed to include the architecture name following this 00056 * pattern:<br> 00057 * - [ARCH][CELL]Config. 00058 * . 00059 * As example:<br> 00060 * - MSP430DIOConfig. 00061 * . 00062 */ 00063 typedef struct { 00064 00065 } GenericConfig; 00066 00067 /** 00068 * @brief Width, in bits, of an I/O port. 00069 */ 00070 #define PAL_IOPORTS_WIDTH 32 00071 00072 /** 00073 * @brief Whole port mask. 00074 * @brief This macro specifies all the valid bits into a port. 00075 */ 00076 #define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFF) 00077 00078 /** 00079 * @brief Digital I/O port sized unsigned type. 00080 */ 00081 typedef uint32_t ioportmask_t; 00082 00083 /** 00084 * @brief Port Identifier. 00085 * @details This type can be a scalar or some kind of pointer, do not make 00086 * any assumption about it, use the provided macros when populating 00087 * variables of this type. 00088 */ 00089 typedef uint32_t ioportid_t; 00090 00091 /*===========================================================================*/ 00092 /* I/O Ports Identifiers. */ 00093 /*===========================================================================*/ 00094 00095 /** 00096 * @brief First I/O port identifier. 00097 * @details Low level drivers can define multiple ports, it is suggested to 00098 * use this naming convention. 00099 */ 00100 #define IOPORT1 0 00101 00102 /*===========================================================================*/ 00103 /* Implementation, some of the following macros could be implemented as */ 00104 /* functions, if so please put them in pal_lld.c. */ 00105 /*===========================================================================*/ 00106 00107 /** 00108 * @brief Low level PAL subsystem initialization. 00109 * 00110 * @param[in] config architecture-dependent ports configuration 00111 */ 00112 #define pal_lld_init(config) 00113 00114 /** 00115 * @brief Reads the physical I/O port states. 00116 * @note This function is not meant to be invoked directly by the 00117 * application code. 00118 * 00119 * @param[in] port port identifier 00120 * @return The port bits. 00121 */ 00122 #define pal_lld_readport(port) 00123 00124 /** 00125 * @brief Reads the output latch. 00126 * @details The purpose of this function is to read back the latched output 00127 * value. 00128 * @note This function is not meant to be invoked directly by the 00129 * application code. 00130 * 00131 * @param[in] port port identifier 00132 * @return The latched logical states. 00133 */ 00134 #define pal_lld_readlatch(port) 00135 00136 /** 00137 * @brief Writes a bits mask on a I/O port. 00138 * @note This function is not meant to be invoked directly by the 00139 * application code. 00140 * 00141 * @param[in] port port identifier 00142 * @param[in] bits bits to be written on the specified port 00143 */ 00144 #define pal_lld_writeport(port, bits) 00145 00146 /** 00147 * @brief Sets a bits mask on a I/O port. 00148 * @note This function is not meant to be invoked directly by the 00149 * application code. 00150 * @note The @ref PAL provides a default software implementation of this 00151 * functionality, implement this function if can optimize it by using 00152 * special hardware functionalities or special coding. 00153 * 00154 * @param[in] port port identifier 00155 * @param[in] bits bits to be ORed on the specified port 00156 */ 00157 #define pal_lld_setport(port, bits) 00158 00159 /** 00160 * @brief Clears a bits mask on a I/O port. 00161 * @note This function is not meant to be invoked directly by the 00162 * application code. 00163 * @note The @ref PAL provides a default software implementation of this 00164 * functionality, implement this function if can optimize it by using 00165 * special hardware functionalities or special coding. 00166 * 00167 * @param[in] port port identifier 00168 * @param[in] bits bits to be cleared on the specified port 00169 */ 00170 #define pal_lld_clearport(port, bits) 00171 00172 /** 00173 * @brief Toggles a bits mask on a I/O port. 00174 * @note This function is not meant to be invoked directly by the 00175 * application code. 00176 * @note The @ref PAL provides a default software implementation of this 00177 * functionality, implement this function if can optimize it by using 00178 * special hardware functionalities or special coding. 00179 * 00180 * @param[in] port port identifier 00181 * @param[in] bits bits to be XORed on the specified port 00182 */ 00183 #define pal_lld_toggleport(port, bits) 00184 00185 /** 00186 * @brief Reads a group of bits. 00187 * @note This function is not meant to be invoked directly by the 00188 * application code. 00189 * @note The @ref PAL provides a default software implementation of this 00190 * functionality, implement this function if can optimize it by using 00191 * special hardware functionalities or special coding. 00192 * 00193 * @param[in] port port identifier 00194 * @param[in] mask group mask 00195 * @param[in] offset group bit offset within the port 00196 * @return The group logical states. 00197 */ 00198 #define pal_lld_readgroup(port, mask, offset) 00199 00200 /** 00201 * @brief Writes a group of bits. 00202 * @note This function is not meant to be invoked directly by the 00203 * application code. 00204 * @note The @ref PAL provides a default software implementation of this 00205 * functionality, implement this function if can optimize it by using 00206 * special hardware functionalities or special coding. 00207 * 00208 * @param[in] port port identifier 00209 * @param[in] mask group mask 00210 * @param[in] offset group bit offset within the port 00211 * @param[in] bits bits to be written. Values exceeding the group width 00212 * are masked. 00213 */ 00214 #define pal_lld_writegroup(port, mask, offset, bits) 00215 00216 /** 00217 * @brief Pads group mode setup. 00218 * @details This function programs a pads group belonging to the same port 00219 * with the specified mode. 00220 * @note This function is not meant to be invoked directly by the 00221 * application code. 00222 * @note Programming an unknown or unsupported mode is silently ignored. 00223 * 00224 * @param[in] port port identifier 00225 * @param[in] mask group mask 00226 * @param[in] mode group mode 00227 */ 00228 #define pal_lld_setgroupmode(port, mask, mode) 00229 00230 /** 00231 * @brief Reads a logical state from an I/O pad. 00232 * @note This function is not meant to be invoked directly by the 00233 * application code. 00234 * @note The @ref PAL provides a default software implementation of this 00235 * functionality, implement this function if can optimize it by using 00236 * special hardware functionalities or special coding. 00237 * 00238 * @param[in] port port identifier 00239 * @param[in] pad pad number within the port 00240 * @return The logical state. 00241 * @retval PAL_LOW low logical state. 00242 * @retval PAL_HIGH high logical state. 00243 */ 00244 #define pal_lld_readpad(port, pad) 00245 00246 /** 00247 * @brief Writes a logical state on an output pad. 00248 * @note This function is not meant to be invoked directly by the 00249 * application code. 00250 * @note The @ref PAL provides a default software implementation of this 00251 * functionality, implement this function if can optimize it by using 00252 * special hardware functionalities or special coding. 00253 * 00254 * @param[in] port port identifier 00255 * @param[in] pad pad number within the port 00256 * @param[out] bit logical value, the value must be @p PAL_LOW or 00257 * @p PAL_HIGH 00258 */ 00259 #define pal_lld_writepad(port, pad, bit) 00260 00261 /** 00262 * @brief Sets a pad logical state to @p PAL_HIGH. 00263 * @note This function is not meant to be invoked directly by the 00264 * application code. 00265 * @note The @ref PAL provides a default software implementation of this 00266 * functionality, implement this function if can optimize it by using 00267 * special hardware functionalities or special coding. 00268 * 00269 * @param[in] port port identifier 00270 * @param[in] pad pad number within the port 00271 */ 00272 #define pal_lld_setpad(port, pad) 00273 00274 /** 00275 * @brief Clears a pad logical state to @p PAL_LOW. 00276 * @note This function is not meant to be invoked directly by the 00277 * application code. 00278 * @note The @ref PAL provides a default software implementation of this 00279 * functionality, implement this function if can optimize it by using 00280 * special hardware functionalities or special coding. 00281 * 00282 * @param[in] port port identifier 00283 * @param[in] pad pad number within the port 00284 */ 00285 #define pal_lld_clearpad(port, pad) 00286 00287 /** 00288 * @brief Toggles a pad logical state. 00289 * @note This function is not meant to be invoked directly by the 00290 * application code. 00291 * @note The @ref PAL provides a default software implementation of this 00292 * functionality, implement this function if can optimize it by using 00293 * special hardware functionalities or special coding. 00294 * 00295 * @param[in] port port identifier 00296 * @param[in] pad pad number within the port 00297 */ 00298 #define pal_lld_togglepad(port, pad) 00299 00300 /** 00301 * @brief Pad mode setup. 00302 * @details This function programs a pad with the specified mode. 00303 * @note This function is not meant to be invoked directly by the 00304 * application code. 00305 * @note The @ref PAL provides a default software implementation of this 00306 * functionality, implement this function if can optimize it by using 00307 * special hardware functionalities or special coding. 00308 * @note Programming an unknown or unsupported mode is silently ignored. 00309 * 00310 * @param[in] port port identifier 00311 * @param[in] pad pad number within the port 00312 * @param[in] mode pad mode 00313 */ 00314 #define pal_lld_setpadmode(port, pad, mode) 00315 00316 #endif /* CH_HAL_USE_PAL */ 00317 00318 #endif /* _PAL_LLD_H_ */ 00319 00320 /** @} */