Subversion Repositories DashDisplay

Rev

Rev 61 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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