annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_ll_fmc.c @ 120:6347a86caa18 FlipDisplay

Cleanup warning and disable printf calls
author Ideenmodellierer
date Tue, 08 Jan 2019 22:31:17 +0100
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_ll_fmc.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief FMC Low Layer HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * This file provides firmware functions to manage the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * functionalities of the Flexible Memory Controller (FMC) peripheral memories:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + Initialization/de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * + Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ##### FMC peripheral features #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 [..] The Flexible memory controller (FMC) includes three memory controllers:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 (+) The NOR/PSRAM memory controller
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 (+) The NAND/PC Card memory controller
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 (+) The Synchronous DRAM (SDRAM) controller
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 [..] The FMC functional block makes the interface with synchronous and asynchronous static
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 memories, SDRAM memories, and 16-bit PC memory cards. Its main purposes are:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 (+) to translate AHB transactions into the appropriate external device protocol
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 (+) to meet the access time requirements of the external memory devices
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 [..] All external memories share the addresses, data and control signals with the controller.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 Each external device is accessed by means of a unique Chip Select. The FMC performs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 only one access at a time to an external device.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 The main features of the FMC controller are the following:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 (+) Interface with static-memory mapped devices including:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (++) Static random access memory (SRAM)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 (++) Read-only memory (ROM)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 (++) NOR Flash memory/OneNAND Flash memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 (++) PSRAM (4 memory banks)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 (++) 16-bit PC Card compatible devices
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 (++) Two banks of NAND Flash memory with ECC hardware to check up to 8 Kbytes of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 (+) Interface with synchronous DRAM (SDRAM) memories
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 (+) Independent Chip Select control for each memory bank
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 (+) Independent configuration for each memory bank
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 /** @defgroup FMC_LL FMC Low Layer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 * @brief FMC driver modules
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 #if defined (HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED) || defined(HAL_SDRAM_MODULE_ENABLED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 /** @addtogroup FMC_LL_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 /** @addtogroup FMC_LL_NORSRAM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 * @brief NORSRAM Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 ##### How to use NORSRAM device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 This driver contains a set of APIs to interface with the FMC NORSRAM banks in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 to run the NORSRAM external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 (+) FMC NORSRAM bank reset using the function FMC_NORSRAM_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 (+) FMC NORSRAM bank control configuration using the function FMC_NORSRAM_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 (+) FMC NORSRAM bank timing configuration using the function FMC_NORSRAM_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 (+) FMC NORSRAM bank extended timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 FMC_NORSRAM_Extended_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 (+) FMC NORSRAM bank enable/disable write operation using the functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 FMC_NORSRAM_WriteOperation_Enable()/FMC_NORSRAM_WriteOperation_Disable()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 /** @addtogroup FMC_LL_NORSRAM_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 ##### Initialization and de_initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 (+) Initialize and configure the FMC NORSRAM interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 (+) De-initialize the FMC NORSRAM interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 (+) Configure the FMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 * @brief Initialize the FMC_NORSRAM device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 * control parameters in the FMC_NORSRAM_InitTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 * @param Init: Pointer to NORSRAM Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_InitTypeDef* Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 assert_param(IS_FMC_NORSRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 assert_param(IS_FMC_NORSRAM_BANK(Init->NSBank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 assert_param(IS_FMC_MUX(Init->DataAddressMux));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 assert_param(IS_FMC_MEMORY(Init->MemoryType));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 assert_param(IS_FMC_NORSRAM_MEMORY_WIDTH(Init->MemoryDataWidth));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 assert_param(IS_FMC_BURSTMODE(Init->BurstAccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 assert_param(IS_FMC_WAIT_POLARITY(Init->WaitSignalPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 assert_param(IS_FMC_WRAP_MODE(Init->WrapMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 assert_param(IS_FMC_WAIT_SIGNAL_ACTIVE(Init->WaitSignalActive));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 assert_param(IS_FMC_WRITE_OPERATION(Init->WriteOperation));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 assert_param(IS_FMC_WAITE_SIGNAL(Init->WaitSignal));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 assert_param(IS_FMC_EXTENDED_MODE(Init->ExtendedMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 assert_param(IS_FMC_ASYNWAIT(Init->AsynchronousWait));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 assert_param(IS_FMC_WRITE_BURST(Init->WriteBurst));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 assert_param(IS_FMC_CONTINOUS_CLOCK(Init->ContinuousClock));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 /* Get the BTCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 tmpr = Device->BTCR[Init->NSBank];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 /* Clear MBKEN, MUXEN, MTYP, MWID, FACCEN, BURSTEN, WAITPOL, WRAPMOD, WAITCFG, WREN,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 WAITEN, EXTMOD, ASYNCWAIT, CBURSTRW and CCLKEN bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 tmpr &= ((uint32_t)~(FMC_BCR1_MBKEN | FMC_BCR1_MUXEN | FMC_BCR1_MTYP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 FMC_BCR1_MWID | FMC_BCR1_FACCEN | FMC_BCR1_BURSTEN | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 FMC_BCR1_WAITPOL | FMC_BCR1_WRAPMOD | FMC_BCR1_WAITCFG | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 FMC_BCR1_WREN | FMC_BCR1_WAITEN | FMC_BCR1_EXTMOD | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 FMC_BCR1_ASYNCWAIT | FMC_BCR1_CBURSTRW | FMC_BCR1_CCLKEN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 /* Set NORSRAM device control parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 tmpr |= (uint32_t)(Init->DataAddressMux |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 Init->MemoryType |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 Init->MemoryDataWidth |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 Init->BurstAccessMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 Init->WaitSignalPolarity |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 Init->WrapMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 Init->WaitSignalActive |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 Init->WriteOperation |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 Init->WaitSignal |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 Init->ExtendedMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 Init->AsynchronousWait |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 Init->WriteBurst |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 Init->ContinuousClock);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 if(Init->MemoryType == FMC_MEMORY_TYPE_NOR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 tmpr |= (uint32_t)FMC_NORSRAM_FLASH_ACCESS_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 Device->BTCR[Init->NSBank] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 /* Configure synchronous mode when Continuous clock is enabled for bank2..4 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 if((Init->ContinuousClock == FMC_CONTINUOUS_CLOCK_SYNC_ASYNC) && (Init->NSBank != FMC_NORSRAM_BANK1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 Init->BurstAccessMode = FMC_BURST_ACCESS_MODE_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 Device->BTCR[FMC_NORSRAM_BANK1] |= (uint32_t)(Init->BurstAccessMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 Init->ContinuousClock);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 * @brief DeInitialize the FMC_NORSRAM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 * @param ExDevice: Pointer to NORSRAM extended mode device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 HAL_StatusTypeDef FMC_NORSRAM_DeInit(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 assert_param(IS_FMC_NORSRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 assert_param(IS_FMC_NORSRAM_EXTENDED_DEVICE(ExDevice));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 assert_param(IS_FMC_NORSRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 /* Disable the FMC_NORSRAM device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 __FMC_NORSRAM_DISABLE(Device, Bank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /* De-initialize the FMC_NORSRAM device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 /* FMC_NORSRAM_BANK1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 if(Bank == FMC_NORSRAM_BANK1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 Device->BTCR[Bank] = 0x000030DB;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 /* FMC_NORSRAM_BANK2, FMC_NORSRAM_BANK3 or FMC_NORSRAM_BANK4 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 Device->BTCR[Bank] = 0x000030D2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 Device->BTCR[Bank + 1] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 ExDevice->BWTR[Bank] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 * @brief Initialize the FMC_NORSRAM Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 * parameters in the FMC_NORSRAM_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 * @param Timing: Pointer to NORSRAM Timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 HAL_StatusTypeDef FMC_NORSRAM_Timing_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 assert_param(IS_FMC_NORSRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 assert_param(IS_FMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 assert_param(IS_FMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 assert_param(IS_FMC_DATASETUP_TIME(Timing->DataSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 assert_param(IS_FMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 assert_param(IS_FMC_CLK_DIV(Timing->CLKDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 assert_param(IS_FMC_DATA_LATENCY(Timing->DataLatency));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 assert_param(IS_FMC_ACCESS_MODE(Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 assert_param(IS_FMC_NORSRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 /* Get the BTCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 tmpr = Device->BTCR[Bank + 1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 /* Clear ADDSET, ADDHLD, DATAST, BUSTURN, CLKDIV, DATLAT and ACCMOD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 tmpr &= ((uint32_t)~(FMC_BTR1_ADDSET | FMC_BTR1_ADDHLD | FMC_BTR1_DATAST | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 FMC_BTR1_BUSTURN | FMC_BTR1_CLKDIV | FMC_BTR1_DATLAT | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 FMC_BTR1_ACCMOD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 /* Set FMC_NORSRAM device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 tmpr |= (uint32_t)(Timing->AddressSetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 ((Timing->AddressHoldTime) << 4) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 ((Timing->DataSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 ((Timing->BusTurnAroundDuration) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 (((Timing->CLKDivision)-1) << 20) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 (((Timing->DataLatency)-2) << 24) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 (Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 Device->BTCR[Bank + 1] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 /* Configure Clock division value (in NORSRAM bank 1) when continuous clock is enabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 if(HAL_IS_BIT_SET(Device->BTCR[FMC_NORSRAM_BANK1], FMC_BCR1_CCLKEN))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 tmpr = (uint32_t)(Device->BTCR[FMC_NORSRAM_BANK1 + 1] & ~(((uint32_t)0x0F) << 20));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 tmpr |= (uint32_t)(((Timing->CLKDivision)-1) << 20);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 Device->BTCR[FMC_NORSRAM_BANK1 + 1] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 * @brief Initialize the FMC_NORSRAM Extended mode Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 * parameters in the FMC_NORSRAM_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 * @param Timing: Pointer to NORSRAM Timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 HAL_StatusTypeDef FMC_NORSRAM_Extended_Timing_Init(FMC_NORSRAM_EXTENDED_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 assert_param(IS_FMC_EXTENDED_MODE(ExtendedMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 /* Set NORSRAM device timing register for write configuration, if extended mode is used */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 if(ExtendedMode == FMC_EXTENDED_MODE_ENABLE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 assert_param(IS_FMC_NORSRAM_EXTENDED_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 assert_param(IS_FMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 assert_param(IS_FMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 assert_param(IS_FMC_DATASETUP_TIME(Timing->DataSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 assert_param(IS_FMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 assert_param(IS_FMC_CLK_DIV(Timing->CLKDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 assert_param(IS_FMC_DATA_LATENCY(Timing->DataLatency));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 assert_param(IS_FMC_ACCESS_MODE(Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 assert_param(IS_FMC_NORSRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 /* Get the BWTR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 tmpr = Device->BWTR[Bank];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 /* Clear ADDSET, ADDHLD, DATAST, BUSTURN, CLKDIV, DATLAT and ACCMOD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 tmpr &= ((uint32_t)~(FMC_BWTR1_ADDSET | FMC_BWTR1_ADDHLD | FMC_BWTR1_DATAST | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 FMC_BWTR1_BUSTURN | FMC_BWTR1_CLKDIV | FMC_BWTR1_DATLAT | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 FMC_BWTR1_ACCMOD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 tmpr |= (uint32_t)(Timing->AddressSetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 ((Timing->AddressHoldTime) << 4) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 ((Timing->DataSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 ((Timing->BusTurnAroundDuration) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 (((Timing->CLKDivision)-1) << 20) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 (((Timing->DataLatency)-2) << 24) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 (Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 Device->BWTR[Bank] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 Device->BWTR[Bank] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 /** @addtogroup FMC_LL_NORSRAM_Private_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 * @brief management functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 ##### FMC_NORSRAM Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 This subsection provides a set of functions allowing to control dynamically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 the FMC NORSRAM interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 * @brief Enables dynamically FMC_NORSRAM write operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Enable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 assert_param(IS_FMC_NORSRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 assert_param(IS_FMC_NORSRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 /* Enable write operation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 Device->BTCR[Bank] |= FMC_WRITE_OPERATION_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 * @brief Disables dynamically FMC_NORSRAM write operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 assert_param(IS_FMC_NORSRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 assert_param(IS_FMC_NORSRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 /* Disable write operation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 Device->BTCR[Bank] &= ~FMC_WRITE_OPERATION_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 /** @addtogroup FMC_LL_NAND
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 * @brief PCCARD Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 ##### How to use NAND device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 This driver contains a set of APIs to interface with the FMC NAND banks in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 to run the NAND external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 (+) FMC NAND bank reset using the function FMC_NAND_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 (+) FMC NAND bank control configuration using the function FMC_NAND_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 (+) FMC NAND bank common space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 FMC_NAND_CommonSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 (+) FMC NAND bank attribute space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 FMC_NAND_AttributeSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 (+) FMC NAND bank enable/disable ECC correction feature using the functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 FMC_NAND_ECC_Enable()/FMC_NAND_ECC_Disable()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 (+) FMC NAND bank get ECC correction code using the function FMC_NAND_GetECC()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 /** @addtogroup FMC_LL_NAND_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 ##### Initialization and de_initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 (+) Initialize and configure the FMC NAND interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 (+) De-initialize the FMC NAND interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 (+) Configure the FMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 * @brief Initializes the FMC_NAND device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 * control parameters in the FMC_NAND_HandleTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 * @param Init: Pointer to NAND Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 HAL_StatusTypeDef FMC_NAND_Init(FMC_NAND_TypeDef *Device, FMC_NAND_InitTypeDef *Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 assert_param(IS_FMC_NAND_BANK(Init->NandBank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 assert_param(IS_FMC_WAIT_FEATURE(Init->Waitfeature));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 assert_param(IS_FMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 assert_param(IS_FMC_ECC_STATE(Init->EccComputation));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 assert_param(IS_FMC_ECCPAGE_SIZE(Init->ECCPageSize));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 assert_param(IS_FMC_TCLR_TIME(Init->TCLRSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 assert_param(IS_FMC_TAR_TIME(Init->TARSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 if(Init->NandBank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 /* Get the NAND bank 2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 tmpr = Device->PCR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 /* Get the NAND bank 3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 tmpr = Device->PCR3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 /* Clear PWAITEN, PBKEN, PTYP, PWID, ECCEN, TCLR, TAR and ECCPS bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 tmpr &= ((uint32_t)~(FMC_PCR2_PWAITEN | FMC_PCR2_PBKEN | FMC_PCR2_PTYP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 FMC_PCR2_PWID | FMC_PCR2_ECCEN | FMC_PCR2_TCLR | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 FMC_PCR2_TAR | FMC_PCR2_ECCPS));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 /* Set NAND device control parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 tmpr |= (uint32_t)(Init->Waitfeature |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 FMC_PCR_MEMORY_TYPE_NAND |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 Init->MemoryDataWidth |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 Init->EccComputation |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 Init->ECCPageSize |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 ((Init->TCLRSetupTime) << 9) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 ((Init->TARSetupTime) << 13));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 if(Init->NandBank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 /* NAND bank 2 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 Device->PCR2 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 /* NAND bank 3 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 Device->PCR3 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 * @brief Initializes the FMC_NAND Common space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 * parameters in the FMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 * @param Timing: Pointer to NAND timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 HAL_StatusTypeDef FMC_NAND_CommonSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 assert_param(IS_FMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 assert_param(IS_FMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 assert_param(IS_FMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 assert_param(IS_FMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 assert_param(IS_FMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 /* Get the NAND bank 2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 tmpr = Device->PMEM2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 /* Get the NAND bank 3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 tmpr = Device->PMEM3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 /* Clear MEMSETx, MEMWAITx, MEMHOLDx and MEMHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 tmpr &= ((uint32_t)~(FMC_PMEM2_MEMSET2 | FMC_PMEM2_MEMWAIT2 | FMC_PMEM2_MEMHOLD2 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 FMC_PMEM2_MEMHIZ2));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 /* Set FMC_NAND device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 ((Timing->HiZSetupTime) << 24)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 /* NAND bank 2 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 Device->PMEM2 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 /* NAND bank 3 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 Device->PMEM3 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 * @brief Initializes the FMC_NAND Attribute space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 * parameters in the FMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 * @param Timing: Pointer to NAND timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 HAL_StatusTypeDef FMC_NAND_AttributeSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 assert_param(IS_FMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 assert_param(IS_FMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 assert_param(IS_FMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 assert_param(IS_FMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 assert_param(IS_FMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 /* Get the NAND bank 2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 tmpr = Device->PATT2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 /* Get the NAND bank 3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 tmpr = Device->PATT3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 /* Clear ATTSETx, ATTWAITx, ATTHOLDx and ATTHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 tmpr &= ((uint32_t)~(FMC_PATT2_ATTSET2 | FMC_PATT2_ATTWAIT2 | FMC_PATT2_ATTHOLD2 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 FMC_PATT2_ATTHIZ2));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 /* Set FMC_NAND device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 /* NAND bank 2 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 Device->PATT2 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 /* NAND bank 3 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 Device->PATT3 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 * @brief DeInitializes the FMC_NAND device
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 HAL_StatusTypeDef FMC_NAND_DeInit(FMC_NAND_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 assert_param(IS_FMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 /* Disable the NAND Bank */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 __FMC_NAND_DISABLE(Device, Bank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 /* De-initialize the NAND Bank */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 /* Set the FMC_NAND_BANK2 registers to their reset values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 Device->PCR2 = 0x00000018;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 Device->SR2 = 0x00000040;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 Device->PMEM2 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 Device->PATT2 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 /* FMC_Bank3_NAND */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 /* Set the FMC_NAND_BANK3 registers to their reset values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 Device->PCR3 = 0x00000018;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 Device->SR3 = 0x00000040;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 Device->PMEM3 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 Device->PATT3 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 /** @addtogroup FMC_LL_NAND_Private_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 * @brief management functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 ##### FMC_NAND Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 This subsection provides a set of functions allowing to control dynamically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 the FMC NAND interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 * @brief Enables dynamically FMC_NAND ECC feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 HAL_StatusTypeDef FMC_NAND_ECC_Enable(FMC_NAND_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 assert_param(IS_FMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 /* Enable ECC feature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 Device->PCR2 |= FMC_PCR2_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 Device->PCR3 |= FMC_PCR3_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 * @brief Disables dynamically FMC_NAND ECC feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 HAL_StatusTypeDef FMC_NAND_ECC_Disable(FMC_NAND_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 assert_param(IS_FMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 /* Disable ECC feature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 Device->PCR2 &= ~FMC_PCR2_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 Device->PCR3 &= ~FMC_PCR3_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 * @brief Disables dynamically FMC_NAND ECC feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 * @param ECCval: Pointer to ECC value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 * @param Timeout: Timeout wait value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 HAL_StatusTypeDef FMC_NAND_GetECC(FMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 assert_param(IS_FMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 assert_param(IS_FMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 /* Wait until FIFO is empty */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 while(__FMC_NAND_GET_FLAG(Device, Bank, FMC_FLAG_FEMPT) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 if(Bank == FMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 /* Get the ECCR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 *ECCval = (uint32_t)Device->ECCR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 /* Get the ECCR3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 *ECCval = (uint32_t)Device->ECCR3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 /** @addtogroup FMC_LL_PCCARD
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 * @brief PCCARD Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 ##### How to use PCCARD device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 This driver contains a set of APIs to interface with the FMC PCCARD bank in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 to run the PCCARD/compact flash external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 (+) FMC PCCARD bank reset using the function FMC_PCCARD_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 (+) FMC PCCARD bank control configuration using the function FMC_PCCARD_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 (+) FMC PCCARD bank common space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 FMC_PCCARD_CommonSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 (+) FMC PCCARD bank attribute space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 FMC_PCCARD_AttributeSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 (+) FMC PCCARD bank IO space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 FMC_PCCARD_IOSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 /** @addtogroup FMC_LL_PCCARD_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 ##### Initialization and de_initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 (+) Initialize and configure the FMC PCCARD interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 (+) De-initialize the FMC PCCARD interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 (+) Configure the FMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 * @brief Initializes the FMC_PCCARD device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 * control parameters in the FMC_PCCARD_HandleTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 * @param Init: Pointer to PCCARD Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 HAL_StatusTypeDef FMC_PCCARD_Init(FMC_PCCARD_TypeDef *Device, FMC_PCCARD_InitTypeDef *Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 assert_param(IS_FMC_PCCARD_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 assert_param(IS_FMC_WAIT_FEATURE(Init->Waitfeature));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 assert_param(IS_FMC_TCLR_TIME(Init->TCLRSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 assert_param(IS_FMC_TAR_TIME(Init->TARSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 /* Get PCCARD control register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 tmpr = Device->PCR4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 /* Clear TAR, TCLR, PWAITEN and PWID bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 tmpr &= ((uint32_t)~(FMC_PCR4_TAR | FMC_PCR4_TCLR | FMC_PCR4_PWAITEN | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 FMC_PCR4_PWID));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 /* Set FMC_PCCARD device control parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 tmpr |= (uint32_t)(Init->Waitfeature |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857 FMC_NAND_PCC_MEM_BUS_WIDTH_16 |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 (Init->TCLRSetupTime << 9) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 (Init->TARSetupTime << 13));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 Device->PCR4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 * @brief Initializes the FMC_PCCARD Common space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 * parameters in the FMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 * @param Timing: Pointer to PCCARD timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 HAL_StatusTypeDef FMC_PCCARD_CommonSpace_Timing_Init(FMC_PCCARD_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 assert_param(IS_FMC_PCCARD_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 assert_param(IS_FMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 assert_param(IS_FMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 assert_param(IS_FMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 assert_param(IS_FMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 /* Get PCCARD common space timing register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 tmpr = Device->PMEM4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 /* Clear MEMSETx, MEMWAITx, MEMHOLDx and MEMHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 tmpr &= ((uint32_t)~(FMC_PMEM4_MEMSET4 | FMC_PMEM4_MEMWAIT4 | FMC_PMEM4_MEMHOLD4 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 FMC_PMEM4_MEMHIZ4));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 /* Set PCCARD timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 Device->PMEM4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 * @brief Initializes the FMC_PCCARD Attribute space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 * parameters in the FMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 * @param Timing: Pointer to PCCARD timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 HAL_StatusTypeDef FMC_PCCARD_AttributeSpace_Timing_Init(FMC_PCCARD_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 assert_param(IS_FMC_PCCARD_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914 assert_param(IS_FMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 assert_param(IS_FMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 assert_param(IS_FMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 assert_param(IS_FMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 /* Get PCCARD timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 tmpr = Device->PATT4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922 /* Clear ATTSETx, ATTWAITx, ATTHOLDx and ATTHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 tmpr &= ((uint32_t)~(FMC_PATT4_ATTSET4 | FMC_PATT4_ATTWAIT4 | FMC_PATT4_ATTHOLD4 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 FMC_PATT4_ATTHIZ4));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 /* Set PCCARD timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 Device->PATT4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 * @brief Initializes the FMC_PCCARD IO space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 * parameters in the FMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 * @param Timing: Pointer to PCCARD timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 HAL_StatusTypeDef FMC_PCCARD_IOSpace_Timing_Init(FMC_PCCARD_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 assert_param(IS_FMC_PCCARD_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 assert_param(IS_FMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950 assert_param(IS_FMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 assert_param(IS_FMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 assert_param(IS_FMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 /* Get FMC_PCCARD device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 tmpr = Device->PIO4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 /* Clear IOSET4, IOWAIT4, IOHOLD4 and IOHIZ4 bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 tmpr &= ((uint32_t)~(FMC_PIO4_IOSET4 | FMC_PIO4_IOWAIT4 | FMC_PIO4_IOHOLD4 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 FMC_PIO4_IOHIZ4));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 /* Set FMC_PCCARD device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 Device->PIO4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 * @brief DeInitializes the FMC_PCCARD device
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 HAL_StatusTypeDef FMC_PCCARD_DeInit(FMC_PCCARD_TypeDef *Device)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 assert_param(IS_FMC_PCCARD_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 /* Disable the FMC_PCCARD device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 __FMC_PCCARD_DISABLE(Device);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 /* De-initialize the FMC_PCCARD device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 Device->PCR4 = 0x00000018;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 Device->SR4 = 0x00000000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 Device->PMEM4 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 Device->PATT4 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 Device->PIO4 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 /** @addtogroup FMC_LL_SDRAM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 * @brief SDRAM Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 ##### How to use SDRAM device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 This driver contains a set of APIs to interface with the FMC SDRAM banks in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 to run the SDRAM external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 (+) FMC SDRAM bank reset using the function FMC_SDRAM_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 (+) FMC SDRAM bank control configuration using the function FMC_SDRAM_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 (+) FMC SDRAM bank timing configuration using the function FMC_SDRAM_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 (+) FMC SDRAM bank enable/disable write operation using the functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 FMC_SDRAM_WriteOperation_Enable()/FMC_SDRAM_WriteOperation_Disable()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 (+) FMC SDRAM bank send command using the function FMC_SDRAM_SendCommand()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 /** @addtogroup FMC_LL_SDRAM_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027 ##### Initialization and de_initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031 (+) Initialize and configure the FMC SDRAM interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 (+) De-initialize the FMC SDRAM interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033 (+) Configure the FMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040 * @brief Initializes the FMC_SDRAM device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041 * control parameters in the FMC_SDRAM_InitTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043 * @param Init: Pointer to SDRAM Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 HAL_StatusTypeDef FMC_SDRAM_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_InitTypeDef *Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048 uint32_t tmpr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 uint32_t tmpr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 assert_param(IS_FMC_SDRAM_BANK(Init->SDBank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 assert_param(IS_FMC_COLUMNBITS_NUMBER(Init->ColumnBitsNumber));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055 assert_param(IS_FMC_ROWBITS_NUMBER(Init->RowBitsNumber));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 assert_param(IS_FMC_SDMEMORY_WIDTH(Init->MemoryDataWidth));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 assert_param(IS_FMC_INTERNALBANK_NUMBER(Init->InternalBankNumber));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 assert_param(IS_FMC_CAS_LATENCY(Init->CASLatency));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 assert_param(IS_FMC_WRITE_PROTECTION(Init->WriteProtection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 assert_param(IS_FMC_SDCLOCK_PERIOD(Init->SDClockPeriod));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 assert_param(IS_FMC_READ_BURST(Init->ReadBurst));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 assert_param(IS_FMC_READPIPE_DELAY(Init->ReadPipeDelay));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 /* Set SDRAM bank configuration parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 if (Init->SDBank != FMC_SDRAM_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 tmpr1 = Device->SDCR[FMC_SDRAM_BANK1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 /* Clear NC, NR, MWID, NB, CAS, WP, SDCLK, RBURST, and RPIPE bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 tmpr1 &= ((uint32_t)~(FMC_SDCR1_NC | FMC_SDCR1_NR | FMC_SDCR1_MWID | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 FMC_SDCR1_NB | FMC_SDCR1_CAS | FMC_SDCR1_WP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072 FMC_SDCR1_SDCLK | FMC_SDCR1_RBURST | FMC_SDCR1_RPIPE));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 tmpr1 |= (uint32_t)(Init->ColumnBitsNumber |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 Init->RowBitsNumber |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 Init->MemoryDataWidth |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078 Init->InternalBankNumber |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 Init->CASLatency |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080 Init->WriteProtection |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 Init->SDClockPeriod |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 Init->ReadBurst |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 Init->ReadPipeDelay
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 Device->SDCR[FMC_SDRAM_BANK1] = tmpr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 else /* FMC_Bank2_SDRAM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 tmpr1 = Device->SDCR[FMC_SDRAM_BANK1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 /* Clear NC, NR, MWID, NB, CAS, WP, SDCLK, RBURST, and RPIPE bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 tmpr1 &= ((uint32_t)~(FMC_SDCR1_NC | FMC_SDCR1_NR | FMC_SDCR1_MWID | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 FMC_SDCR1_NB | FMC_SDCR1_CAS | FMC_SDCR1_WP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 FMC_SDCR1_SDCLK | FMC_SDCR1_RBURST | FMC_SDCR1_RPIPE));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 tmpr1 |= (uint32_t)(Init->SDClockPeriod |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 Init->ReadBurst |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 Init->ReadPipeDelay);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 tmpr2 = Device->SDCR[FMC_SDRAM_BANK2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 /* Clear NC, NR, MWID, NB, CAS, WP, SDCLK, RBURST, and RPIPE bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103 tmpr2 &= ((uint32_t)~(FMC_SDCR1_NC | FMC_SDCR1_NR | FMC_SDCR1_MWID | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 FMC_SDCR1_NB | FMC_SDCR1_CAS | FMC_SDCR1_WP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 FMC_SDCR1_SDCLK | FMC_SDCR1_RBURST | FMC_SDCR1_RPIPE));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 tmpr2 |= (uint32_t)(Init->ColumnBitsNumber |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 Init->RowBitsNumber |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 Init->MemoryDataWidth |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 Init->InternalBankNumber |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 Init->CASLatency |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112 Init->WriteProtection);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 Device->SDCR[FMC_SDRAM_BANK1] = tmpr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 Device->SDCR[FMC_SDRAM_BANK2] = tmpr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 * @brief Initializes the FMC_SDRAM device timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 * parameters in the FMC_SDRAM_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 * @param Timing: Pointer to SDRAM Timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 * @param Bank: SDRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 HAL_StatusTypeDef FMC_SDRAM_Timing_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131 uint32_t tmpr1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132 uint32_t tmpr2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136 assert_param(IS_FMC_LOADTOACTIVE_DELAY(Timing->LoadToActiveDelay));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137 assert_param(IS_FMC_EXITSELFREFRESH_DELAY(Timing->ExitSelfRefreshDelay));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138 assert_param(IS_FMC_SELFREFRESH_TIME(Timing->SelfRefreshTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139 assert_param(IS_FMC_ROWCYCLE_DELAY(Timing->RowCycleDelay));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 assert_param(IS_FMC_WRITE_RECOVERY_TIME(Timing->WriteRecoveryTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 assert_param(IS_FMC_RP_DELAY(Timing->RPDelay));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 assert_param(IS_FMC_RCD_DELAY(Timing->RCDDelay));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143 assert_param(IS_FMC_SDRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145 /* Set SDRAM device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 if (Bank != FMC_SDRAM_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 tmpr1 = Device->SDTR[FMC_SDRAM_BANK1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 /* Clear TMRD, TXSR, TRAS, TRC, TWR, TRP and TRCD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 tmpr1 &= ((uint32_t)~(FMC_SDTR1_TMRD | FMC_SDTR1_TXSR | FMC_SDTR1_TRAS | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 FMC_SDTR1_TRC | FMC_SDTR1_TWR | FMC_SDTR1_TRP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 FMC_SDTR1_TRCD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 tmpr1 |= (uint32_t)(((Timing->LoadToActiveDelay)-1) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 (((Timing->ExitSelfRefreshDelay)-1) << 4) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 (((Timing->SelfRefreshTime)-1) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158 (((Timing->RowCycleDelay)-1) << 12) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 (((Timing->WriteRecoveryTime)-1) <<16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 (((Timing->RPDelay)-1) << 20) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161 (((Timing->RCDDelay)-1) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 Device->SDTR[FMC_SDRAM_BANK1] = tmpr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 else /* FMC_Bank2_SDRAM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 tmpr1 = Device->SDTR[FMC_SDRAM_BANK2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 /* Clear TMRD, TXSR, TRAS, TRC, TWR, TRP and TRCD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169 tmpr1 &= ((uint32_t)~(FMC_SDTR1_TMRD | FMC_SDTR1_TXSR | FMC_SDTR1_TRAS | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 FMC_SDTR1_TRC | FMC_SDTR1_TWR | FMC_SDTR1_TRP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171 FMC_SDTR1_TRCD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 tmpr1 |= (uint32_t)(((Timing->LoadToActiveDelay)-1) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174 (((Timing->ExitSelfRefreshDelay)-1) << 4) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175 (((Timing->SelfRefreshTime)-1) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 (((Timing->WriteRecoveryTime)-1) <<16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177 (((Timing->RCDDelay)-1) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 tmpr2 = Device->SDTR[FMC_SDRAM_BANK1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 /* Clear TMRD, TXSR, TRAS, TRC, TWR, TRP and TRCD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 tmpr2 &= ((uint32_t)~(FMC_SDTR1_TMRD | FMC_SDTR1_TXSR | FMC_SDTR1_TRAS | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 FMC_SDTR1_TRC | FMC_SDTR1_TWR | FMC_SDTR1_TRP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 FMC_SDTR1_TRCD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 tmpr2 |= (uint32_t)((((Timing->RowCycleDelay)-1) << 12) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 (((Timing->RPDelay)-1) << 20));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188 Device->SDTR[FMC_SDRAM_BANK2] = tmpr1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 Device->SDTR[FMC_SDRAM_BANK1] = tmpr2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1196 * @brief DeInitializes the FMC_SDRAM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1199 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1200 HAL_StatusTypeDef FMC_SDRAM_DeInit(FMC_SDRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1201 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1202 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1203 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1204 assert_param(IS_FMC_SDRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1206 /* De-initialize the SDRAM device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1207 Device->SDCR[Bank] = 0x000002D0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1208 Device->SDTR[Bank] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1209 Device->SDCMR = 0x00000000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1210 Device->SDRTR = 0x00000000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1211 Device->SDSR = 0x00000000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1213 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1214 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1216 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1217 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1218 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1219
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1220 /** @addtogroup FMC_LL_SDRAMPrivate_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1221 * @brief management functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1222 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1223 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1224 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1225 ##### FMC_SDRAM Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1226 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1227 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1228 This subsection provides a set of functions allowing to control dynamically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1229 the FMC SDRAM interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1231 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1232 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1233 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1234 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1235 * @brief Enables dynamically FMC_SDRAM write protection.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1236 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1237 * @param Bank: SDRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1238 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1239 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1240 HAL_StatusTypeDef FMC_SDRAM_WriteProtection_Enable(FMC_SDRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1241 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1242 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1243 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1244 assert_param(IS_FMC_SDRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1245
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1246 /* Enable write protection */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1247 Device->SDCR[Bank] |= FMC_SDRAM_WRITE_PROTECTION_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1248
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1249 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1250 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1252 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1253 * @brief Disables dynamically FMC_SDRAM write protection.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1254 * @param hsdram: FMC_SDRAM handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1255 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1256 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1257 HAL_StatusTypeDef FMC_SDRAM_WriteProtection_Disable(FMC_SDRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1258 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1259 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1260 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1261 assert_param(IS_FMC_SDRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1262
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1263 /* Disable write protection */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1264 Device->SDCR[Bank] &= ~FMC_SDRAM_WRITE_PROTECTION_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1265
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1266 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1267 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1268
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1269 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1270 * @brief Send Command to the FMC SDRAM bank
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1271 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1272 * @param Command: Pointer to SDRAM command structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1273 * @param Timing: Pointer to SDRAM Timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1274 * @param Timeout: Timeout wait value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1275 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1276 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1277 HAL_StatusTypeDef FMC_SDRAM_SendCommand(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_CommandTypeDef *Command, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1279 __IO uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1280 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1282 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1283 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1284 assert_param(IS_FMC_COMMAND_MODE(Command->CommandMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1285 assert_param(IS_FMC_COMMAND_TARGET(Command->CommandTarget));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1286 assert_param(IS_FMC_AUTOREFRESH_NUMBER(Command->AutoRefreshNumber));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1287 assert_param(IS_FMC_MODE_REGISTER(Command->ModeRegisterDefinition));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1288
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1289 /* Set command register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1290 tmpr = (uint32_t)((Command->CommandMode) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1291 (Command->CommandTarget) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1292 (((Command->AutoRefreshNumber)-1) << 5) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1293 ((Command->ModeRegisterDefinition) << 9)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1294 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1295
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1296 Device->SDCMR = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1297
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1298 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1299 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1300
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1301 /* wait until command is send */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1302 while(HAL_IS_BIT_SET(Device->SDSR, FMC_SDSR_BUSY))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1303 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1304 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1305 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1306 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1307 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1308 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1309 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1310 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1313 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1314 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1315
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1316 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1317 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1318
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1319 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1320 * @brief Program the SDRAM Memory Refresh rate.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1321 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1322 * @param RefreshRate: The SDRAM refresh rate value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1323 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1324 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1325 HAL_StatusTypeDef FMC_SDRAM_ProgramRefreshRate(FMC_SDRAM_TypeDef *Device, uint32_t RefreshRate)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1326 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1327 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1328 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1329 assert_param(IS_FMC_REFRESH_RATE(RefreshRate));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1330
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1331 /* Set the refresh rate in command register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1332 Device->SDRTR |= (RefreshRate<<1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1333
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1334 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1335 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1336
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1337 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1338 * @brief Set the Number of consecutive SDRAM Memory auto Refresh commands.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1339 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1340 * @param AutoRefreshNumber: Specifies the auto Refresh number.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1341 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1342 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1343 HAL_StatusTypeDef FMC_SDRAM_SetAutoRefreshNumber(FMC_SDRAM_TypeDef *Device, uint32_t AutoRefreshNumber)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1344 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1345 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1346 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1347 assert_param(IS_FMC_AUTOREFRESH_NUMBER(AutoRefreshNumber));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1349 /* Set the Auto-refresh number in command register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1350 Device->SDCMR |= (AutoRefreshNumber << 5);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1351
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1352 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1354
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1355 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1356 * @brief Returns the indicated FMC SDRAM bank mode status.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1357 * @param Device: Pointer to SDRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1358 * @param Bank: Defines the FMC SDRAM bank. This parameter can be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1359 * FMC_Bank1_SDRAM or FMC_Bank2_SDRAM.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1360 * @retval The FMC SDRAM bank mode status, could be on of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1361 * FMC_SDRAM_NORMAL_MODE, FMC_SDRAM_SELF_REFRESH_MODE or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1362 * FMC_SDRAM_POWER_DOWN_MODE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1363 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1364 uint32_t FMC_SDRAM_GetModeStatus(FMC_SDRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1365 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1366 uint32_t tmpreg = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1368 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1369 assert_param(IS_FMC_SDRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1370 assert_param(IS_FMC_SDRAM_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1371
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1372 /* Get the corresponding bank mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1373 if(Bank == FMC_SDRAM_BANK1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1374 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1375 tmpreg = (uint32_t)(Device->SDSR & FMC_SDSR_MODES1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1376 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1377 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1378 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1379 tmpreg = ((uint32_t)(Device->SDSR & FMC_SDSR_MODES2) >> 2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1380 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1381
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1382 /* Return the mode status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1383 return tmpreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1384 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1385
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1386 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1387 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1388 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1389
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1390 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1391 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1392 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1394 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1395 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1396 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1397 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1398 #endif /* HAL_SRAM_MODULE_ENABLED || HAL_NOR_MODULE_ENABLED || HAL_NAND_MODULE_ENABLED || HAL_PCCARD_MODULE_ENABLED || HAL_SDRAM_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1399
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1400 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1401 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1402 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1403
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1404 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1405 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1406 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1407
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1408 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/