Rev 56 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 56 | Rev 61 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | * @file stm32l1xx_ll_fsmc.c |
3 | * @file stm32l1xx_ll_fsmc.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief FSMC Low Layer HAL module driver. |
5 | * @brief FSMC Low Layer HAL module driver. |
6 | * |
6 | * |
7 | * This file provides firmware functions to manage the following |
7 | * This file provides firmware functions to manage the following |
8 | * functionalities of the Flexible Static Memory Controller (FSMC) peripheral memories: |
8 | * functionalities of the Flexible Memory Controller (FSMC) peripheral memories: |
9 | * + Initialization/de-initialization functions |
9 | * + Initialization/de-initialization functions |
10 | * + Peripheral Control functions |
10 | * + Peripheral Control functions |
11 | * + Peripheral State functions |
11 | * + Peripheral State functions |
12 | * |
12 | * |
13 | @verbatim |
13 | @verbatim |
14 | ============================================================================= |
14 | ============================================================================== |
15 | ##### FSMC peripheral features ##### |
15 | ##### FSMC peripheral features ##### |
16 | ============================================================================= |
16 | ============================================================================== |
17 | [..] The Flexible static memory controller (FSMC) includes following memory controllers: |
17 | [..] The Flexible memory controller (FSMC) includes following memory controllers: |
18 | (+) The NOR/PSRAM memory controller |
18 | (+) The NOR/PSRAM memory controller |
19 | 19 | ||
20 | [..] The FSMC functional block makes the interface with synchronous and asynchronous static |
20 | [..] The FSMC functional block makes the interface with synchronous and asynchronous static |
21 | memories. Its main purposes are: |
21 | memories. Its main purposes are: |
22 | (+) to translate AHB transactions into the appropriate external device protocol. |
22 | (+) to translate AHB transactions into the appropriate external device protocol |
23 | (+) to meet the access time requirements of the external memory devices. |
23 | (+) to meet the access time requirements of the external memory devices |
24 | 24 | ||
25 | [..] All external memories share the addresses, data and control signals with the controller. |
25 | [..] All external memories share the addresses, data and control signals with the controller. |
26 | Each external device is accessed by means of a unique Chip Select. The FSMC performs |
26 | Each external device is accessed by means of a unique Chip Select. The FSMC performs |
27 | only one access at a time to an external device. |
27 | only one access at a time to an external device. |
28 | The main features of the FSMC controller are the following: |
28 | The main features of the FSMC controller are the following: |
29 | (+) Interface with static-memory mapped devices including: |
29 | (+) Interface with static-memory mapped devices including: |
30 | (++) Static random access memory (SRAM). |
30 | (++) Static random access memory (SRAM) |
31 | (++) NOR Flash memory. |
31 | (++) Read-only memory (ROM) |
- | 32 | (++) NOR Flash memory/OneNAND Flash memory |
|
32 | (++) PSRAM (4 memory banks). |
33 | (++) PSRAM (4 memory banks) |
33 | (+) Independent Chip Select control for each memory bank |
34 | (+) Independent Chip Select control for each memory bank |
34 | (+) Independent configuration for each memory bank |
35 | (+) Independent configuration for each memory bank |
35 | 36 | ||
36 | @endverbatim |
37 | @endverbatim |
37 | ****************************************************************************** |
38 | ****************************************************************************** |
38 | * @attention |
39 | * @attention |
39 | * |
40 | * |
40 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
41 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
41 | * All rights reserved.</center></h2> |
42 | * All rights reserved.</center></h2> |
42 | * |
43 | * |
43 | * This software component is licensed by ST under BSD 3-Clause license, |
44 | * This software component is licensed by ST under BSD 3-Clause license, |
44 | * the "License"; You may not use this file except in compliance with the |
45 | * the "License"; You may not use this file except in compliance with the |
45 | * License. You may obtain a copy of the License at: |
46 | * License. You may obtain a copy of the License at: |
46 | * opensource.org/licenses/BSD-3-Clause |
47 | * opensource.org/licenses/BSD-3-Clause |
47 | * |
48 | * |
48 | ****************************************************************************** |
49 | ****************************************************************************** |
49 | */ |
50 | */ |
50 | 51 | ||
51 | /* Includes ------------------------------------------------------------------*/ |
52 | /* Includes ------------------------------------------------------------------*/ |
52 | #include "stm32l1xx_hal.h" |
53 | #include "stm32l1xx_hal.h" |
53 | 54 | ||
54 | /** @addtogroup STM32L1xx_HAL_Driver |
55 | /** @addtogroup STM32L1xx_HAL_Driver |
55 | * @{ |
56 | * @{ |
56 | */ |
57 | */ |
- | 58 | #if defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_SRAM_MODULE_ENABLED) |
|
57 | 59 | ||
58 | #if defined(FSMC_BANK1) |
- | |
59 | - | ||
60 | #if defined(HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) |
- | |
61 | - | ||
62 | /** @defgroup FSMC_LL FSMC Low Layer |
60 | /** @defgroup FSMC_LL FSMC Low Layer |
63 | * @brief FSMC driver modules |
61 | * @brief FSMC driver modules |
64 | * @{ |
62 | * @{ |
65 | */ |
63 | */ |
66 | 64 | ||
67 | /* Private typedef -----------------------------------------------------------*/ |
65 | /* Private typedef -----------------------------------------------------------*/ |
68 | /* Private define ------------------------------------------------------------*/ |
66 | /* Private define ------------------------------------------------------------*/ |
- | 67 | ||
69 | /** @defgroup FSMC_LL_Private_Constants FSMC Low Layer Private Constants |
68 | /** @defgroup FSMC_LL_Private_Constants FSMC Low Layer Private Constants |
70 | * @{ |
69 | * @{ |
71 | */ |
70 | */ |
72 | 71 | ||
73 | /* ----------------------- FSMC registers bit mask --------------------------- */ |
72 | /* ----------------------- FSMC registers bit mask --------------------------- */ |
- | 73 | ||
- | 74 | #if defined(FSMC_BANK1) |
|
74 | /* --- BCR Register ---*/ |
75 | /* --- BCR Register ---*/ |
75 | /* BCR register clear mask */ |
76 | /* BCR register clear mask */ |
76 | #define BCR_CLEAR_MASK ((uint32_t)(FSMC_BCRx_FACCEN | FSMC_BCRx_MUXEN | \ |
- | |
77 | FSMC_BCRx_MTYP | FSMC_BCRx_MWID | \ |
- | |
78 | FSMC_BCRx_BURSTEN | FSMC_BCRx_WAITPOL | \ |
- | |
79 | FSMC_BCRx_WRAPMOD | FSMC_BCRx_WAITCFG | \ |
- | |
80 | FSMC_BCRx_WREN | FSMC_BCRx_WAITEN | \ |
- | |
81 | FSMC_BCRx_EXTMOD | FSMC_BCRx_ASYNCWAIT | \ |
- | |
82 | FSMC_BCRx_CBURSTRW)) |
- | |
- | 77 | ||
83 | /* --- BTR Register ---*/ |
78 | /* --- BTR Register ---*/ |
84 | /* BTR register clear mask */ |
79 | /* BTR register clear mask */ |
85 | #define BTR_CLEAR_MASK ((uint32_t)(FSMC_BTRx_ADDSET | FSMC_BTRx_ADDHLD |\ |
80 | #define BTR_CLEAR_MASK ((uint32_t)(FSMC_BTRx_ADDSET | FSMC_BTRx_ADDHLD |\ |
86 | FSMC_BTRx_DATAST | FSMC_BTRx_BUSTURN |\ |
81 | FSMC_BTRx_DATAST | FSMC_BTRx_BUSTURN |\ |
87 | FSMC_BTRx_CLKDIV | FSMC_BTRx_DATLAT |\ |
82 | FSMC_BTRx_CLKDIV | FSMC_BTRx_DATLAT |\ |
88 | FSMC_BTRx_ACCMOD)) |
83 | FSMC_BTRx_ACCMOD)) |
89 | 84 | ||
90 | /* --- BWTR Register ---*/ |
85 | /* --- BWTR Register ---*/ |
91 | /* BWTR register clear mask */ |
86 | /* BWTR register clear mask */ |
92 | #define BWTR_CLEAR_MASK ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD | \ |
87 | #define BWTR_CLEAR_MASK ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD |\ |
93 | FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD | \ |
88 | FSMC_BWTRx_DATAST | FSMC_BWTRx_BUSTURN |\ |
94 | FSMC_BWTRx_BUSTURN)) |
89 | FSMC_BWTRx_ACCMOD)) |
- | 90 | #endif /* FSMC_BANK1 */ |
|
95 | 91 | ||
96 | /** |
92 | /** |
97 | * @} |
93 | * @} |
98 | */ |
94 | */ |
99 | 95 | ||
100 | /* Private macro -------------------------------------------------------------*/ |
96 | /* Private macro -------------------------------------------------------------*/ |
101 | /** @defgroup FSMC_LL_Private_Macros FSMC Low Layer Private Macros |
- | |
102 | * @{ |
- | |
103 | */ |
- | |
104 | - | ||
105 | /** |
- | |
106 | * @} |
- | |
107 | */ |
- | |
108 | - | ||
109 | /* Private variables ---------------------------------------------------------*/ |
97 | /* Private variables ---------------------------------------------------------*/ |
110 | /* Private function prototypes -----------------------------------------------*/ |
98 | /* Private function prototypes -----------------------------------------------*/ |
111 | /* Exported functions --------------------------------------------------------*/ |
99 | /* Exported functions --------------------------------------------------------*/ |
112 | 100 | ||
113 | /** @defgroup FSMC_LL_Exported_Functions FSMC Low Layer Exported Functions |
101 | /** @defgroup FSMC_LL_Exported_Functions FSMC Low Layer Exported Functions |
114 | * @{ |
102 | * @{ |
115 | */ |
103 | */ |
116 | 104 | ||
- | 105 | #if defined(FSMC_BANK1) |
|
- | 106 | ||
117 | /** @defgroup FSMC_NORSRAM FSMC NORSRAM Controller functions |
107 | /** @defgroup FSMC_LL_Exported_Functions_NORSRAM FSMC Low Layer NOR SRAM Exported Functions |
118 | * @brief NORSRAM Controller functions |
108 | * @brief NORSRAM Controller functions |
119 | * |
109 | * |
120 | @verbatim |
110 | @verbatim |
121 | ============================================================================== |
111 | ============================================================================== |
122 | ##### How to use NORSRAM device driver ##### |
112 | ##### How to use NORSRAM device driver ##### |
123 | ============================================================================== |
113 | ============================================================================== |
Line 132... | Line 122... | ||
132 | (+) FSMC NORSRAM bank extended timing configuration using the function |
122 | (+) FSMC NORSRAM bank extended timing configuration using the function |
133 | FSMC_NORSRAM_Extended_Timing_Init() |
123 | FSMC_NORSRAM_Extended_Timing_Init() |
134 | (+) FSMC NORSRAM bank enable/disable write operation using the functions |
124 | (+) FSMC NORSRAM bank enable/disable write operation using the functions |
135 | FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable() |
125 | FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable() |
136 | 126 | ||
137 | - | ||
138 | @endverbatim |
127 | @endverbatim |
139 | * @{ |
128 | * @{ |
140 | */ |
129 | */ |
141 | 130 | ||
142 | /** @defgroup FSMC_NORSRAM_Group1 Initialization/de-initialization functions |
131 | /** @defgroup FSMC_LL_NORSRAM_Exported_Functions_Group1 Initialization and de-initialization functions |
143 | * @brief Initialization and Configuration functions |
132 | * @brief Initialization and Configuration functions |
144 | * |
133 | * |
145 | @verbatim |
134 | @verbatim |
146 | ============================================================================== |
135 | ============================================================================== |
147 | ##### Initialization and de_initialization functions ##### |
136 | ##### Initialization and de_initialization functions ##### |
Line 161... | Line 150... | ||
161 | * control parameters in the FSMC_NORSRAM_InitTypeDef |
150 | * control parameters in the FSMC_NORSRAM_InitTypeDef |
162 | * @param Device Pointer to NORSRAM device instance |
151 | * @param Device Pointer to NORSRAM device instance |
163 | * @param Init Pointer to NORSRAM Initialization structure |
152 | * @param Init Pointer to NORSRAM Initialization structure |
164 | * @retval HAL status |
153 | * @retval HAL status |
165 | */ |
154 | */ |
166 | HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef *Init) |
155 | HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, |
- | 156 | FSMC_NORSRAM_InitTypeDef *Init) |
|
167 | { |
157 | { |
- | 158 | uint32_t flashaccess; |
|
- | 159 | uint32_t btcr_reg; |
|
- | 160 | uint32_t mask; |
|
- | 161 | ||
168 | /* Check the parameters */ |
162 | /* Check the parameters */ |
169 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
163 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
170 | assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank)); |
164 | assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank)); |
171 | assert_param(IS_FSMC_MUX(Init->DataAddressMux)); |
165 | assert_param(IS_FSMC_MUX(Init->DataAddressMux)); |
172 | assert_param(IS_FSMC_MEMORY(Init->MemoryType)); |
166 | assert_param(IS_FSMC_MEMORY(Init->MemoryType)); |
Line 178... | Line 172... | ||
178 | assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation)); |
172 | assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation)); |
179 | assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal)); |
173 | assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal)); |
180 | assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode)); |
174 | assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode)); |
181 | assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait)); |
175 | assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait)); |
182 | assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst)); |
176 | assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst)); |
- | 177 | assert_param(IS_FSMC_PAGESIZE(Init->PageSize)); |
|
183 | 178 | ||
184 | /* Disable NORSRAM Device */ |
179 | /* Disable NORSRAM Device */ |
185 | __FSMC_NORSRAM_DISABLE(Device, Init->NSBank); |
180 | __FSMC_NORSRAM_DISABLE(Device, Init->NSBank); |
186 | 181 | ||
187 | /* Set NORSRAM device control parameters */ |
182 | /* Set NORSRAM device control parameters */ |
188 | if (Init->MemoryType == FSMC_MEMORY_TYPE_NOR) |
183 | if (Init->MemoryType == FSMC_MEMORY_TYPE_NOR) |
189 | { |
184 | { |
190 | MODIFY_REG(Device->BTCR[Init->NSBank], BCR_CLEAR_MASK, (uint32_t)(FSMC_NORSRAM_FLASH_ACCESS_ENABLE |
185 | flashaccess = FSMC_NORSRAM_FLASH_ACCESS_ENABLE; |
191 | | Init->DataAddressMux |
- | |
192 | | Init->MemoryType |
- | |
193 | | Init->MemoryDataWidth |
- | |
194 | | Init->BurstAccessMode |
- | |
195 | | Init->WaitSignalPolarity |
- | |
196 | | Init->WrapMode |
- | |
197 | | Init->WaitSignalActive |
- | |
198 | | Init->WriteOperation |
- | |
199 | | Init->WaitSignal |
- | |
200 | | Init->ExtendedMode |
- | |
201 | | Init->AsynchronousWait |
- | |
202 | | Init->WriteBurst |
- | |
203 | ) |
- | |
204 | ); |
- | |
205 | } |
186 | } |
206 | else |
187 | else |
207 | { |
188 | { |
208 | MODIFY_REG(Device->BTCR[Init->NSBank], BCR_CLEAR_MASK, (uint32_t)(FSMC_NORSRAM_FLASH_ACCESS_DISABLE |
189 | flashaccess = FSMC_NORSRAM_FLASH_ACCESS_DISABLE; |
209 | | Init->DataAddressMux |
- | |
210 | | Init->MemoryType |
- | |
211 | | Init->MemoryDataWidth |
- | |
212 | | Init->BurstAccessMode |
- | |
213 | | Init->WaitSignalPolarity |
- | |
214 | | Init->WrapMode |
- | |
215 | | Init->WaitSignalActive |
- | |
216 | | Init->WriteOperation |
- | |
217 | | Init->WaitSignal |
- | |
218 | | Init->ExtendedMode |
- | |
219 | | Init->AsynchronousWait |
- | |
220 | | Init->WriteBurst |
- | |
221 | ) |
- | |
222 | ); |
- | |
223 | } |
190 | } |
224 | 191 | ||
- | 192 | btcr_reg = (flashaccess | \ |
|
- | 193 | Init->DataAddressMux | \ |
|
- | 194 | Init->MemoryType | \ |
|
- | 195 | Init->MemoryDataWidth | \ |
|
- | 196 | Init->BurstAccessMode | \ |
|
- | 197 | Init->WaitSignalPolarity | \ |
|
- | 198 | Init->WaitSignalActive | \ |
|
- | 199 | Init->WriteOperation | \ |
|
- | 200 | Init->WaitSignal | \ |
|
- | 201 | Init->ExtendedMode | \ |
|
- | 202 | Init->AsynchronousWait | \ |
|
- | 203 | Init->WriteBurst); |
|
- | 204 | ||
- | 205 | btcr_reg |= Init->WrapMode; |
|
- | 206 | btcr_reg |= Init->PageSize; |
|
- | 207 | ||
- | 208 | mask = (FSMC_BCRx_MBKEN | |
|
- | 209 | FSMC_BCRx_MUXEN | |
|
- | 210 | FSMC_BCRx_MTYP | |
|
- | 211 | FSMC_BCRx_MWID | |
|
- | 212 | FSMC_BCRx_FACCEN | |
|
- | 213 | FSMC_BCRx_BURSTEN | |
|
- | 214 | FSMC_BCRx_WAITPOL | |
|
- | 215 | FSMC_BCRx_WAITCFG | |
|
- | 216 | FSMC_BCRx_WREN | |
|
- | 217 | FSMC_BCRx_WAITEN | |
|
- | 218 | FSMC_BCRx_EXTMOD | |
|
- | 219 | FSMC_BCRx_ASYNCWAIT | |
|
- | 220 | FSMC_BCRx_CBURSTRW); |
|
- | 221 | ||
- | 222 | mask |= FSMC_BCRx_WRAPMOD; |
|
- | 223 | mask |= FSMC_BCRx_CPSIZE; |
|
- | 224 | ||
- | 225 | MODIFY_REG(Device->BTCR[Init->NSBank], mask, btcr_reg); |
|
- | 226 | ||
- | 227 | ||
225 | return HAL_OK; |
228 | return HAL_OK; |
226 | } |
229 | } |
227 | 230 | ||
228 | - | ||
229 | /** |
231 | /** |
230 | * @brief DeInitialize the FSMC_NORSRAM peripheral |
232 | * @brief DeInitialize the FSMC_NORSRAM peripheral |
231 | * @param Device Pointer to NORSRAM device instance |
233 | * @param Device Pointer to NORSRAM device instance |
232 | * @param ExDevice Pointer to NORSRAM extended mode device instance |
234 | * @param ExDevice Pointer to NORSRAM extended mode device instance |
233 | * @param Bank NORSRAM bank number |
235 | * @param Bank NORSRAM bank number |
234 | * @retval HAL status |
236 | * @retval HAL status |
235 | */ |
237 | */ |
236 | HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank) |
238 | HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, |
- | 239 | FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank) |
|
237 | { |
240 | { |
238 | /* Check the parameters */ |
241 | /* Check the parameters */ |
239 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
242 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
240 | assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice)); |
243 | assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice)); |
241 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
244 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
Line 245... | Line 248... | ||
245 | 248 | ||
246 | /* De-initialize the FSMC_NORSRAM device */ |
249 | /* De-initialize the FSMC_NORSRAM device */ |
247 | /* FSMC_NORSRAM_BANK1 */ |
250 | /* FSMC_NORSRAM_BANK1 */ |
248 | if (Bank == FSMC_NORSRAM_BANK1) |
251 | if (Bank == FSMC_NORSRAM_BANK1) |
249 | { |
252 | { |
250 | Device->BTCR[Bank] = 0x000030DB; |
253 | Device->BTCR[Bank] = 0x000030DBU; |
251 | } |
254 | } |
252 | /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */ |
255 | /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */ |
253 | else |
256 | else |
254 | { |
257 | { |
255 | Device->BTCR[Bank] = 0x000030D2; |
258 | Device->BTCR[Bank] = 0x000030D2U; |
256 | } |
259 | } |
257 | 260 | ||
258 | Device->BTCR[Bank + 1] = 0x0FFFFFFF; |
261 | Device->BTCR[Bank + 1U] = 0x0FFFFFFFU; |
259 | ExDevice->BWTR[Bank] = 0x0FFFFFFF; |
262 | ExDevice->BWTR[Bank] = 0x0FFFFFFFU; |
260 | 263 | ||
261 | return HAL_OK; |
264 | return HAL_OK; |
262 | } |
265 | } |
263 | 266 | ||
264 | - | ||
265 | /** |
267 | /** |
266 | * @brief Initialize the FSMC_NORSRAM Timing according to the specified |
268 | * @brief Initialize the FSMC_NORSRAM Timing according to the specified |
267 | * parameters in the FSMC_NORSRAM_TimingTypeDef |
269 | * parameters in the FSMC_NORSRAM_TimingTypeDef |
268 | * @param Device Pointer to NORSRAM device instance |
270 | * @param Device Pointer to NORSRAM device instance |
269 | * @param Timing Pointer to NORSRAM Timing structure |
271 | * @param Timing Pointer to NORSRAM Timing structure |
270 | * @param Bank NORSRAM bank number |
272 | * @param Bank NORSRAM bank number |
271 | * @retval HAL status |
273 | * @retval HAL status |
272 | */ |
274 | */ |
273 | HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank) |
275 | HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, |
- | 276 | FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank) |
|
274 | { |
277 | { |
- | 278 | ||
275 | /* Check the parameters */ |
279 | /* Check the parameters */ |
276 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
280 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
277 | assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime)); |
281 | assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime)); |
278 | assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime)); |
282 | assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime)); |
279 | assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime)); |
283 | assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime)); |
Line 282... | Line 286... | ||
282 | assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency)); |
286 | assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency)); |
283 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
287 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
284 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
288 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
285 | 289 | ||
286 | /* Set FSMC_NORSRAM device timing parameters */ |
290 | /* Set FSMC_NORSRAM device timing parameters */ |
287 | MODIFY_REG(Device->BTCR[Bank + 1], \ |
291 | MODIFY_REG(Device->BTCR[Bank + 1U], BTR_CLEAR_MASK, (Timing->AddressSetupTime | |
288 | BTR_CLEAR_MASK, \ |
- | |
289 | (uint32_t)(Timing->AddressSetupTime | \ |
- | |
290 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BTRx_ADDHLD)) | \ |
292 | ((Timing->AddressHoldTime) << FSMC_BTRx_ADDHLD_Pos) | |
291 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BTRx_DATAST)) | \ |
293 | ((Timing->DataSetupTime) << FSMC_BTRx_DATAST_Pos) | |
292 | ((Timing->BusTurnAroundDuration) << POSITION_VAL(FSMC_BTRx_BUSTURN)) | \ |
294 | ((Timing->BusTurnAroundDuration) << FSMC_BTRx_BUSTURN_Pos) | |
293 | (((Timing->CLKDivision) - 1) << POSITION_VAL(FSMC_BTRx_CLKDIV)) | \ |
295 | (((Timing->CLKDivision) - 1U) << FSMC_BTRx_CLKDIV_Pos) | |
294 | (((Timing->DataLatency) - 2) << POSITION_VAL(FSMC_BTRx_DATLAT)) | \ |
296 | (((Timing->DataLatency) - 2U) << FSMC_BTRx_DATLAT_Pos) | |
295 | (Timing->AccessMode))); |
297 | (Timing->AccessMode))); |
296 | 298 | ||
297 | return HAL_OK; |
299 | return HAL_OK; |
298 | } |
300 | } |
299 | 301 | ||
300 | /** |
302 | /** |
Line 307... | Line 309... | ||
307 | * This parameter can be one of the following values: |
309 | * This parameter can be one of the following values: |
308 | * @arg FSMC_EXTENDED_MODE_DISABLE |
310 | * @arg FSMC_EXTENDED_MODE_DISABLE |
309 | * @arg FSMC_EXTENDED_MODE_ENABLE |
311 | * @arg FSMC_EXTENDED_MODE_ENABLE |
310 | * @retval HAL status |
312 | * @retval HAL status |
311 | */ |
313 | */ |
312 | HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode) |
314 | HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, |
- | 315 | FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, |
|
- | 316 | uint32_t ExtendedMode) |
|
313 | { |
317 | { |
314 | /* Check the parameters */ |
318 | /* Check the parameters */ |
315 | assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode)); |
319 | assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode)); |
316 | 320 | ||
317 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
321 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
Line 325... | Line 329... | ||
325 | assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration)); |
329 | assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration)); |
326 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
330 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
327 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
331 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
328 | 332 | ||
329 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
333 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
330 | MODIFY_REG(Device->BWTR[Bank], \ |
334 | MODIFY_REG(Device->BWTR[Bank], BWTR_CLEAR_MASK, (Timing->AddressSetupTime | |
331 | BWTR_CLEAR_MASK, \ |
- | |
332 | (uint32_t)(Timing->AddressSetupTime | \ |
- | |
333 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BWTRx_ADDHLD)) | \ |
335 | ((Timing->AddressHoldTime) << FSMC_BWTRx_ADDHLD_Pos) | |
334 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BWTRx_DATAST)) | \ |
336 | ((Timing->DataSetupTime) << FSMC_BWTRx_DATAST_Pos) | |
335 | Timing->AccessMode | \ |
337 | Timing->AccessMode | |
336 | ((Timing->BusTurnAroundDuration) << POSITION_VAL(FSMC_BWTRx_BUSTURN)))); |
338 | ((Timing->BusTurnAroundDuration) << FSMC_BWTRx_BUSTURN_Pos))); |
337 | } |
339 | } |
338 | else |
340 | else |
339 | { |
341 | { |
340 | Device->BWTR[Bank] = 0x0FFFFFFF; |
342 | Device->BWTR[Bank] = 0x0FFFFFFFU; |
341 | } |
343 | } |
342 | 344 | ||
343 | return HAL_OK; |
345 | return HAL_OK; |
344 | } |
346 | } |
345 | - | ||
346 | - | ||
347 | /** |
347 | /** |
348 | * @} |
348 | * @} |
349 | */ |
349 | */ |
350 | 350 | ||
351 | - | ||
352 | /** @defgroup FSMC_NORSRAM_Group2 Control functions |
351 | /** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group2 |
353 | * @brief management functions |
352 | * @brief management functions |
354 | * |
353 | * |
355 | @verbatim |
354 | @verbatim |
356 | ============================================================================== |
355 | ============================================================================== |
357 | ##### FSMC_NORSRAM Control functions ##### |
356 | ##### FSMC_NORSRAM Control functions ##### |
358 | ============================================================================== |
357 | ============================================================================== |
359 | [..] |
358 | [..] |
Line 405... | Line 404... | ||
405 | */ |
404 | */ |
406 | 405 | ||
407 | /** |
406 | /** |
408 | * @} |
407 | * @} |
409 | */ |
408 | */ |
- | 409 | #endif /* FSMC_BANK1 */ |
|
- | 410 | ||
- | 411 | ||
- | 412 | ||
- | 413 | ||
410 | /** |
414 | /** |
411 | * @} |
415 | * @} |
412 | */ |
416 | */ |
413 | 417 | ||
414 | /** |
418 | /** |
415 | * @} |
419 | * @} |
416 | */ |
420 | */ |
417 | 421 | ||
418 | #endif /* defined(HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) */ |
422 | #endif /* HAL_NOR_MODULE_ENABLED */ |
419 | 423 | /** |
|
420 | #endif /* FSMC_BANK1 */ |
424 | * @} |
421 | 425 | */ |
|
422 | /** |
426 | /** |
423 | * @} |
427 | * @} |
424 | */ |
428 | */ |
425 | 429 | ||
426 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
430 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |