annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_ll_fsmc.c @ 75:2b3f8ed4a0b8

Update version info
author Ideenmodellierer
date Thu, 04 Oct 2018 20:41:21 +0200
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_fsmc.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 FSMC 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 Static Memory Controller (FSMC) 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 ##### FSMC peripheral features #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 [..] The Flexible static memory controller (FSMC) includes two 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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 [..] The FSMC functional block makes the interface with synchronous and asynchronous static
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 memories, SDRAM memories, and 16-bit PC memory cards. Its main purposes are:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 (+) to translate AHB transactions into the appropriate external device protocol.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 (+) to meet the access time requirements of the external memory devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 [..] All external memories share the addresses, data and control signals with the controller.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 Each external device is accessed by means of a unique Chip Select. The FSMC performs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 only one access at a time to an external device.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 The main features of the FSMC controller are the following:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 (+) Interface with static-memory mapped devices including:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 (++) Static random access memory (SRAM).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (++) Read-only memory (ROM).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 (++) NOR Flash memory/OneNAND Flash memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 (++) PSRAM (4 memory banks).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 (++) 16-bit PC Card compatible devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 (++) 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
39 data.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 (+) Independent Chip Select control for each memory bank.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 (+) Independent configuration for each memory bank.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 ******************************************************************************
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 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 /** @defgroup FSMC_LL FSMC Low Layer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 * @brief FSMC driver modules
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 #if defined (HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 /** @addtogroup FSMC_LL_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 /** @addtogroup FSMC_LL_NORSRAM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 * @brief NORSRAM Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 ##### How to use NORSRAM device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 This driver contains a set of APIs to interface with the FSMC NORSRAM banks in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 to run the NORSRAM external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 (+) FSMC NORSRAM bank reset using the function FSMC_NORSRAM_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 (+) FSMC NORSRAM bank control configuration using the function FSMC_NORSRAM_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 (+) FSMC NORSRAM bank timing configuration using the function FSMC_NORSRAM_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 (+) FSMC NORSRAM bank extended timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 FSMC_NORSRAM_Extended_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 (+) FSMC NORSRAM bank enable/disable write operation using the functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 * @{
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 /** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 ##### Initialization and de_initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 (+) Initialize and configure the FSMC NORSRAM interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 (+) De-initialize the FSMC NORSRAM interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 (+) Configure the FSMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 * @brief Initialize the FSMC_NORSRAM device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 * control parameters in the FSMC_NORSRAM_InitTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 * @param Init: Pointer to NORSRAM Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef* Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 assert_param(IS_FSMC_MUX(Init->DataAddressMux));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 assert_param(IS_FSMC_MEMORY(Init->MemoryType));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 assert_param(IS_FSMC_NORSRAM_MEMORY_WIDTH(Init->MemoryDataWidth));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 assert_param(IS_FSMC_BURSTMODE(Init->BurstAccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 assert_param(IS_FSMC_WAIT_POLARITY(Init->WaitSignalPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 assert_param(IS_FSMC_WRAP_MODE(Init->WrapMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(Init->WaitSignalActive));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 /* Get the BTCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 tmpr = Device->BTCR[Init->NSBank];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 /* Clear MBKEN, MUXEN, MTYP, MWID, FACCEN, BURSTEN, WAITPOL, WRAPMOD, WAITCFG, WREN,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 WAITEN, EXTMOD, ASYNCWAIT, CBURSTRW and CCLKEN bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 tmpr &= ((uint32_t)~(FSMC_BCR1_MBKEN | FSMC_BCR1_MUXEN | FSMC_BCR1_MTYP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 FSMC_BCR1_MWID | FSMC_BCR1_FACCEN | FSMC_BCR1_BURSTEN | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 FSMC_BCR1_WAITPOL | FSMC_BCR1_WRAPMOD | FSMC_BCR1_WAITCFG | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 FSMC_BCR1_WREN | FSMC_BCR1_WAITEN | FSMC_BCR1_EXTMOD | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 FSMC_BCR1_ASYNCWAIT | FSMC_BCR1_CBURSTRW));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 /* Set NORSRAM device control parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 tmpr |= (uint32_t)(Init->DataAddressMux |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 Init->MemoryType |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 Init->MemoryDataWidth |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 Init->BurstAccessMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 Init->WaitSignalPolarity |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 Init->WrapMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 Init->WaitSignalActive |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 Init->WriteOperation |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 Init->WaitSignal |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 Init->ExtendedMode |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 Init->AsynchronousWait |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 Init->WriteBurst
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 if(Init->MemoryType == FSMC_MEMORY_TYPE_NOR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 tmpr |= (uint32_t)FSMC_NORSRAM_FLASH_ACCESS_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 Device->BTCR[Init->NSBank] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 * @brief DeInitialize the FSMC_NORSRAM peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 * @param ExDevice: Pointer to NORSRAM extended mode device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 /* Disable the FSMC_NORSRAM device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 __FSMC_NORSRAM_DISABLE(Device, Bank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 /* De-initialize the FSMC_NORSRAM device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 /* FSMC_NORSRAM_BANK1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 if(Bank == FSMC_NORSRAM_BANK1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 Device->BTCR[Bank] = 0x000030DB;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 Device->BTCR[Bank] = 0x000030D2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 Device->BTCR[Bank + 1] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 ExDevice->BWTR[Bank] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 * @brief Initialize the FSMC_NORSRAM Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 * parameters in the FSMC_NORSRAM_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 * @param Timing: Pointer to NORSRAM Timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 /* Get the BTCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 tmpr = Device->BTCR[Bank + 1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 /* Clear ADDSET, ADDHLD, DATAST, BUSTURN, CLKDIV, DATLAT and ACCMOD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 tmpr &= ((uint32_t)~(FSMC_BTR1_ADDSET | FSMC_BTR1_ADDHLD | FSMC_BTR1_DATAST | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 FSMC_BTR1_BUSTURN | FSMC_BTR1_CLKDIV | FSMC_BTR1_DATLAT | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 FSMC_BTR1_ACCMOD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 /* Set FSMC_NORSRAM device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 tmpr |= (uint32_t)(Timing->AddressSetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 ((Timing->AddressHoldTime) << 4) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 ((Timing->DataSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 ((Timing->BusTurnAroundDuration) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 (((Timing->CLKDivision)-1) << 20) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 (((Timing->DataLatency)-2) << 24) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 (Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 Device->BTCR[Bank + 1] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 * @brief Initialize the FSMC_NORSRAM Extended mode Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 * parameters in the FSMC_NORSRAM_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 * @param Timing: Pointer to NORSRAM Timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 /* Set NORSRAM device timing register for write configuration, if extended mode is used */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 if(ExtendedMode == FSMC_EXTENDED_MODE_ENABLE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 /* Get the BWTR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 tmpr = Device->BWTR[Bank];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 /* Clear ADDSET, ADDHLD, DATAST, BUSTURN, CLKDIV, DATLAT and ACCMOD bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 tmpr &= ((uint32_t)~(FSMC_BWTR1_ADDSET | FSMC_BWTR1_ADDHLD | FSMC_BWTR1_DATAST | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 FSMC_BWTR1_BUSTURN | FSMC_BWTR1_CLKDIV | FSMC_BWTR1_DATLAT | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 FSMC_BWTR1_ACCMOD));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 tmpr |= (uint32_t)(Timing->AddressSetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 ((Timing->AddressHoldTime) << 4) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 ((Timing->DataSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 ((Timing->BusTurnAroundDuration) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 (((Timing->CLKDivision)-1) << 20) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 (((Timing->DataLatency)-2) << 24) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 (Timing->AccessMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 Device->BWTR[Bank] = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 Device->BWTR[Bank] = 0x0FFFFFFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 /** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 * @brief management functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 ##### FSMC_NORSRAM Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 This subsection provides a set of functions allowing to control dynamically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 the FSMC NORSRAM interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 * @brief Enables dynamically FSMC_NORSRAM write operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 /* Enable write operation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 Device->BTCR[Bank] |= FSMC_WRITE_OPERATION_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 return HAL_OK;
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 * @brief Disables dynamically FSMC_NORSRAM write operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 * @param Device: Pointer to NORSRAM device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 * @param Bank: NORSRAM bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 /* Disable write operation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 Device->BTCR[Bank] &= ~FSMC_WRITE_OPERATION_ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 }
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 /** @addtogroup FSMC_LL_NAND
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 * @brief NAND Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 ##### How to use NAND device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 This driver contains a set of APIs to interface with the FSMC NAND banks in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 to run the NAND external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 (+) FSMC NAND bank reset using the function FSMC_NAND_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 (+) FSMC NAND bank control configuration using the function FSMC_NAND_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 (+) FSMC NAND bank common space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 FSMC_NAND_CommonSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 (+) FSMC NAND bank attribute space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 FSMC_NAND_AttributeSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 (+) FSMC NAND bank enable/disable ECC correction feature using the functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 FSMC_NAND_ECC_Enable()/FSMC_NAND_ECC_Disable()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 (+) FSMC NAND bank get ECC correction code using the function FSMC_NAND_GetECC()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 /** @addtogroup FSMC_LL_NAND_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 ##### Initialization and de_initialization functions #####
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 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 (+) Initialize and configure the FSMC NAND interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 (+) De-initialize the FSMC NAND interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 (+) Configure the FSMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 * @brief Initializes the FSMC_NAND device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 * control parameters in the FSMC_NAND_HandleTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 * @param Init: Pointer to NAND Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 HAL_StatusTypeDef FSMC_NAND_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_InitTypeDef *Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 assert_param(IS_FSMC_NAND_BANK(Init->NandBank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 assert_param(IS_FSMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 assert_param(IS_FSMC_ECC_STATE(Init->EccComputation));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 assert_param(IS_FSMC_ECCPAGE_SIZE(Init->ECCPageSize));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 if(Init->NandBank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 /* Get the NAND bank 2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 tmpr = Device->PCR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 /* Get the NAND bank 3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 tmpr = Device->PCR3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 /* Clear PWAITEN, PBKEN, PTYP, PWID, ECCEN, TCLR, TAR and ECCPS bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 tmpr &= ((uint32_t)~(FSMC_PCR2_PWAITEN | FSMC_PCR2_PBKEN | FSMC_PCR2_PTYP | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 FSMC_PCR2_PWID | FSMC_PCR2_ECCEN | FSMC_PCR2_TCLR | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 FSMC_PCR2_TAR | FSMC_PCR2_ECCPS));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 /* Set NAND device control parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 tmpr |= (uint32_t)(Init->Waitfeature |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 FSMC_PCR_MEMORY_TYPE_NAND |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 Init->MemoryDataWidth |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 Init->EccComputation |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 Init->ECCPageSize |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 ((Init->TCLRSetupTime) << 9) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 ((Init->TARSetupTime) << 13));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 if(Init->NandBank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 /* NAND bank 2 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 Device->PCR2 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 /* NAND bank 3 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 Device->PCR3 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 * @brief Initializes the FSMC_NAND Common space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 * parameters in the FSMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 * @param Timing: Pointer to NAND timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 /* Get the NAND bank 2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 tmpr = Device->PMEM2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 /* Get the NAND bank 3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 tmpr = Device->PMEM3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 /* Clear MEMSETx, MEMWAITx, MEMHOLDx and MEMHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 tmpr &= ((uint32_t)~(FSMC_PMEM2_MEMSET2 | FSMC_PMEM2_MEMWAIT2 | FSMC_PMEM2_MEMHOLD2 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 FSMC_PMEM2_MEMHIZ2));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 /* Set FSMC_NAND device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 ((Timing->HiZSetupTime) << 24)
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 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 /* NAND bank 2 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 Device->PMEM2 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 /* NAND bank 3 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 Device->PMEM3 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 * @brief Initializes the FSMC_NAND Attribute space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 * parameters in the FSMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 * @param Timing: Pointer to NAND timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 /* Get the NAND bank 2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 tmpr = Device->PATT2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 /* Get the NAND bank 3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 tmpr = Device->PATT3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 /* Clear ATTSETx, ATTWAITx, ATTHOLDx and ATTHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 tmpr &= ((uint32_t)~(FSMC_PATT2_ATTSET2 | FSMC_PATT2_ATTWAIT2 | FSMC_PATT2_ATTHOLD2 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 FSMC_PATT2_ATTHIZ2));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 /* Set FSMC_NAND device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 ((Timing->HiZSetupTime) << 24)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 /* NAND bank 2 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 Device->PATT2 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 /* NAND bank 3 registers configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 Device->PATT3 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 * @brief DeInitializes the FSMC_NAND device
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 /* Disable the NAND Bank */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 __FSMC_NAND_DISABLE(Device, Bank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 /* De-initialize the NAND Bank */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 /* Set the FSMC_NAND_BANK2 registers to their reset values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 Device->PCR2 = 0x00000018;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 Device->SR2 = 0x00000040;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 Device->PMEM2 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 Device->PATT2 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 /* FSMC_Bank3_NAND */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 /* Set the FSMC_NAND_BANK3 registers to their reset values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 Device->PCR3 = 0x00000018;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 Device->SR3 = 0x00000040;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 Device->PMEM3 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 Device->PATT3 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 /** @addtogroup FSMC_LL_NAND_Private_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 * @brief management functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 ##### FSMC_NAND Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 This subsection provides a set of functions allowing to control dynamically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 the FSMC NAND interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 * @brief Enables dynamically FSMC_NAND ECC feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 /* Enable ECC feature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 Device->PCR2 |= FSMC_PCR2_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 Device->PCR3 |= FSMC_PCR3_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 * @brief Disables dynamically FSMC_NAND ECC feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 /* Disable ECC feature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 Device->PCR2 &= ~FSMC_PCR2_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 Device->PCR3 &= ~FSMC_PCR3_ECCEN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 * @brief Disables dynamically FSMC_NAND ECC feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 * @param Device: Pointer to NAND device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 * @param ECCval: Pointer to ECC value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 * @param Bank: NAND bank number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 * @param Timeout: Timeout wait value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 HAL_StatusTypeDef FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 uint32_t tickstart = 0;
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_FSMC_NAND_DEVICE(Device));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 assert_param(IS_FSMC_NAND_BANK(Bank));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 /* Wait until FIFO is empty */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 while(__FSMC_NAND_GET_FLAG(Device, Bank, FSMC_FLAG_FEMPT) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 return HAL_TIMEOUT;
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 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 if(Bank == FSMC_NAND_BANK2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 /* Get the ECCR2 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 *ECCval = (uint32_t)Device->ECCR2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 /* Get the ECCR3 register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 *ECCval = (uint32_t)Device->ECCR3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 */
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 * @}
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 /** @addtogroup FSMC_LL_PCCARD
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 * @brief PCCARD Controller functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 ##### How to use PCCARD device driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 This driver contains a set of APIs to interface with the FSMC PCCARD bank in order
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 to run the PCCARD/compact flash external devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 (+) FSMC PCCARD bank reset using the function FSMC_PCCARD_DeInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 (+) FSMC PCCARD bank control configuration using the function FSMC_PCCARD_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 (+) FSMC PCCARD bank common space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 FSMC_PCCARD_CommonSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 (+) FSMC PCCARD bank attribute space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 FSMC_PCCARD_AttributeSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 (+) FSMC PCCARD bank IO space timing configuration using the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 FSMC_PCCARD_IOSpace_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 /** @addtogroup FSMC_LL_PCCARD_Private_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 ##### Initialization and de_initialization functions #####
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 This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 (+) Initialize and configure the FSMC PCCARD interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 (+) De-initialize the FSMC PCCARD interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 (+) Configure the FSMC clock and associated GPIOs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 * @brief Initializes the FSMC_PCCARD device according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 * control parameters in the FSMC_PCCARD_HandleTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 * @param Init: Pointer to PCCARD Initialization structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 HAL_StatusTypeDef FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 /* Get PCCARD control register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 tmpr = Device->PCR4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 /* Clear TAR, TCLR, PWAITEN and PWID bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 tmpr &= ((uint32_t)~(FSMC_PCR4_TAR | FSMC_PCR4_TCLR | FSMC_PCR4_PWAITEN | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 FSMC_PCR4_PWID));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 /* Set FSMC_PCCARD device control parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 tmpr |= (uint32_t)(Init->Waitfeature |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 FSMC_NAND_PCC_MEM_BUS_WIDTH_16 |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 (Init->TCLRSetupTime << 9) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 (Init->TARSetupTime << 13));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 Device->PCR4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 }
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 * @brief Initializes the FSMC_PCCARD Common space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 * parameters in the FSMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 * @param Timing: Pointer to PCCARD timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 /* Get PCCARD common space timing register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 tmpr = Device->PMEM4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 /* Clear MEMSETx, MEMWAITx, MEMHOLDx and MEMHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 tmpr &= ((uint32_t)~(FSMC_PMEM4_MEMSET4 | FSMC_PMEM4_MEMWAIT4 | FSMC_PMEM4_MEMHOLD4 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 FSMC_PMEM4_MEMHIZ4));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 /* Set PCCARD timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 tmpr |= (uint32_t)((Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 (Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 Device->PMEM4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 * @brief Initializes the FSMC_PCCARD Attribute space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 * parameters in the FSMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 * @param Timing: Pointer to PCCARD timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 /* Get PCCARD timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 tmpr = Device->PATT4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 /* Clear ATTSETx, ATTWAITx, ATTHOLDx and ATTHIZx bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 tmpr &= ((uint32_t)~(FSMC_PATT4_ATTSET4 | FSMC_PATT4_ATTWAIT4 | FSMC_PATT4_ATTHOLD4 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 FSMC_PATT4_ATTHIZ4));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 /* Set PCCARD timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 Device->PATT4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 * @brief Initializes the FSMC_PCCARD IO space Timing according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 * parameters in the FSMC_NAND_PCC_TimingTypeDef
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 * @param Timing: Pointer to PCCARD timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 uint32_t tmpr = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 /* Get FSMC_PCCARD device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 tmpr = Device->PIO4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 /* Clear IOSET4, IOWAIT4, IOHOLD4 and IOHIZ4 bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 tmpr &= ((uint32_t)~(FSMC_PIO4_IOSET4 | FSMC_PIO4_IOWAIT4 | FSMC_PIO4_IOHOLD4 | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 FSMC_PIO4_IOHIZ4));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 /* Set FSMC_PCCARD device timing parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 tmpr |= (uint32_t)(Timing->SetupTime |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 ((Timing->WaitSetupTime) << 8) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 ((Timing->HoldSetupTime) << 16) |\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 ((Timing->HiZSetupTime) << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 Device->PIO4 = tmpr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 * @brief DeInitializes the FSMC_PCCARD device
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 * @param Device: Pointer to PCCARD device instance
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922 /* Disable the FSMC_PCCARD device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 __FSMC_PCCARD_DISABLE(Device);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 /* De-initialize the FSMC_PCCARD device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 Device->PCR4 = 0x00000018;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 Device->SR4 = 0x00000000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 Device->PMEM4 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 Device->PATT4 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 Device->PIO4 = 0xFCFCFCFC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 }
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 #endif /* HAL_SRAM_MODULE_ENABLED || HAL_NOR_MODULE_ENABLED || HAL_NAND_MODULE_ENABLED || HAL_PCCARD_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/