2 ******************************************************************************
\r
3 * @file stm32l1xx_fsmc.h
\r
4 * @author MCD Application Team
\r
6 * @date 05-March-2012
\r
7 * @brief This file contains all the functions prototypes for the FSMC firmware
\r
9 ******************************************************************************
\r
12 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
\r
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
\r
15 * You may not use this file except in compliance with the License.
\r
16 * You may obtain a copy of the License at:
\r
18 * http://www.st.com/software_license_agreement_liberty_v2
\r
20 * Unless required by applicable law or agreed to in writing, software
\r
21 * distributed under the License is distributed on an "AS IS" BASIS,
\r
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
23 * See the License for the specific language governing permissions and
\r
24 * limitations under the License.
\r
26 ******************************************************************************
\r
29 /* Define to prevent recursive inclusion -------------------------------------*/
\r
30 #ifndef __STM32L1xx_FSMC_H
\r
31 #define __STM32L1xx_FSMC_H
\r
37 /* Includes ------------------------------------------------------------------*/
\r
38 #include "stm32l1xx.h"
\r
40 /** @addtogroup STM32L1xx_StdPeriph_Driver
\r
44 /** @addtogroup FSMC
\r
48 /* Exported types ------------------------------------------------------------*/
\r
51 * @brief Timing parameters For NOR/SRAM Banks
\r
56 uint32_t FSMC_AddressSetupTime; /*!< Defines the number of HCLK cycles to configure
\r
57 the duration of the address setup time.
\r
58 This parameter can be a value between 0 and 0xF.
\r
59 @note It is not used with synchronous NOR Flash memories. */
\r
61 uint32_t FSMC_AddressHoldTime; /*!< Defines the number of HCLK cycles to configure
\r
62 the duration of the address hold time.
\r
63 This parameter can be a value between 0 and 0xF.
\r
64 @note It is not used with synchronous NOR Flash memories.*/
\r
66 uint32_t FSMC_DataSetupTime; /*!< Defines the number of HCLK cycles to configure
\r
67 the duration of the data setup time.
\r
68 This parameter can be a value between 0 and 0xFF.
\r
69 @note It is used for SRAMs, ROMs and asynchronous multiplexed NOR Flash memories. */
\r
71 uint32_t FSMC_BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure
\r
72 the duration of the bus turnaround.
\r
73 This parameter can be a value between 0 and 0xF.
\r
74 @note It is only used for multiplexed NOR Flash memories. */
\r
76 uint32_t FSMC_CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of HCLK cycles.
\r
77 This parameter can be a value between 1 and 0xF.
\r
78 @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM accesses. */
\r
80 uint32_t FSMC_DataLatency; /*!< Defines the number of memory clock cycles to issue
\r
81 to the memory before getting the first data.
\r
82 The parameter value depends on the memory type as shown below:
\r
83 - It must be set to 0 in case of a CRAM
\r
84 - It is don't care in asynchronous NOR, SRAM or ROM accesses
\r
85 - It may assume a value between 0 and 0xF in NOR Flash memories
\r
86 with synchronous burst mode enable */
\r
88 uint32_t FSMC_AccessMode; /*!< Specifies the asynchronous access mode.
\r
89 This parameter can be a value of @ref FSMC_Access_Mode */
\r
90 }FSMC_NORSRAMTimingInitTypeDef;
\r
93 * @brief FSMC NOR/SRAM Init structure definition
\r
98 uint32_t FSMC_Bank; /*!< Specifies the NOR/SRAM memory bank that will be used.
\r
99 This parameter can be a value of @ref FSMC_NORSRAM_Bank */
\r
101 uint32_t FSMC_DataAddressMux; /*!< Specifies whether the address and data values are
\r
102 multiplexed on the databus or not.
\r
103 This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing */
\r
105 uint32_t FSMC_MemoryType; /*!< Specifies the type of external memory attached to
\r
106 the corresponding memory bank.
\r
107 This parameter can be a value of @ref FSMC_Memory_Type */
\r
109 uint32_t FSMC_MemoryDataWidth; /*!< Specifies the external memory device width.
\r
110 This parameter can be a value of @ref FSMC_Data_Width */
\r
112 uint32_t FSMC_BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory,
\r
113 valid only with synchronous burst Flash memories.
\r
114 This parameter can be a value of @ref FSMC_Burst_Access_Mode */
\r
116 uint32_t FSMC_AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers,
\r
117 valid only with asynchronous Flash memories.
\r
118 This parameter can be a value of @ref FSMC_AsynchronousWait */
\r
120 uint32_t FSMC_WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing
\r
121 the Flash memory in burst mode.
\r
122 This parameter can be a value of @ref FSMC_Wait_Signal_Polarity */
\r
124 uint32_t FSMC_WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash
\r
125 memory, valid only when accessing Flash memories in burst mode.
\r
126 This parameter can be a value of @ref FSMC_Wrap_Mode */
\r
128 uint32_t FSMC_WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one
\r
129 clock cycle before the wait state or during the wait state,
\r
130 valid only when accessing memories in burst mode.
\r
131 This parameter can be a value of @ref FSMC_Wait_Timing */
\r
133 uint32_t FSMC_WriteOperation; /*!< Enables or disables the write operation in the selected bank by the FSMC.
\r
134 This parameter can be a value of @ref FSMC_Write_Operation */
\r
136 uint32_t FSMC_WaitSignal; /*!< Enables or disables the wait-state insertion via wait
\r
137 signal, valid for Flash memory access in burst mode.
\r
138 This parameter can be a value of @ref FSMC_Wait_Signal */
\r
140 uint32_t FSMC_ExtendedMode; /*!< Enables or disables the extended mode.
\r
141 This parameter can be a value of @ref FSMC_Extended_Mode */
\r
143 uint32_t FSMC_WriteBurst; /*!< Enables or disables the write burst operation.
\r
144 This parameter can be a value of @ref FSMC_Write_Burst */
\r
146 FSMC_NORSRAMTimingInitTypeDef* FSMC_ReadWriteTimingStruct; /*!< Timing Parameters for write and read access if the ExtendedMode is not used*/
\r
148 FSMC_NORSRAMTimingInitTypeDef* FSMC_WriteTimingStruct; /*!< Timing Parameters for write access if the ExtendedMode is used*/
\r
149 }FSMC_NORSRAMInitTypeDef;
\r
151 /* Exported constants --------------------------------------------------------*/
\r
153 /** @defgroup FSMC_Exported_Constants
\r
157 /** @defgroup FSMC_NORSRAM_Bank
\r
160 #define FSMC_Bank1_NORSRAM1 ((uint32_t)0x00000000)
\r
161 #define FSMC_Bank1_NORSRAM2 ((uint32_t)0x00000002)
\r
162 #define FSMC_Bank1_NORSRAM3 ((uint32_t)0x00000004)
\r
163 #define FSMC_Bank1_NORSRAM4 ((uint32_t)0x00000006)
\r
165 #define IS_FSMC_NORSRAM_BANK(BANK) (((BANK) == FSMC_Bank1_NORSRAM1) || \
\r
166 ((BANK) == FSMC_Bank1_NORSRAM2) || \
\r
167 ((BANK) == FSMC_Bank1_NORSRAM3) || \
\r
168 ((BANK) == FSMC_Bank1_NORSRAM4))
\r
173 /** @defgroup NOR_SRAM_Controller
\r
177 /** @defgroup FSMC_Data_Address_Bus_Multiplexing
\r
181 #define FSMC_DataAddressMux_Disable ((uint32_t)0x00000000)
\r
182 #define FSMC_DataAddressMux_Enable ((uint32_t)0x00000002)
\r
183 #define IS_FSMC_MUX(MUX) (((MUX) == FSMC_DataAddressMux_Disable) || \
\r
184 ((MUX) == FSMC_DataAddressMux_Enable))
\r
190 /** @defgroup FSMC_Memory_Type
\r
194 #define FSMC_MemoryType_SRAM ((uint32_t)0x00000000)
\r
195 #define FSMC_MemoryType_PSRAM ((uint32_t)0x00000004)
\r
196 #define FSMC_MemoryType_NOR ((uint32_t)0x00000008)
\r
197 #define IS_FSMC_MEMORY(MEMORY) (((MEMORY) == FSMC_MemoryType_SRAM) || \
\r
198 ((MEMORY) == FSMC_MemoryType_PSRAM)|| \
\r
199 ((MEMORY) == FSMC_MemoryType_NOR))
\r
205 /** @defgroup FSMC_Data_Width
\r
209 #define FSMC_MemoryDataWidth_8b ((uint32_t)0x00000000)
\r
210 #define FSMC_MemoryDataWidth_16b ((uint32_t)0x00000010)
\r
211 #define IS_FSMC_MEMORY_WIDTH(WIDTH) (((WIDTH) == FSMC_MemoryDataWidth_8b) || \
\r
212 ((WIDTH) == FSMC_MemoryDataWidth_16b))
\r
218 /** @defgroup FSMC_Burst_Access_Mode
\r
222 #define FSMC_BurstAccessMode_Disable ((uint32_t)0x00000000)
\r
223 #define FSMC_BurstAccessMode_Enable ((uint32_t)0x00000100)
\r
224 #define IS_FSMC_BURSTMODE(STATE) (((STATE) == FSMC_BurstAccessMode_Disable) || \
\r
225 ((STATE) == FSMC_BurstAccessMode_Enable))
\r
230 /** @defgroup FSMC_AsynchronousWait
\r
233 #define FSMC_AsynchronousWait_Disable ((uint32_t)0x00000000)
\r
234 #define FSMC_AsynchronousWait_Enable ((uint32_t)0x00008000)
\r
235 #define IS_FSMC_ASYNWAIT(STATE) (((STATE) == FSMC_AsynchronousWait_Disable) || \
\r
236 ((STATE) == FSMC_AsynchronousWait_Enable))
\r
242 /** @defgroup FSMC_Wait_Signal_Polarity
\r
246 #define FSMC_WaitSignalPolarity_Low ((uint32_t)0x00000000)
\r
247 #define FSMC_WaitSignalPolarity_High ((uint32_t)0x00000200)
\r
248 #define IS_FSMC_WAIT_POLARITY(POLARITY) (((POLARITY) == FSMC_WaitSignalPolarity_Low) || \
\r
249 ((POLARITY) == FSMC_WaitSignalPolarity_High))
\r
255 /** @defgroup FSMC_Wrap_Mode
\r
259 #define FSMC_WrapMode_Disable ((uint32_t)0x00000000)
\r
260 #define FSMC_WrapMode_Enable ((uint32_t)0x00000400)
\r
261 #define IS_FSMC_WRAP_MODE(MODE) (((MODE) == FSMC_WrapMode_Disable) || \
\r
262 ((MODE) == FSMC_WrapMode_Enable))
\r
268 /** @defgroup FSMC_Wait_Timing
\r
272 #define FSMC_WaitSignalActive_BeforeWaitState ((uint32_t)0x00000000)
\r
273 #define FSMC_WaitSignalActive_DuringWaitState ((uint32_t)0x00000800)
\r
274 #define IS_FSMC_WAIT_SIGNAL_ACTIVE(ACTIVE) (((ACTIVE) == FSMC_WaitSignalActive_BeforeWaitState) || \
\r
275 ((ACTIVE) == FSMC_WaitSignalActive_DuringWaitState))
\r
281 /** @defgroup FSMC_Write_Operation
\r
285 #define FSMC_WriteOperation_Disable ((uint32_t)0x00000000)
\r
286 #define FSMC_WriteOperation_Enable ((uint32_t)0x00001000)
\r
287 #define IS_FSMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FSMC_WriteOperation_Disable) || \
\r
288 ((OPERATION) == FSMC_WriteOperation_Enable))
\r
294 /** @defgroup FSMC_Wait_Signal
\r
298 #define FSMC_WaitSignal_Disable ((uint32_t)0x00000000)
\r
299 #define FSMC_WaitSignal_Enable ((uint32_t)0x00002000)
\r
300 #define IS_FSMC_WAITE_SIGNAL(SIGNAL) (((SIGNAL) == FSMC_WaitSignal_Disable) || \
\r
301 ((SIGNAL) == FSMC_WaitSignal_Enable))
\r
306 /** @defgroup FSMC_Extended_Mode
\r
310 #define FSMC_ExtendedMode_Disable ((uint32_t)0x00000000)
\r
311 #define FSMC_ExtendedMode_Enable ((uint32_t)0x00004000)
\r
313 #define IS_FSMC_EXTENDED_MODE(MODE) (((MODE) == FSMC_ExtendedMode_Disable) || \
\r
314 ((MODE) == FSMC_ExtendedMode_Enable))
\r
320 /** @defgroup FSMC_Write_Burst
\r
324 #define FSMC_WriteBurst_Disable ((uint32_t)0x00000000)
\r
325 #define FSMC_WriteBurst_Enable ((uint32_t)0x00080000)
\r
326 #define IS_FSMC_WRITE_BURST(BURST) (((BURST) == FSMC_WriteBurst_Disable) || \
\r
327 ((BURST) == FSMC_WriteBurst_Enable))
\r
332 /** @defgroup FSMC_Address_Setup_Time
\r
336 #define IS_FSMC_ADDRESS_SETUP_TIME(TIME) ((TIME) <= 0xF)
\r
342 /** @defgroup FSMC_Address_Hold_Time
\r
346 #define IS_FSMC_ADDRESS_HOLD_TIME(TIME) ((TIME) <= 0xF)
\r
352 /** @defgroup FSMC_Data_Setup_Time
\r
356 #define IS_FSMC_DATASETUP_TIME(TIME) (((TIME) > 0) && ((TIME) <= 0xFF))
\r
362 /** @defgroup FSMC_Bus_Turn_around_Duration
\r
366 #define IS_FSMC_TURNAROUND_TIME(TIME) ((TIME) <= 0xF)
\r
372 /** @defgroup FSMC_CLK_Division
\r
376 #define IS_FSMC_CLK_DIV(DIV) ((DIV) <= 0xF)
\r
382 /** @defgroup FSMC_Data_Latency
\r
386 #define IS_FSMC_DATA_LATENCY(LATENCY) ((LATENCY) <= 0xF)
\r
392 /** @defgroup FSMC_Access_Mode
\r
396 #define FSMC_AccessMode_A ((uint32_t)0x00000000)
\r
397 #define FSMC_AccessMode_B ((uint32_t)0x10000000)
\r
398 #define FSMC_AccessMode_C ((uint32_t)0x20000000)
\r
399 #define FSMC_AccessMode_D ((uint32_t)0x30000000)
\r
400 #define IS_FSMC_ACCESS_MODE(MODE) (((MODE) == FSMC_AccessMode_A) || \
\r
401 ((MODE) == FSMC_AccessMode_B) || \
\r
402 ((MODE) == FSMC_AccessMode_C) || \
\r
403 ((MODE) == FSMC_AccessMode_D))
\r
417 /* Exported macro ------------------------------------------------------------*/
\r
418 /* Exported functions ------------------------------------------------------- */
\r
419 /* NOR/SRAM Controller functions **********************************************/
\r
420 void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank);
\r
421 void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
\r
422 void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
\r
423 void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState);
\r
429 #endif /*__STM32L1xx_FSMC_H */
\r
438 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r