annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_sram.c @ 56:bab006305b58

language updates
author heinrichsweikamp
date Tue, 07 Aug 2018 17:03:36 +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_hal_sram.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 SRAM HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This file provides a generic firmware to drive SRAM memories
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * mounted as external device.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 This driver is a generic layered driver which contains a set of APIs used to
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 control SRAM memories. It uses the FMC layer functions to interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 with SRAM devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 The following sequence should be followed to configure the FMC/FSMC to interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 with SRAM/PSRAM memories:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 (#) Declare a SRAM_HandleTypeDef handle structure, for example:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 SRAM_HandleTypeDef hsram; and:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 (++) Fill the SRAM_HandleTypeDef handle "Init" field with the allowed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 values of the structure member.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 (++) Fill the SRAM_HandleTypeDef handle "Instance" field with a predefined
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 base register instance for NOR or SRAM device
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 (++) Fill the SRAM_HandleTypeDef handle "Extended" field with a predefined
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 base register instance for NOR or SRAM extended mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (#) Declare two FMC_NORSRAM_TimingTypeDef structures, for both normal and extended
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 mode timings; for example:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 FMC_NORSRAM_TimingTypeDef Timing and FMC_NORSRAM_TimingTypeDef ExTiming;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 and fill its fields with the allowed values of the structure member.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 (#) Initialize the SRAM Controller by calling the function HAL_SRAM_Init(). This function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 performs the following sequence:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 (##) MSP hardware layer configuration using the function HAL_SRAM_MspInit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 (##) Control register configuration using the FMC NORSRAM interface function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 FMC_NORSRAM_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 (##) Timing register configuration using the FMC NORSRAM interface function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 FMC_NORSRAM_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 (##) Extended mode Timing register configuration using the FMC NORSRAM interface function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 FMC_NORSRAM_Extended_Timing_Init()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 (##) Enable the SRAM device using the macro __FMC_NORSRAM_ENABLE()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 (#) At this stage you can perform read/write accesses from/to the memory connected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 to the NOR/SRAM Bank. You can perform either polling or DMA transfer using the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 following APIs:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 (++) HAL_SRAM_Read()/HAL_SRAM_Write() for polling read/write access
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 (++) HAL_SRAM_Read_DMA()/HAL_SRAM_Write_DMA() for DMA read/write transfer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 (#) You can also control the SRAM device by calling the control APIs HAL_SRAM_WriteOperation_Enable()/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 HAL_SRAM_WriteOperation_Disable() to respectively enable/disable the SRAM write operation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 (#) You can continuously monitor the SRAM device HAL state by calling the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 HAL_SRAM_GetState()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 /** @defgroup SRAM SRAM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 * @brief SRAM driver modules
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 #ifdef HAL_SRAM_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 /** @defgroup SRAM_Exported_Functions SRAM Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 /** @defgroup SRAM_Exported_Functions_Group1 Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 ##### SRAM Initialization and de_initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 [..] This section provides functions allowing to initialize/de-initialize
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 the SRAM memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 * @brief Performs the SRAM device initialization sequence
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 * @param Timing: Pointer to SRAM control timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 * @param ExtTiming: Pointer to SRAM extended mode timing structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 /* Check the SRAM handle parameter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 if(hsram == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 if(hsram->State == HAL_SRAM_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 /* Initialize the low level hardware (MSP) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 HAL_SRAM_MspInit(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 /* Initialize SRAM control Interface */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 FMC_NORSRAM_Init(hsram->Instance, &(hsram->Init));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 /* Initialize SRAM timing Interface */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 FMC_NORSRAM_Timing_Init(hsram->Instance, Timing, hsram->Init.NSBank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 /* Initialize SRAM extended mode timing Interface */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 FMC_NORSRAM_Extended_Timing_Init(hsram->Extended, ExtTiming, hsram->Init.NSBank, hsram->Init.ExtendedMode);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 /* Enable the NORSRAM device */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 __FMC_NORSRAM_ENABLE(hsram->Instance, hsram->Init.NSBank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 * @brief Performs the SRAM device De-initialization sequence.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 /* De-Initialize the low level hardware (MSP) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 HAL_SRAM_MspDeInit(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 /* Configure the SRAM registers with their reset values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 FMC_NORSRAM_DeInit(hsram->Instance, hsram->Extended, hsram->Init.NSBank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 hsram->State = HAL_SRAM_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 * @brief SRAM MSP Init.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 __weak void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 the HAL_SRAM_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 * @brief SRAM MSP DeInit.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 __weak void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 the HAL_SRAM_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 * @brief DMA transfer complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 * @param hdma: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 __weak void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 the HAL_SRAM_DMA_XferCpltCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 * @brief DMA transfer complete error callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 * @param hdma: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 __weak void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 the HAL_SRAM_DMA_XferErrorCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 /** @defgroup SRAM_Exported_Functions_Group2 Input and Output functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 * @brief Input Output and memory control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 ##### SRAM Input and Output functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 This section provides functions allowing to use and control the SRAM memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 * @brief Reads 8-bit buffer from SRAM memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 * @param pAddress: Pointer to read start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 * @param pDstBuffer: Pointer to destination buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 * @param BufferSize: Size of the buffer to read from memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 __IO uint8_t * pSramAddress = (uint8_t *)pAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 /* Read data from memory */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 for(; BufferSize != 0; BufferSize--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 *pDstBuffer = *(__IO uint8_t *)pSramAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 pDstBuffer++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 pSramAddress++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 * @brief Writes 8-bit buffer to SRAM memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 * @param pAddress: Pointer to write start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 * @param pSrcBuffer: Pointer to source buffer to write
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 * @param BufferSize: Size of the buffer to write to memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 HAL_StatusTypeDef HAL_SRAM_Write_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pSrcBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 __IO uint8_t * pSramAddress = (uint8_t *)pAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 /* Check the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 if(hsram->State == HAL_SRAM_STATE_PROTECTED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 /* Write data to memory */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 for(; BufferSize != 0; BufferSize--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 *(__IO uint8_t *)pSramAddress = *pSrcBuffer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 pSrcBuffer++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 pSramAddress++;
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 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 * @brief Reads 16-bit buffer from SRAM memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 * @param pAddress: Pointer to read start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 * @param pDstBuffer: Pointer to destination buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 * @param BufferSize: Size of the buffer to read from memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 HAL_StatusTypeDef HAL_SRAM_Read_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pDstBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 __IO uint16_t * pSramAddress = (uint16_t *)pAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 /* Read data from memory */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 for(; BufferSize != 0; BufferSize--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 *pDstBuffer = *(__IO uint16_t *)pSramAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 pDstBuffer++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 pSramAddress++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 return HAL_OK;
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 * @brief Writes 16-bit buffer to SRAM memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 * @param pAddress: Pointer to write start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 * @param pSrcBuffer: Pointer to source buffer to write
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 * @param BufferSize: Size of the buffer to write to memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 HAL_StatusTypeDef HAL_SRAM_Write_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pSrcBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 __IO uint16_t * pSramAddress = (uint16_t *)pAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 /* Check the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 if(hsram->State == HAL_SRAM_STATE_PROTECTED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 /* Write data to memory */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 for(; BufferSize != 0; BufferSize--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 *(__IO uint16_t *)pSramAddress = *pSrcBuffer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 pSrcBuffer++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 pSramAddress++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 * @brief Reads 32-bit buffer from SRAM memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 * @param pAddress: Pointer to read start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 * @param pDstBuffer: Pointer to destination buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 * @param BufferSize: Size of the buffer to read from memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 HAL_StatusTypeDef HAL_SRAM_Read_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 /* Read data from memory */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 for(; BufferSize != 0; BufferSize--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 *pDstBuffer = *(__IO uint32_t *)pAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 pDstBuffer++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 pAddress++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 * @brief Writes 32-bit buffer to SRAM memory.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 * @param pAddress: Pointer to write start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 * @param pSrcBuffer: Pointer to source buffer to write
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 * @param BufferSize: Size of the buffer to write to memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 /* Check the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 if(hsram->State == HAL_SRAM_STATE_PROTECTED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 /* Write data to memory */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 for(; BufferSize != 0; BufferSize--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 *(__IO uint32_t *)pAddress = *pSrcBuffer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 pSrcBuffer++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 pAddress++;
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 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 * @brief Reads a Words data from the SRAM memory using DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 * @param pAddress: Pointer to read start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 * @param pDstBuffer: Pointer to destination buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 * @param BufferSize: Size of the buffer to read from memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 /* Configure DMA user callbacks */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 hsram->hdma->XferCpltCallback = HAL_SRAM_DMA_XferCpltCallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 hsram->hdma->XferErrorCallback = HAL_SRAM_DMA_XferErrorCallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 HAL_DMA_Start_IT(hsram->hdma, (uint32_t)pAddress, (uint32_t)pDstBuffer, (uint32_t)BufferSize);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 * @brief Writes a Words data buffer to SRAM memory using DMA transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 * @param pAddress: Pointer to write start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 * @param pSrcBuffer: Pointer to source buffer to write
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 * @param BufferSize: Size of the buffer to write to memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 /* Check the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 if(hsram->State == HAL_SRAM_STATE_PROTECTED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 /* Configure DMA user callbacks */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 hsram->hdma->XferCpltCallback = HAL_SRAM_DMA_XferCpltCallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 hsram->hdma->XferErrorCallback = HAL_SRAM_DMA_XferErrorCallback;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 HAL_DMA_Start_IT(hsram->hdma, (uint32_t)pSrcBuffer, (uint32_t)pAddress, (uint32_t)BufferSize);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 }
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 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 /** @defgroup SRAM_Exported_Functions_Group3 Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 * @brief management functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 ##### SRAM Control functions #####
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 This subsection provides a set of functions allowing to control dynamically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 the SRAM interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 * @brief Enables dynamically SRAM write operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 /* Enable write operation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 FMC_NORSRAM_WriteOperation_Enable(hsram->Instance, hsram->Init.NSBank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 hsram->State = HAL_SRAM_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 * @brief Disables dynamically SRAM write operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 __HAL_LOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 hsram->State = HAL_SRAM_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 /* Disable write operation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 FMC_NORSRAM_WriteOperation_Disable(hsram->Instance, hsram->Init.NSBank);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 /* Update the SRAM controller state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 hsram->State = HAL_SRAM_STATE_PROTECTED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 __HAL_UNLOCK(hsram);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 /** @defgroup SRAM_Exported_Functions_Group4 State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 ##### SRAM State functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 This subsection permits to get in run-time the status of the SRAM controller
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 and the data flow.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 * @brief Returns the SRAM controller state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 * the configuration information for SRAM module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 HAL_SRAM_StateTypeDef HAL_SRAM_GetState(SRAM_HandleTypeDef *hsram)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 return hsram->State;
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 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 #endif /* HAL_SRAM_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/