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/spi_lld.h 00029 * @brief SPI Driver subsystem low level driver header template. 00030 * 00031 * @addtogroup SPI_LLD 00032 * @{ 00033 */ 00034 00035 #ifndef _SPI_LLD_H_ 00036 #define _SPI_LLD_H_ 00037 00038 #if CH_HAL_USE_SPI || defined(__DOXYGEN__) 00039 00040 /*===========================================================================*/ 00041 /* Driver constants. */ 00042 /*===========================================================================*/ 00043 00044 /*===========================================================================*/ 00045 /* Driver pre-compile time settings. */ 00046 /*===========================================================================*/ 00047 00048 /*===========================================================================*/ 00049 /* Derived constants and error checks. */ 00050 /*===========================================================================*/ 00051 00052 /*===========================================================================*/ 00053 /* Driver data structures and types. */ 00054 /*===========================================================================*/ 00055 00056 /** 00057 * @brief Driver configuration structure. 00058 */ 00059 typedef struct { 00060 00061 } SPIConfig; 00062 00063 /** 00064 * @brief Structure representing a SPI driver. 00065 */ 00066 typedef struct { 00067 /** 00068 * @brief Driver state. 00069 */ 00070 spistate_t spd_state; 00071 #if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__) 00072 #if CH_USE_MUTEXES || defined(__DOXYGEN__) 00073 /** 00074 * @brief Mutex protecting the bus. 00075 */ 00076 Mutex spd_mutex; 00077 #elif CH_USE_SEMAPHORES 00078 Semaphore spd_semaphore; 00079 #endif 00080 #endif /* SPI_USE_MUTUAL_EXCLUSION */ 00081 /** 00082 * @brief Current configuration data. 00083 */ 00084 const SPIConfig *spd_config; 00085 /* End of the mandatory fields.*/ 00086 } SPIDriver; 00087 00088 /*===========================================================================*/ 00089 /* Driver macros. */ 00090 /*===========================================================================*/ 00091 00092 /*===========================================================================*/ 00093 /* External declarations. */ 00094 /*===========================================================================*/ 00095 00096 #ifdef __cplusplus 00097 extern "C" { 00098 #endif 00099 void spi_lld_init(void); 00100 void spi_lld_start(SPIDriver *spip); 00101 void spi_lld_stop(SPIDriver *spip); 00102 void spi_lld_select(SPIDriver *spip); 00103 void spi_lld_unselect(SPIDriver *spip); 00104 void spi_lld_ignore(SPIDriver *spip, size_t n); 00105 void spi_lld_exchange(SPIDriver *spip, size_t n, 00106 const void *txbuf, void *rxbuf); 00107 void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf); 00108 void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf); 00109 #ifdef __cplusplus 00110 } 00111 #endif 00112 00113 #endif /* CH_HAL_USE_SPI */ 00114 00115 #endif /* _SPI_LLD_H_ */ 00116 00117 /** @} */