stm32f10x_fsmc.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:19k
源码类别:

uCOS

开发平台:

C/C++

  1. /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
  2. * File Name          : stm32f10x_fsmc.h
  3. * Author             : MCD Application Team
  4. * Version            : V2.0.2
  5. * Date               : 07/11/2008
  6. * Description        : This file contains all the functions prototypes for the
  7. *                      FSMC firmware library.
  8. ********************************************************************************
  9. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  10. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  11. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  12. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  13. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  14. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  15. *******************************************************************************/
  16. /* Define to prevent recursive inclusion -------------------------------------*/
  17. #ifndef __STM32F10x_FSMC_H
  18. #define __STM32F10x_FSMC_H
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "stm32f10x_map.h"
  21. /* Exported types ------------------------------------------------------------*/
  22. /* Timing parameters For NOR/SRAM Banks */
  23. typedef struct
  24. {
  25.   u32 FSMC_AddressSetupTime;
  26.   u32 FSMC_AddressHoldTime;
  27.   u32 FSMC_DataSetupTime;
  28.   u32 FSMC_BusTurnAroundDuration;
  29.   u32 FSMC_CLKDivision;
  30.   u32 FSMC_DataLatency;
  31.   u32 FSMC_AccessMode;
  32. }FSMC_NORSRAMTimingInitTypeDef;
  33. /* FSMC NOR/SRAM Init structure definition */
  34. typedef struct
  35. {
  36.   u32 FSMC_Bank;
  37.   u32 FSMC_DataAddressMux;
  38.   u32 FSMC_MemoryType;
  39.   u32 FSMC_MemoryDataWidth;
  40.   u32 FSMC_BurstAccessMode;
  41.   u32 FSMC_WaitSignalPolarity;
  42.   u32 FSMC_WrapMode;
  43.   u32 FSMC_WaitSignalActive;
  44.   u32 FSMC_WriteOperation;
  45.   u32 FSMC_WaitSignal;
  46.   u32 FSMC_ExtendedMode;
  47.   u32 FSMC_AsyncWait;
  48.   u32 FSMC_WriteBurst;
  49.   /* Timing Parameters for write and read access if the  ExtendedMode is not used*/
  50.   FSMC_NORSRAMTimingInitTypeDef* FSMC_ReadWriteTimingStruct;
  51.   /* Timing Parameters for write access if the  ExtendedMode is used*/
  52.   FSMC_NORSRAMTimingInitTypeDef* FSMC_WriteTimingStruct;
  53. }FSMC_NORSRAMInitTypeDef;
  54. /* Timing parameters For FSMC NAND and PCCARD Banks */
  55. typedef struct
  56. {
  57.   u32 FSMC_SetupTime;
  58.   u32 FSMC_WaitSetupTime;
  59.   u32 FSMC_HoldSetupTime;
  60.   u32 FSMC_HiZSetupTime;
  61. }FSMC_NAND_PCCARDTimingInitTypeDef;
  62. /* FSMC NAND Init structure definition */
  63. typedef struct
  64. {
  65.   u32 FSMC_Bank;
  66.   u32 FSMC_Waitfeature;
  67.   u32 FSMC_MemoryDataWidth;
  68.   u32 FSMC_ECC;
  69.   u32 FSMC_ECCPageSize;
  70.   u32 FSMC_AddressLowMapping;
  71.   u32 FSMC_TCLRSetupTime;
  72.   u32 FSMC_TARSetupTime;
  73.   /* FSMC Common Space Timing */
  74.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_CommonSpaceTimingStruct;
  75.   /* FSMC Attribute Space Timing */
  76.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_AttributeSpaceTimingStruct;
  77. }FSMC_NANDInitTypeDef;
  78. /* FSMC PCCARD Init structure definition */
  79. typedef struct
  80. {
  81.   u32 FSMC_Waitfeature;
  82.   u32 FSMC_AddressLowMapping;
  83.   u32 FSMC_TCLRSetupTime;
  84.   u32 FSMC_TARSetupTime;
  85.   /* FSMC Common Space Timing */
  86.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_CommonSpaceTimingStruct;
  87.   /* FSMC Attribute Space Timing */
  88.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_AttributeSpaceTimingStruct;
  89.   /* FSMC IO Space Timing */
  90.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_IOSpaceTimingStruct;
  91. }FSMC_PCCARDInitTypeDef;
  92. /* Exported constants --------------------------------------------------------*/
  93. /*-------------------------------FSMC Banks definitions ----------------------*/
  94. #define FSMC_Bank1_NORSRAM1                             ((u32)0x00000000)
  95. #define FSMC_Bank1_NORSRAM2                             ((u32)0x00000002)
  96. #define FSMC_Bank1_NORSRAM3                             ((u32)0x00000004)
  97. #define FSMC_Bank1_NORSRAM4                             ((u32)0x00000006)
  98. #define FSMC_Bank2_NAND                                 ((u32)0x00000010)
  99. #define FSMC_Bank3_NAND                                 ((u32)0x00000100)
  100. #define FSMC_Bank4_PCCARD                               ((u32)0x00001000)
  101. #define IS_FSMC_NORSRAM_BANK(BANK) (((BANK) == FSMC_Bank1_NORSRAM1) || 
  102.                                     ((BANK) == FSMC_Bank1_NORSRAM2) || 
  103.                                     ((BANK) == FSMC_Bank1_NORSRAM3) || 
  104.                                     ((BANK) == FSMC_Bank1_NORSRAM4))                           
  105. #define IS_FSMC_NAND_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || 
  106.                                  ((BANK) == FSMC_Bank3_NAND))
  107. #define IS_FSMC_GETFLAG_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || 
  108.                                     ((BANK) == FSMC_Bank3_NAND) || 
  109.                                     ((BANK) == FSMC_Bank4_PCCARD))
  110.                                     
  111. #define IS_FSMC_IT_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || 
  112.                                ((BANK) == FSMC_Bank3_NAND) || 
  113.                                ((BANK) == FSMC_Bank4_PCCARD))                                    
  114. /*------------------------------- NOR/SRAM Banks -----------------------------*/
  115. /* FSMC Data/Address Bus Multiplexing ----------------------------------------*/
  116. #define FSMC_DataAddressMux_Disable                       ((u32)0x00000000)
  117. #define FSMC_DataAddressMux_Enable                        ((u32)0x00000002)
  118. #define IS_FSMC_MUX(MUX) (((MUX) == FSMC_DataAddressMux_Disable) || 
  119.                           ((MUX) == FSMC_DataAddressMux_Enable))                           
  120. /* FSMC Memory Type ----------------------------------------------------------*/
  121. #define FSMC_MemoryType_SRAM                            ((u32)0x00000000)
  122. #define FSMC_MemoryType_CRAM                            ((u32)0x00000004)
  123. #define FSMC_MemoryType_NOR                             ((u32)0x00000008)
  124. #define FSMC_MemoryType_COSMORAM                        ((u32)0x0000000C)
  125. #define IS_FSMC_MEMORY(MEMORY) (((MEMORY) == FSMC_MemoryType_SRAM) || 
  126.                                 ((MEMORY) == FSMC_MemoryType_CRAM)|| 
  127.                                 ((MEMORY) == FSMC_MemoryType_NOR)|| 
  128.                                 ((MEMORY) == FSMC_MemoryType_COSMORAM))
  129.                                      
  130. /* FSMC  Data Width ----------------------------------------------------------*/
  131. #define FSMC_MemoryDataWidth_8b                         ((u32)0x00000000)
  132. #define FSMC_MemoryDataWidth_16b                        ((u32)0x00000010)
  133. #define IS_FSMC_MEMORY_WIDTH(WIDTH) (((WIDTH) == FSMC_MemoryDataWidth_8b) || 
  134.                                      ((WIDTH) == FSMC_MemoryDataWidth_16b))
  135.                                       
  136.                                
  137. /* FSMC Burst Access Mode ----------------------------------------------------*/
  138. #define FSMC_BurstAccessMode_Disable                    ((u32)0x00000000) 
  139. #define FSMC_BurstAccessMode_Enable                     ((u32)0x00000100)
  140. #define IS_FSMC_BURSTMODE(STATE) (((STATE) == FSMC_BurstAccessMode_Disable) || 
  141.                                   ((STATE) == FSMC_BurstAccessMode_Enable))
  142. /* FSMC Wait Signal Polarity -------------------------------------------------*/                                  
  143. #define FSMC_WaitSignalPolarity_Low                     ((u32)0x00000000)
  144. #define FSMC_WaitSignalPolarity_High                    ((u32)0x00000200)
  145. #define IS_FSMC_WAIT_POLARITY(POLARITY) (((POLARITY) == FSMC_WaitSignalPolarity_Low) || 
  146.                                          ((POLARITY) == FSMC_WaitSignalPolarity_High)) 
  147.                                         
  148. /* FSMC Wrap Mode ------------------------------------------------------------*/ 
  149. #define FSMC_WrapMode_Disable                           ((u32)0x00000000)
  150. #define FSMC_WrapMode_Enable                            ((u32)0x00000400) 
  151. #define IS_FSMC_WRAP_MODE(MODE) (((MODE) == FSMC_WrapMode_Disable) || 
  152.                                  ((MODE) == FSMC_WrapMode_Enable))
  153.                                  
  154. /* FSMC Wait Timing ----------------------------------------------------------*/                                 
  155. #define FSMC_WaitSignalActive_BeforeWaitState           ((u32)0x00000000)
  156. #define FSMC_WaitSignalActive_DuringWaitState           ((u32)0x00000800) 
  157. #define IS_FSMC_WAIT_SIGNAL_ACTIVE(ACTIVE) (((ACTIVE) == FSMC_WaitSignalActive_BeforeWaitState) || 
  158.                                             ((ACTIVE) == FSMC_WaitSignalActive_DuringWaitState))
  159.                                     
  160. /* FSMC Write Operation ------------------------------------------------------*/
  161. #define FSMC_WriteOperation_Disable                     ((u32)0x00000000)
  162. #define FSMC_WriteOperation_Enable                      ((u32)0x00001000)
  163. #define IS_FSMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FSMC_WriteOperation_Disable) || 
  164.                                             ((OPERATION) == FSMC_WriteOperation_Enable))
  165.                               
  166. /* FSMC Wait Signal ----------------------------------------------------------*/
  167. #define FSMC_WaitSignal_Disable                         ((u32)0x00000000)
  168. #define FSMC_WaitSignal_Enable                          ((u32)0x00002000) 
  169. #define IS_FSMC_WAITE_SIGNAL(SIGNAL) (((SIGNAL) == FSMC_WaitSignal_Disable) || 
  170.                                       ((SIGNAL) == FSMC_WaitSignal_Enable))
  171. /* FSMC Extended Mode --------------------------------------------------------*/
  172. #define FSMC_ExtendedMode_Disable                       ((u32)0x00000000)
  173. #define FSMC_ExtendedMode_Enable                        ((u32)0x00004000)                                  
  174. #define IS_FSMC_EXTENDED_MODE(MODE) (((MODE) == FSMC_ExtendedMode_Disable) || 
  175.                                      ((MODE) == FSMC_ExtendedMode_Enable)) 
  176.                                
  177. /* FSMC Asynchronous Wait ----------------------------------------------------*/
  178. #define FSMC_AsyncWait_Disable                          ((u32)0x00000000)
  179. #define FSMC_AsyncWait_Enable                           ((u32)0x00008000)
  180. #define IS_FSMC_ASYNC_WAIT(WAIT) (((WAIT) == FSMC_AsyncWait_Disable) || 
  181.                                   ((WAIT) == FSMC_AsyncWait_Enable))
  182.                                   
  183. /* FSMC Write Burst ----------------------------------------------------------*/                                  
  184. #define FSMC_WriteBurst_Disable                         ((u32)0x00000000)
  185. #define FSMC_WriteBurst_Enable                          ((u32)0x00080000) 
  186. #define IS_FSMC_WRITE_BURST(BURST) (((BURST) == FSMC_WriteBurst_Disable) || 
  187.                                     ((BURST) == FSMC_WriteBurst_Enable))
  188. /* FSMC Address Setup Time ---------------------------------------------------*/
  189. #define IS_FSMC_ADDRESS_SETUP_TIME(TIME) ((TIME) <= 0xF)
  190. /* FSMC Address Hold Time ----------------------------------------------------*/
  191. #define IS_FSMC_ADDRESS_HOLD_TIME(TIME) ((TIME) <= 0xF)
  192. /* FSMC Data Setup Time ------------------------------------------------------*/
  193. #define IS_FSMC_DATASETUP_TIME(TIME) (((TIME) > 0) && ((TIME) <= 0xFF))
  194. /* FSMC Bus Turn around Duration ---------------------------------------------*/
  195. #define IS_FSMC_TURNAROUND_TIME(TIME) ((TIME) <= 0xF)
  196. /* FSMC CLK Division ---------------------------------------------------------*/
  197. #define IS_FSMC_CLK_DIV(DIV) ((DIV) <= 0xF)
  198. /* FSMC Data Latency ---------------------------------------------------------*/
  199. #define IS_FSMC_DATA_LATENCY(LATENCY) ((LATENCY) <= 0xF)
  200. /* FSMC Access Mode ----------------------------------------------------------*/
  201. #define FSMC_AccessMode_A                               ((u32)0x00000000)
  202. #define FSMC_AccessMode_B                               ((u32)0x10000000) 
  203. #define FSMC_AccessMode_C                               ((u32)0x20000000)
  204. #define FSMC_AccessMode_D                               ((u32)0x30000000)
  205. #define IS_FSMC_ACCESS_MODE(MODE) (((MODE) == FSMC_AccessMode_A) || 
  206.                                    ((MODE) == FSMC_AccessMode_B) || 
  207.                                    ((MODE) == FSMC_AccessMode_C) || 
  208.                                    ((MODE) == FSMC_AccessMode_D)) 
  209.                                   
  210. /*----------------------------- NAND and PCCARD Banks ------------------------*/
  211. /* FSMC Wait feature ---------------------------------------------------------*/
  212. #define FSMC_Waitfeature_Disable                        ((u32)0x00000000)
  213. #define FSMC_Waitfeature_Enable                         ((u32)0x00000002)
  214. #define IS_FSMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FSMC_Waitfeature_Disable) || 
  215.                                        ((FEATURE) == FSMC_Waitfeature_Enable))
  216.                                     
  217. /* FSMC Memory Data Width ----------------------------------------------------*/
  218. #define FSMC_MemoryDataWidth_8b                         ((u32)0x00000000)
  219. #define FSMC_MemoryDataWidth_16b                        ((u32)0x00000010)
  220. #define IS_FSMC_DATA_WIDTH(WIDTH) (((WIDTH) == FSMC_MemoryDataWidth_8b) || 
  221.                                    ((WIDTH) == FSMC_MemoryDataWidth_16b))
  222.                                     
  223. /* FSMC ECC ------------------------------------------------------------------*/
  224. #define FSMC_ECC_Disable                                ((u32)0x00000000)
  225. #define FSMC_ECC_Enable                                 ((u32)0x00000040)
  226. #define IS_FSMC_ECC_STATE(STATE) (((STATE) == FSMC_ECC_Disable) || 
  227.                                   ((STATE) == FSMC_ECC_Enable))
  228.                                             
  229. /* FSMC ECC Page Size --------------------------------------------------------*/
  230. #define FSMC_ECCPageSize_256Bytes                       ((u32)0x00000000)
  231. #define FSMC_ECCPageSize_512Bytes                       ((u32)0x00020000)
  232. #define FSMC_ECCPageSize_1024Bytes                      ((u32)0x00040000)
  233. #define FSMC_ECCPageSize_2048Bytes                      ((u32)0x00060000)
  234. #define FSMC_ECCPageSize_4096Bytes                      ((u32)0x00080000)
  235. #define FSMC_ECCPageSize_8192Bytes                      ((u32)0x000A0000)
  236. #define IS_FSMC_ECCPAGE_SIZE(SIZE) (((SIZE) == FSMC_ECCPageSize_256Bytes) || 
  237.                                     ((SIZE) == FSMC_ECCPageSize_512Bytes) || 
  238.                                     ((SIZE) == FSMC_ECCPageSize_1024Bytes) || 
  239.                                     ((SIZE) == FSMC_ECCPageSize_2048Bytes) || 
  240.                                     ((SIZE) == FSMC_ECCPageSize_4096Bytes) || 
  241.                                     ((SIZE) == FSMC_ECCPageSize_8192Bytes))
  242.                                                               
  243. /* FSMC Address Low Mapping --------------------------------------------------*/
  244. #define FSMC_AddressLowMapping_Direct                   ((u32)0x00000000)
  245. #define FSMC_AddressLowMapping_InDirect                 ((u32)0x00000100)
  246. #define IS_FSMC_ADDRESS_LOW_MAPPING(MAPPING) (((MAPPING) == FSMC_AddressLowMapping_Direct) || 
  247.                                               ((MAPPING) == FSMC_AddressLowMapping_InDirect))
  248. /* FSMC TCLR Setup Time ------------------------------------------------------*/
  249. #define IS_FSMC_TCLR_TIME(TIME) ((TIME) <= 0xFF)
  250. /* FSMC TAR Setup Time -------------------------------------------------------*/
  251. #define IS_FSMC_TAR_TIME(TIME) ((TIME) <= 0xFF)
  252. /* FSMC Setup Time ----------------------------------------------------*/
  253. #define IS_FSMC_SETUP_TIME(TIME) ((TIME) <= 0xFF)
  254. /* FSMC Wait Setup Time -----------------------------------------------*/
  255. #define IS_FSMC_WAIT_TIME(TIME) ((TIME) <= 0xFF)
  256. /* FSMC Hold Setup Time -----------------------------------------------*/
  257. #define IS_FSMC_HOLD_TIME(TIME) ((TIME) <= 0xFF)
  258. /* FSMC HiZ Setup Time ------------------------------------------------*/
  259. #define IS_FSMC_HIZ_TIME(TIME) ((TIME) <= 0xFF)
  260. /* FSMC Interrupt sources ----------------------------------------------------*/
  261. #define FSMC_IT_RisingEdge                              ((u32)0x00000008)
  262. #define FSMC_IT_Level                                   ((u32)0x00000010)
  263. #define FSMC_IT_FallingEdge                             ((u32)0x00000020)
  264. #define IS_FSMC_IT(IT) ((((IT) & (u32)0xFFFFFFC7) == 0x00000000) && ((IT) != 0x00000000))
  265. #define IS_FSMC_GET_IT(IT) (((IT) == FSMC_IT_RisingEdge) || 
  266.                             ((IT) == FSMC_IT_Level) || 
  267.                             ((IT) == FSMC_IT_FallingEdge)) 
  268. /* FSMC Flags ----------------------------------------------------------------*/
  269. #define FSMC_FLAG_RisingEdge                            ((u32)0x00000001)
  270. #define FSMC_FLAG_Level                                 ((u32)0x00000002)
  271. #define FSMC_FLAG_FallingEdge                           ((u32)0x00000004)
  272. #define FSMC_FLAG_FEMPT                                 ((u32)0x00000040)
  273. #define IS_FSMC_GET_FLAG(FLAG) (((FLAG) == FSMC_FLAG_RisingEdge) || 
  274.                                 ((FLAG) == FSMC_FLAG_Level) || 
  275.                                 ((FLAG) == FSMC_FLAG_FallingEdge) || 
  276.                                 ((FLAG) == FSMC_FLAG_FEMPT))
  277. #define IS_FSMC_CLEAR_FLAG(FLAG) ((((FLAG) & (u32)0xFFFFFFF8) == 0x00000000) && ((FLAG) != 0x00000000))                                                                                                                                                                                                                                                                                                                                  
  278. /* Exported macro ------------------------------------------------------------*/
  279. /* Exported functions ------------------------------------------------------- */
  280. void FSMC_NORSRAMDeInit(u32 FSMC_Bank);
  281. void FSMC_NANDDeInit(u32 FSMC_Bank);
  282. void FSMC_PCCARDDeInit(void);
  283. void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
  284. void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
  285. void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
  286. void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
  287. void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
  288. void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
  289. void FSMC_NORSRAMCmd(u32 FSMC_Bank, FunctionalState NewState);
  290. void FSMC_NANDCmd(u32 FSMC_Bank, FunctionalState NewState);
  291. void FSMC_PCCARDCmd(FunctionalState NewState);
  292. void FSMC_NANDECCCmd(u32 FSMC_Bank, FunctionalState NewState);
  293. u32 FSMC_GetECC(u32 FSMC_Bank);
  294. void FSMC_ITConfig(u32 FSMC_Bank, u32 FSMC_IT, FunctionalState NewState);
  295. FlagStatus FSMC_GetFlagStatus(u32 FSMC_Bank, u32 FSMC_FLAG);
  296. void FSMC_ClearFlag(u32 FSMC_Bank, u32 FSMC_FLAG);
  297. ITStatus FSMC_GetITStatus(u32 FSMC_Bank, u32 FSMC_IT);
  298. void FSMC_ClearITPendingBit(u32 FSMC_Bank, u32 FSMC_IT);
  299. #endif /*__STM32F10x_FSMC_H */
  300. /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/