BSP_DISCO_L4R9I
Dependents: DISCO_L4R9I-LCD-demo
Drivers/BSP/STM32L4R9I-Discovery/stm32l4r9i_discovery_ospi_nor.c@1:2105b8894450, 2019-11-26 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Tue Nov 26 14:35:07 2019 +0100
- Revision:
- 1:2105b8894450
- Parent:
- 0:31ddfafdd3da
Update for MBED use
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
0:31ddfafdd3da
|
1
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
2
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
3
|
* @file stm32l4r9i_discovery_ospi_nor.c
|
|
Jerome Coutant
0:31ddfafdd3da
|
4
|
* @author MCD Application Team
|
|
Jerome Coutant
0:31ddfafdd3da
|
5
|
* @brief This file includes a standard driver for the MX25LM51245G OSPI
|
|
Jerome Coutant
0:31ddfafdd3da
|
6
|
* memory mounted on STM32L4R9I_DISCOVERY board.
|
|
Jerome Coutant
0:31ddfafdd3da
|
7
|
@verbatim
|
|
Jerome Coutant
0:31ddfafdd3da
|
8
|
==============================================================================
|
|
Jerome Coutant
0:31ddfafdd3da
|
9
|
##### How to use this driver #####
|
|
Jerome Coutant
0:31ddfafdd3da
|
10
|
==============================================================================
|
|
Jerome Coutant
0:31ddfafdd3da
|
11
|
[..]
|
|
Jerome Coutant
0:31ddfafdd3da
|
12
|
(#) This driver is used to drive the MX25LM51245G OSPI external
|
|
Jerome Coutant
0:31ddfafdd3da
|
13
|
memory mounted on STM32L4R9I_DISCOVERY evaluation board.
|
|
Jerome Coutant
0:31ddfafdd3da
|
14
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
15
|
(#) This driver need a specific component driver (MX25LM51245G) to be included with.
|
|
Jerome Coutant
0:31ddfafdd3da
|
16
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
17
|
(#) Initialization steps:
|
|
Jerome Coutant
0:31ddfafdd3da
|
18
|
(++) Initialize the OPSI external memory using the BSP_OSPI_NOR_Init() function. This
|
|
Jerome Coutant
0:31ddfafdd3da
|
19
|
function includes the MSP layer hardware resources initialization and the
|
|
Jerome Coutant
0:31ddfafdd3da
|
20
|
OSPI interface with the external memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
21
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
22
|
(#) OSPI memory operations
|
|
Jerome Coutant
0:31ddfafdd3da
|
23
|
(++) OSPI memory can be accessed with read/write operations once it is
|
|
Jerome Coutant
0:31ddfafdd3da
|
24
|
initialized.
|
|
Jerome Coutant
0:31ddfafdd3da
|
25
|
Read/write operation can be performed with AHB access using the functions
|
|
Jerome Coutant
0:31ddfafdd3da
|
26
|
BSP_OSPI_NOR_Read()/BSP_OSPI_NOR_Write().
|
|
Jerome Coutant
0:31ddfafdd3da
|
27
|
(++) The function BSP_OSPI_NOR_GetInfo() returns the configuration of the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
28
|
(see the OSPI memory data sheet)
|
|
Jerome Coutant
0:31ddfafdd3da
|
29
|
(++) Perform erase block operation using the function BSP_OSPI_NOR_Erase_Block() and by
|
|
Jerome Coutant
0:31ddfafdd3da
|
30
|
specifying the block address. You can perform an erase operation of the whole
|
|
Jerome Coutant
0:31ddfafdd3da
|
31
|
chip by calling the function BSP_OSPI_NOR_Erase_Chip().
|
|
Jerome Coutant
0:31ddfafdd3da
|
32
|
(++) The function BSP_OSPI_NOR_GetStatus() returns the current status of the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
33
|
(see the OSPI memory data sheet)
|
|
Jerome Coutant
0:31ddfafdd3da
|
34
|
@endverbatim
|
|
Jerome Coutant
0:31ddfafdd3da
|
35
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
36
|
* @attention
|
|
Jerome Coutant
0:31ddfafdd3da
|
37
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
38
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
|
Jerome Coutant
0:31ddfafdd3da
|
39
|
* All rights reserved.</center></h2>
|
|
Jerome Coutant
0:31ddfafdd3da
|
40
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
41
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
Jerome Coutant
0:31ddfafdd3da
|
42
|
* the "License"; You may not use this file except in compliance with the
|
|
Jerome Coutant
0:31ddfafdd3da
|
43
|
* License. You may obtain a copy of the License at:
|
|
Jerome Coutant
0:31ddfafdd3da
|
44
|
* opensource.org/licenses/BSD-3-Clause
|
|
Jerome Coutant
0:31ddfafdd3da
|
45
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
46
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
47
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
48
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
49
|
/* Includes ------------------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
50
|
#include "stm32l4r9i_discovery_ospi_nor.h"
|
|
Jerome Coutant
0:31ddfafdd3da
|
51
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
52
|
/** @addtogroup BSP
|
|
Jerome Coutant
0:31ddfafdd3da
|
53
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
54
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
55
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
56
|
/** @addtogroup STM32L4R9I_DISCOVERY
|
|
Jerome Coutant
0:31ddfafdd3da
|
57
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
58
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
59
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
60
|
/** @defgroup STM32L4R9I_DISCOVERY_OSPI_NOR STM32L4R9I_DISCOVERY OSPI NOR
|
|
Jerome Coutant
0:31ddfafdd3da
|
61
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
62
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
63
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
64
|
/* Private constants --------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
65
|
/** @defgroup STM32L4R9I_DISCOVERY_OSPI_NOR_Private_Constants Private Constants
|
|
Jerome Coutant
0:31ddfafdd3da
|
66
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
67
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
68
|
#define OSPI_NOR_OCTAL_DISABLE 0x0
|
|
Jerome Coutant
0:31ddfafdd3da
|
69
|
#define OSPI_NOR_OCTAL_ENABLE 0x1
|
|
Jerome Coutant
0:31ddfafdd3da
|
70
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
71
|
#define DUMMY_CYCLES_READ_OCTAL MX25LM51245G_DUMMY_CYCLES_READ_OCTAL_66M
|
|
Jerome Coutant
0:31ddfafdd3da
|
72
|
#define DUMMY_CYCLES_CR_CFG MX25LM51245G_CR2_DC_66M
|
|
Jerome Coutant
0:31ddfafdd3da
|
73
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
74
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
75
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
76
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
77
|
/* Uncomment this line to use the memory in SDR mode */
|
|
Jerome Coutant
0:31ddfafdd3da
|
78
|
//#define BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
79
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
80
|
/* Private variables ---------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
81
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
82
|
/** @defgroup STM32L4R9I_DISCOVERY_OSPI_NOR_Private_Variables Private Variables
|
|
Jerome Coutant
0:31ddfafdd3da
|
83
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
84
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
85
|
OSPI_HandleTypeDef OSPINORHandle;
|
|
Jerome Coutant
0:31ddfafdd3da
|
86
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
87
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
88
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
89
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
90
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
91
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
92
|
/* Private functions ---------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
93
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
94
|
/** @defgroup STM32L4R9I_DISCOVERY_OSPI_NOR_Private_Functions Private Functions
|
|
Jerome Coutant
0:31ddfafdd3da
|
95
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
96
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
97
|
static void OSPI_NOR_MspInit (void);
|
|
Jerome Coutant
0:31ddfafdd3da
|
98
|
static void OSPI_NOR_MspDeInit (void);
|
|
Jerome Coutant
0:31ddfafdd3da
|
99
|
static uint8_t OSPI_NOR_ResetMemory (OSPI_HandleTypeDef *hospi);
|
|
Jerome Coutant
0:31ddfafdd3da
|
100
|
static uint8_t OSPI_NOR_WriteEnable (OSPI_HandleTypeDef *hospi);
|
|
Jerome Coutant
0:31ddfafdd3da
|
101
|
static uint8_t OSPI_NOR_AutoPollingMemReady(OSPI_HandleTypeDef *hospi, uint32_t Timeout);
|
|
Jerome Coutant
0:31ddfafdd3da
|
102
|
static uint8_t OSPI_NOR_OctalMode (OSPI_HandleTypeDef *hospi, uint8_t Operation);
|
|
Jerome Coutant
0:31ddfafdd3da
|
103
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
104
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
105
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
106
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
107
|
/* Exported functions ---------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
108
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
109
|
/** @addtogroup STM32L4R9I_DISCOVERY_OSPI_NOR_Exported_Functions
|
|
Jerome Coutant
0:31ddfafdd3da
|
110
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
111
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
112
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
113
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
114
|
* @brief Initializes the OSPI interface.
|
|
Jerome Coutant
0:31ddfafdd3da
|
115
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
116
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
117
|
uint8_t BSP_OSPI_NOR_Init(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
118
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
119
|
OSPIM_CfgTypeDef OSPIM_Cfg_Struct;
|
|
Jerome Coutant
0:31ddfafdd3da
|
120
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
121
|
OSPINORHandle.Instance = OCTOSPI1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
122
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
123
|
/* Call the DeInit function to reset the driver */
|
|
Jerome Coutant
0:31ddfafdd3da
|
124
|
if (HAL_OSPI_DeInit(&OSPINORHandle) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
125
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
126
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
127
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
128
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
129
|
/* System level initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
130
|
OSPI_NOR_MspInit();
|
|
Jerome Coutant
0:31ddfafdd3da
|
131
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
132
|
/* OctoSPI initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
133
|
OSPINORHandle.Init.FifoThreshold = 4;
|
|
Jerome Coutant
0:31ddfafdd3da
|
134
|
OSPINORHandle.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
135
|
OSPINORHandle.Init.DeviceSize = POSITION_VAL(MX25LM51245G_FLASH_SIZE); /* 512 MBits */
|
|
Jerome Coutant
0:31ddfafdd3da
|
136
|
OSPINORHandle.Init.ChipSelectHighTime = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
137
|
OSPINORHandle.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
138
|
OSPINORHandle.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
139
|
OSPINORHandle.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
|
|
Jerome Coutant
0:31ddfafdd3da
|
140
|
OSPINORHandle.Init.ClockPrescaler = 2; /* OctoSPI clock = 120MHz / ClockPrescaler = 60MHz */
|
|
Jerome Coutant
0:31ddfafdd3da
|
141
|
OSPINORHandle.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
142
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
143
|
OSPINORHandle.Init.MemoryType = HAL_OSPI_MEMTYPE_MICRON;
|
|
Jerome Coutant
0:31ddfafdd3da
|
144
|
OSPINORHandle.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
145
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
146
|
OSPINORHandle.Init.MemoryType = HAL_OSPI_MEMTYPE_MACRONIX;
|
|
Jerome Coutant
0:31ddfafdd3da
|
147
|
OSPINORHandle.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
148
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
149
|
OSPINORHandle.Init.ChipSelectBoundary = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
150
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
151
|
if (HAL_OSPI_Init(&OSPINORHandle) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
152
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
153
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
154
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
155
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
156
|
/* OctoSPI IO Manager configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
157
|
OSPIM_Cfg_Struct.ClkPort = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
158
|
OSPIM_Cfg_Struct.DQSPort = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
159
|
OSPIM_Cfg_Struct.IOHighPort = HAL_OSPIM_IOPORT_2_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
160
|
OSPIM_Cfg_Struct.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
|
|
Jerome Coutant
0:31ddfafdd3da
|
161
|
OSPIM_Cfg_Struct.NCSPort = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
162
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
163
|
if (HAL_OSPIM_Config(&OSPINORHandle, &OSPIM_Cfg_Struct, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
164
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
165
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
166
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
167
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
168
|
/* OctoSPI memory reset */
|
|
Jerome Coutant
0:31ddfafdd3da
|
169
|
if (OSPI_NOR_ResetMemory(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
170
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
171
|
return OSPI_NOR_NOT_SUPPORTED;
|
|
Jerome Coutant
0:31ddfafdd3da
|
172
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
173
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
174
|
/* Insert delay */
|
|
Jerome Coutant
0:31ddfafdd3da
|
175
|
HAL_Delay(1);
|
|
Jerome Coutant
0:31ddfafdd3da
|
176
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
177
|
/* OctoSPI octal enable */
|
|
Jerome Coutant
0:31ddfafdd3da
|
178
|
if (OSPI_NOR_OctalMode(&OSPINORHandle, OSPI_NOR_OCTAL_ENABLE) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
179
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
180
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
181
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
182
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
183
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
184
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
185
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
186
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
187
|
* @brief De-Initializes the OSPI interface.
|
|
Jerome Coutant
0:31ddfafdd3da
|
188
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
189
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
190
|
uint8_t BSP_OSPI_NOR_DeInit(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
191
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
192
|
OSPINORHandle.Instance = OCTOSPI1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
193
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
194
|
/* Abort any activity on OctoSPI (eg Memory-mapped mode) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
195
|
if (HAL_OSPI_GetState(&OSPINORHandle) != HAL_OSPI_STATE_READY)
|
|
Jerome Coutant
0:31ddfafdd3da
|
196
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
197
|
if (HAL_OSPI_Abort(&OSPINORHandle) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
198
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
199
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
200
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
201
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
202
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
203
|
/* OctoSPI octal mode disable */
|
|
Jerome Coutant
0:31ddfafdd3da
|
204
|
if (OSPI_NOR_OctalMode(&OSPINORHandle, OSPI_NOR_OCTAL_DISABLE) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
205
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
206
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
207
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
208
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
209
|
/* Call the DeInit function to reset the driver */
|
|
Jerome Coutant
0:31ddfafdd3da
|
210
|
if (HAL_OSPI_DeInit(&OSPINORHandle) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
211
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
212
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
213
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
214
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
215
|
/* System level De-initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
216
|
OSPI_NOR_MspDeInit();
|
|
Jerome Coutant
0:31ddfafdd3da
|
217
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
218
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
219
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
220
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
221
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
222
|
* @brief Reads an amount of data from the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
223
|
* @param pData: Pointer to data to be read
|
|
Jerome Coutant
0:31ddfafdd3da
|
224
|
* @param ReadAddr: Read start address
|
|
Jerome Coutant
0:31ddfafdd3da
|
225
|
* @param Size: Size of data to read
|
|
Jerome Coutant
0:31ddfafdd3da
|
226
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
227
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
228
|
uint8_t BSP_OSPI_NOR_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size)
|
|
Jerome Coutant
0:31ddfafdd3da
|
229
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
230
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
231
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
232
|
/* Initialize the read command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
233
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
234
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
235
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
236
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
237
|
sCommand.Address = ReadAddr;
|
|
Jerome Coutant
0:31ddfafdd3da
|
238
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
239
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
240
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
241
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
242
|
sCommand.NbData = Size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
243
|
sCommand.DummyCycles = DUMMY_CYCLES_READ_OCTAL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
244
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
245
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
246
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
247
|
sCommand.Instruction = OCTAL_IO_READ_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
248
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
249
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
250
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
251
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
252
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
253
|
sCommand.Instruction = OCTAL_IO_DTR_READ_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
254
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
255
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
256
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
257
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
258
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
259
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
260
|
/* Configure the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
261
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
262
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
263
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
264
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
265
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
266
|
/* Reception of the data */
|
|
Jerome Coutant
0:31ddfafdd3da
|
267
|
if (HAL_OSPI_Receive(&OSPINORHandle, pData, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
268
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
269
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
270
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
271
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
272
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
273
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
274
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
275
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
276
|
* @brief Writes an amount of data to the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
277
|
* @param pData: Pointer to data to be written
|
|
Jerome Coutant
0:31ddfafdd3da
|
278
|
* @param WriteAddr: Write start address
|
|
Jerome Coutant
0:31ddfafdd3da
|
279
|
* @param Size: Size of data to write
|
|
Jerome Coutant
0:31ddfafdd3da
|
280
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
281
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
282
|
uint8_t BSP_OSPI_NOR_Write(uint8_t* pData, uint32_t WriteAddr, uint32_t Size)
|
|
Jerome Coutant
0:31ddfafdd3da
|
283
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
284
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
285
|
uint32_t end_addr, current_size, current_addr;
|
|
Jerome Coutant
0:31ddfafdd3da
|
286
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
287
|
/* Calculation of the size between the write address and the end of the page */
|
|
Jerome Coutant
0:31ddfafdd3da
|
288
|
current_size = MX25LM51245G_PAGE_SIZE - (WriteAddr % MX25LM51245G_PAGE_SIZE);
|
|
Jerome Coutant
0:31ddfafdd3da
|
289
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
290
|
/* Check if the size of the data is less than the remaining place in the page */
|
|
Jerome Coutant
0:31ddfafdd3da
|
291
|
if (current_size > Size)
|
|
Jerome Coutant
0:31ddfafdd3da
|
292
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
293
|
current_size = Size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
294
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
295
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
296
|
/* Initialize the adress variables */
|
|
Jerome Coutant
0:31ddfafdd3da
|
297
|
current_addr = WriteAddr;
|
|
Jerome Coutant
0:31ddfafdd3da
|
298
|
end_addr = WriteAddr + Size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
299
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
300
|
/* Initialize the program command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
301
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
302
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
303
|
sCommand.Instruction = OCTAL_PAGE_PROG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
304
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
305
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
306
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
307
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
308
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
309
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
310
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
311
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
312
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
313
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
314
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
315
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
316
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
317
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
318
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
319
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
320
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
321
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
322
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
323
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
324
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
325
|
/* Perform the write page by page */
|
|
Jerome Coutant
0:31ddfafdd3da
|
326
|
do
|
|
Jerome Coutant
0:31ddfafdd3da
|
327
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
328
|
sCommand.Address = current_addr;
|
|
Jerome Coutant
0:31ddfafdd3da
|
329
|
sCommand.NbData = current_size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
330
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
331
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
332
|
if (OSPI_NOR_WriteEnable(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
333
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
334
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
335
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
336
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
337
|
/* Configure the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
338
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
339
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
340
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
341
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
342
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
343
|
/* Transmission of the data */
|
|
Jerome Coutant
0:31ddfafdd3da
|
344
|
if (HAL_OSPI_Transmit(&OSPINORHandle, pData, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
345
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
346
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
347
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
348
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
349
|
/* Configure automatic polling mode to wait for end of program */
|
|
Jerome Coutant
0:31ddfafdd3da
|
350
|
if (OSPI_NOR_AutoPollingMemReady(&OSPINORHandle, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
351
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
352
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
353
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
354
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
355
|
/* Update the address and size variables for next page programming */
|
|
Jerome Coutant
0:31ddfafdd3da
|
356
|
current_addr += current_size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
357
|
pData += current_size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
358
|
current_size = ((current_addr + MX25LM51245G_PAGE_SIZE) > end_addr) ? (end_addr - current_addr) : MX25LM51245G_PAGE_SIZE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
359
|
} while (current_addr < end_addr);
|
|
Jerome Coutant
0:31ddfafdd3da
|
360
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
361
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
362
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
363
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
364
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
365
|
* @brief Erases the specified block of the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
366
|
* @param BlockAddress: Block address to erase
|
|
Jerome Coutant
0:31ddfafdd3da
|
367
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
368
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
369
|
uint8_t BSP_OSPI_NOR_Erase_Block(uint32_t BlockAddress)
|
|
Jerome Coutant
0:31ddfafdd3da
|
370
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
371
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
372
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
373
|
/* Initialize the erase command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
374
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
375
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
376
|
sCommand.Instruction = OCTAL_BLOCK_ERASE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
377
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
378
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
379
|
sCommand.Address = BlockAddress;
|
|
Jerome Coutant
0:31ddfafdd3da
|
380
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
381
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
382
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
383
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
384
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
385
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
386
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
387
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
388
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
389
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
390
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
391
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
392
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
393
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
394
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
395
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
396
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
397
|
if (OSPI_NOR_WriteEnable(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
398
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
399
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
400
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
401
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
402
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
403
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
404
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
405
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
406
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
407
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
408
|
/* Configure automatic polling mode to wait for end of erase */
|
|
Jerome Coutant
0:31ddfafdd3da
|
409
|
if (OSPI_NOR_AutoPollingMemReady(&OSPINORHandle, MX25LM51245G_BLOCK_ERASE_MAX_TIME) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
410
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
411
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
412
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
413
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
414
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
415
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
416
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
417
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
418
|
* @brief Erases the specified sector of the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
419
|
* @param Sector: Sector address to erase (0 to 255)
|
|
Jerome Coutant
0:31ddfafdd3da
|
420
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
421
|
* @note This function is non blocking meaning that sector erase
|
|
Jerome Coutant
0:31ddfafdd3da
|
422
|
* operation is started but not completed when the function
|
|
Jerome Coutant
0:31ddfafdd3da
|
423
|
* returns. Application has to call BSP_QSPI_GetStatus()
|
|
Jerome Coutant
0:31ddfafdd3da
|
424
|
* to know when the device is available again (i.e. erase operation
|
|
Jerome Coutant
0:31ddfafdd3da
|
425
|
* completed).
|
|
Jerome Coutant
0:31ddfafdd3da
|
426
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
427
|
uint8_t BSP_OSPI_NOR_Erase_Sector(uint32_t Sector)
|
|
Jerome Coutant
0:31ddfafdd3da
|
428
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
429
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
430
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
431
|
if (Sector >= (uint32_t)(MX25LM51245G_FLASH_SIZE/MX25LM51245G_SECTOR_SIZE))
|
|
Jerome Coutant
0:31ddfafdd3da
|
432
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
433
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
434
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
435
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
436
|
/* Initialize the erase command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
437
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
438
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
439
|
sCommand.Instruction = OCTAL_SECTOR_ERASE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
440
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
441
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
442
|
sCommand.Address = (Sector * MX25LM51245G_SECTOR_SIZE);
|
|
Jerome Coutant
0:31ddfafdd3da
|
443
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
444
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
445
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
446
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
447
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
448
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
449
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
450
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
451
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
452
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
453
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
454
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
455
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
456
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
457
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
458
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
459
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
460
|
if (OSPI_NOR_WriteEnable(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
461
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
462
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
463
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
464
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
465
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
466
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
467
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
468
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
469
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
470
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
471
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
472
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
473
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
474
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
475
|
* @brief Erases the entire OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
476
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
477
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
478
|
uint8_t BSP_OSPI_NOR_Erase_Chip(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
479
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
480
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
481
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
482
|
/* Initialize the erase command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
483
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
484
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
485
|
sCommand.Instruction = OCTAL_CHIP_ERASE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
486
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
487
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
488
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
489
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
490
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
491
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
492
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
493
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
494
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
495
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
496
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
497
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
498
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
499
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
500
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
501
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
502
|
if (OSPI_NOR_WriteEnable(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
503
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
504
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
505
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
506
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
507
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
508
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
509
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
510
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
511
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
512
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
513
|
/* Configure automatic polling mode to wait for end of erase */
|
|
Jerome Coutant
0:31ddfafdd3da
|
514
|
if (OSPI_NOR_AutoPollingMemReady(&OSPINORHandle, MX25LM51245G_CHIP_ERASE_MAX_TIME) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
515
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
516
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
517
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
518
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
519
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
520
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
521
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
522
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
523
|
* @brief Reads current status of the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
524
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
525
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
526
|
uint8_t BSP_OSPI_NOR_GetStatus(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
527
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
528
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
529
|
uint8_t reg[2];
|
|
Jerome Coutant
0:31ddfafdd3da
|
530
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
531
|
/* Initialize the read security register command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
532
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
533
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
534
|
sCommand.Instruction = OCTAL_READ_SECURITY_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
535
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
536
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
537
|
sCommand.Address = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
538
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
539
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
540
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
541
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
542
|
sCommand.NbData = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
543
|
sCommand.DummyCycles = DUMMY_CYCLES_READ_OCTAL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
544
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
545
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
546
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
547
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
548
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
549
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
550
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
551
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
552
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
553
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
554
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
555
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
556
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
557
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
558
|
/* Configure the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
559
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
560
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
561
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
562
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
563
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
564
|
/* Reception of the data */
|
|
Jerome Coutant
0:31ddfafdd3da
|
565
|
if (HAL_OSPI_Receive(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
566
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
567
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
568
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
569
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
570
|
/* Check the value of the register */
|
|
Jerome Coutant
0:31ddfafdd3da
|
571
|
if ((reg[0] & (MX25LM51245G_SECR_P_FAIL | MX25LM51245G_SECR_E_FAIL)) != 0)
|
|
Jerome Coutant
0:31ddfafdd3da
|
572
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
573
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
574
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
575
|
else if ((reg[0] & (MX25LM51245G_SECR_PSB | MX25LM51245G_SECR_ESB)) != 0)
|
|
Jerome Coutant
0:31ddfafdd3da
|
576
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
577
|
return OSPI_NOR_SUSPENDED;
|
|
Jerome Coutant
0:31ddfafdd3da
|
578
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
579
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
580
|
/* Initialize the read status register command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
581
|
sCommand.Instruction = OCTAL_READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
582
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
583
|
/* Configure the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
584
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
585
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
586
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
587
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
588
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
589
|
/* Reception of the data */
|
|
Jerome Coutant
0:31ddfafdd3da
|
590
|
if (HAL_OSPI_Receive(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
591
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
592
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
593
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
594
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
595
|
/* Check the value of the register */
|
|
Jerome Coutant
0:31ddfafdd3da
|
596
|
if ((reg[0] & MX25LM51245G_SR_WIP) != 0)
|
|
Jerome Coutant
0:31ddfafdd3da
|
597
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
598
|
return OSPI_NOR_BUSY;
|
|
Jerome Coutant
0:31ddfafdd3da
|
599
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
600
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
601
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
602
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
603
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
604
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
605
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
606
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
607
|
* @brief Return the configuration of the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
608
|
* @param pInfo: pointer on the configuration structure
|
|
Jerome Coutant
0:31ddfafdd3da
|
609
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
610
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
611
|
uint8_t BSP_OSPI_NOR_GetInfo(OSPI_NOR_Info* pInfo)
|
|
Jerome Coutant
0:31ddfafdd3da
|
612
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
613
|
/* Configure the structure with the memory configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
614
|
pInfo->FlashSize = MX25LM51245G_FLASH_SIZE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
615
|
pInfo->EraseSectorSize = MX25LM51245G_BLOCK_SIZE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
616
|
pInfo->EraseSectorsNumber = (MX25LM51245G_FLASH_SIZE/MX25LM51245G_BLOCK_SIZE);
|
|
Jerome Coutant
0:31ddfafdd3da
|
617
|
pInfo->ProgPageSize = MX25LM51245G_PAGE_SIZE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
618
|
pInfo->ProgPagesNumber = (MX25LM51245G_FLASH_SIZE/MX25LM51245G_PAGE_SIZE);
|
|
Jerome Coutant
0:31ddfafdd3da
|
619
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
620
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
621
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
622
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
623
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
624
|
* @brief Configure the OSPI in memory-mapped mode
|
|
Jerome Coutant
0:31ddfafdd3da
|
625
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
626
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
627
|
uint8_t BSP_OSPI_NOR_EnableMemoryMappedMode(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
628
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
629
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
630
|
OSPI_MemoryMappedTypeDef sMemMappedCfg;
|
|
Jerome Coutant
0:31ddfafdd3da
|
631
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
632
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
633
|
if (OSPI_NOR_WriteEnable(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
634
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
635
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
636
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
637
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
638
|
/* Configure the command for the read instruction */
|
|
Jerome Coutant
0:31ddfafdd3da
|
639
|
sCommand.OperationType = HAL_OSPI_OPTYPE_READ_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
640
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
641
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
642
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
643
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
644
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
645
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
646
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
647
|
sCommand.DummyCycles = DUMMY_CYCLES_READ_OCTAL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
648
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
649
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
650
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
651
|
sCommand.Instruction = OCTAL_IO_READ_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
652
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
653
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
654
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
655
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
656
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
657
|
sCommand.Instruction = OCTAL_IO_DTR_READ_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
658
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
659
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
660
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
661
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
662
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
663
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
664
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
665
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
666
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
667
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
668
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
669
|
/* Configure the command for the write instruction */
|
|
Jerome Coutant
0:31ddfafdd3da
|
670
|
sCommand.OperationType = HAL_OSPI_OPTYPE_WRITE_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
671
|
sCommand.Instruction = OCTAL_PAGE_PROG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
672
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
673
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
674
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
675
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
676
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
677
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
678
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
679
|
/* Configure the memory mapped mode */
|
|
Jerome Coutant
0:31ddfafdd3da
|
680
|
sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
681
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
682
|
if (HAL_OSPI_MemoryMapped(&OSPINORHandle, &sMemMappedCfg) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
683
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
684
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
685
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
686
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
687
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
688
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
689
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
690
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
691
|
* @brief This function suspends an ongoing erase command.
|
|
Jerome Coutant
0:31ddfafdd3da
|
692
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
693
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
694
|
uint8_t BSP_OSPI_NOR_SuspendErase(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
695
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
696
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
697
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
698
|
/* Check whether the device is busy (erase operation is
|
|
Jerome Coutant
0:31ddfafdd3da
|
699
|
in progress).
|
|
Jerome Coutant
0:31ddfafdd3da
|
700
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
701
|
if (BSP_OSPI_NOR_GetStatus() == OSPI_NOR_BUSY)
|
|
Jerome Coutant
0:31ddfafdd3da
|
702
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
703
|
/* Initialize the suspend command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
704
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
705
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
706
|
sCommand.Instruction = OCTAL_PROG_ERASE_SUSPEND_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
707
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
708
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
709
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
710
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
711
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
712
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
713
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
714
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
715
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
716
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
717
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
718
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
719
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
720
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
721
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
722
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
723
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
724
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
725
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
726
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
727
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
728
|
if (BSP_OSPI_NOR_GetStatus() == OSPI_NOR_SUSPENDED)
|
|
Jerome Coutant
0:31ddfafdd3da
|
729
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
730
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
731
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
732
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
733
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
734
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
735
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
736
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
737
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
738
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
739
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
740
|
* @brief This function resumes a paused erase command.
|
|
Jerome Coutant
0:31ddfafdd3da
|
741
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
742
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
743
|
uint8_t BSP_OSPI_NOR_ResumeErase(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
744
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
745
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
746
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
747
|
/* Check whether the device is in suspended state */
|
|
Jerome Coutant
0:31ddfafdd3da
|
748
|
if (BSP_OSPI_NOR_GetStatus() == OSPI_NOR_SUSPENDED)
|
|
Jerome Coutant
0:31ddfafdd3da
|
749
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
750
|
/* Initialize the resume command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
751
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
752
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
753
|
sCommand.Instruction = OCTAL_PROG_ERASE_RESUME_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
754
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
755
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
756
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
757
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
758
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
759
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
760
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
761
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
762
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
763
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
764
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
765
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
766
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
767
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
768
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
769
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
770
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
771
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
772
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
773
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
774
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
775
|
/*
|
|
Jerome Coutant
0:31ddfafdd3da
|
776
|
When this command is executed, the status register write in progress bit is set to 1, and
|
|
Jerome Coutant
0:31ddfafdd3da
|
777
|
the flag status register program erase controller bit is set to 0. This command is ignored
|
|
Jerome Coutant
0:31ddfafdd3da
|
778
|
if the device is not in a suspended state.
|
|
Jerome Coutant
0:31ddfafdd3da
|
779
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
780
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
781
|
if (BSP_OSPI_NOR_GetStatus() == OSPI_NOR_BUSY)
|
|
Jerome Coutant
0:31ddfafdd3da
|
782
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
783
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
784
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
785
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
786
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
787
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
788
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
789
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
790
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
791
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
792
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
793
|
* @brief This function enter the OSPI memory in deep power down mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
794
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
795
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
796
|
uint8_t BSP_OSPI_NOR_EnterDeepPowerDown(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
797
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
798
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
799
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
800
|
/* Initialize the deep power down command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
801
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
802
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
803
|
sCommand.Instruction = OCTAL_ENTER_DEEP_POWER_DOWN_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
804
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
805
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
806
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
807
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
808
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
809
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
810
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
811
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
812
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
813
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
814
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
815
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
816
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
817
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
818
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
819
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
820
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
821
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
822
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
823
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
824
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
825
|
/* --- Memory takes 10us max to enter deep power down --- */
|
|
Jerome Coutant
0:31ddfafdd3da
|
826
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
827
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
828
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
829
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
830
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
831
|
* @brief This function leave the OSPI memory from deep power down mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
832
|
* @retval OSPI memory status
|
|
Jerome Coutant
0:31ddfafdd3da
|
833
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
834
|
uint8_t BSP_OSPI_NOR_LeaveDeepPowerDown(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
835
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
836
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
837
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
838
|
/* Initialize the nop command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
839
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
840
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
841
|
sCommand.Instruction = OCTAL_NO_OPERATION_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
842
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
843
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
844
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
845
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
846
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
847
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
848
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
849
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
850
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
851
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
852
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
853
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
854
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
855
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
856
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
857
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
858
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
859
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
860
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
861
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
862
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
863
|
/* --- A NOP command is sent to the memory, as the nCS should be low for at least 20 ns --- */
|
|
Jerome Coutant
0:31ddfafdd3da
|
864
|
/* --- Memory takes 30us min to leave deep power down --- */
|
|
Jerome Coutant
0:31ddfafdd3da
|
865
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
866
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
867
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
868
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
869
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
870
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
871
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
872
|
/** @addtogroup STM32L4R9I_DISCOVERY_OSPI_NOR_Private_Functions
|
|
Jerome Coutant
0:31ddfafdd3da
|
873
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
874
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
875
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
876
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
877
|
* @brief Initializes the OSPI MSP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
878
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
879
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
880
|
static void OSPI_NOR_MspInit(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
881
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
882
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
Jerome Coutant
0:31ddfafdd3da
|
883
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
884
|
/* Enable the OctoSPI memory interface clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
885
|
__HAL_RCC_OSPIM_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
886
|
__HAL_RCC_OSPI1_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
887
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
888
|
/* Reset the OctoSPI memory interface */
|
|
Jerome Coutant
0:31ddfafdd3da
|
889
|
__HAL_RCC_OSPI1_FORCE_RESET();
|
|
Jerome Coutant
0:31ddfafdd3da
|
890
|
__HAL_RCC_OSPI1_RELEASE_RESET();
|
|
Jerome Coutant
0:31ddfafdd3da
|
891
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
892
|
/* Enable GPIO clocks */
|
|
Jerome Coutant
0:31ddfafdd3da
|
893
|
/* IOSV bit MUST be set to access GPIO port G[2:15] */
|
|
Jerome Coutant
0:31ddfafdd3da
|
894
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
895
|
SET_BIT(PWR->CR2, PWR_CR2_IOSV);
|
|
Jerome Coutant
0:31ddfafdd3da
|
896
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
897
|
__HAL_RCC_GPIOG_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
898
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
899
|
__HAL_RCC_GPIOI_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
900
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
901
|
/* OctoSPI CS GPIO pin configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
902
|
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
|
Jerome Coutant
0:31ddfafdd3da
|
903
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
904
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
905
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
906
|
GPIO_InitStruct.Alternate = GPIO_AF5_OCTOSPIM_P2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
907
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
908
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
909
|
/* OctoSPI DQS GPIO pins configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
910
|
GPIO_InitStruct.Pin = GPIO_PIN_15;
|
|
Jerome Coutant
0:31ddfafdd3da
|
911
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
912
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
913
|
/* OctoSPI CLK, D0, D1 and D2 GPIO pins configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
914
|
GPIO_InitStruct.Pin = (GPIO_PIN_6 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11);
|
|
Jerome Coutant
0:31ddfafdd3da
|
915
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
916
|
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
917
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
918
|
/* OctoSPI D3, D4 and D5 GPIO pins configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
919
|
GPIO_InitStruct.Pin = (GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10);
|
|
Jerome Coutant
0:31ddfafdd3da
|
920
|
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
921
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
922
|
/* OctoSPI D6 and D7 GPIO pins configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
923
|
GPIO_InitStruct.Pin = (GPIO_PIN_9 | GPIO_PIN_10);
|
|
Jerome Coutant
0:31ddfafdd3da
|
924
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
925
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
926
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
927
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
928
|
* @brief De-Initializes the OSPI MSP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
929
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
930
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
931
|
static void OSPI_NOR_MspDeInit(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
932
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
933
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
Jerome Coutant
0:31ddfafdd3da
|
934
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
935
|
/* OctoSPI CLK, CS, D0-D7, DQS GPIO pins de-configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
936
|
HAL_GPIO_DeInit(GPIOG, (GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_12 | GPIO_PIN_15));
|
|
Jerome Coutant
0:31ddfafdd3da
|
937
|
HAL_GPIO_DeInit(GPIOH, (GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10));
|
|
Jerome Coutant
0:31ddfafdd3da
|
938
|
HAL_GPIO_DeInit(GPIOI, (GPIO_PIN_6 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11));
|
|
Jerome Coutant
0:31ddfafdd3da
|
939
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
940
|
/* Set GPIOG pin 12 in pull up mode (optimum default setting) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
941
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
Jerome Coutant
0:31ddfafdd3da
|
942
|
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
|
Jerome Coutant
0:31ddfafdd3da
|
943
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
944
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
Jerome Coutant
0:31ddfafdd3da
|
945
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
946
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
947
|
/* Set GPIOG pin 15 in no pull, low state (optimum default setting) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
948
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
949
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
950
|
GPIO_InitStruct.Pin = GPIO_PIN_15;
|
|
Jerome Coutant
0:31ddfafdd3da
|
951
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
952
|
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_15, GPIO_PIN_RESET);
|
|
Jerome Coutant
0:31ddfafdd3da
|
953
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
954
|
/* Reset the OctoSPI memory interface */
|
|
Jerome Coutant
0:31ddfafdd3da
|
955
|
__HAL_RCC_OSPI1_FORCE_RESET();
|
|
Jerome Coutant
0:31ddfafdd3da
|
956
|
__HAL_RCC_OSPI1_RELEASE_RESET();
|
|
Jerome Coutant
0:31ddfafdd3da
|
957
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
958
|
/* Disable the OctoSPI memory interface clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
959
|
__HAL_RCC_OSPI1_CLK_DISABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
960
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
961
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
962
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
963
|
* @brief This function reset the OSPI memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
964
|
* @param hospi: OSPI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
965
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
966
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
967
|
static uint8_t OSPI_NOR_ResetMemory(OSPI_HandleTypeDef *hospi)
|
|
Jerome Coutant
0:31ddfafdd3da
|
968
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
969
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
970
|
OSPI_AutoPollingTypeDef sConfig;
|
|
Jerome Coutant
0:31ddfafdd3da
|
971
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
972
|
/* Initialize the reset enable command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
973
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
974
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
975
|
sCommand.Instruction = RESET_ENABLE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
976
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
977
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
978
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
979
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
980
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
981
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
982
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
983
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
984
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
985
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
986
|
/* Send the command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
987
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
988
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
989
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
990
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
991
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
992
|
/* Send the reset memory command */
|
|
Jerome Coutant
0:31ddfafdd3da
|
993
|
sCommand.Instruction = RESET_MEMORY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
994
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
995
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
996
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
997
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
998
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
999
|
/* Configure automatic polling mode to wait the memory is ready */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1000
|
sCommand.Instruction = READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1001
|
sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1002
|
sCommand.NbData = 1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1003
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1004
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1005
|
sConfig.Match = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1006
|
sConfig.Mask = MX25LM51245G_SR_WIP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1007
|
sConfig.MatchMode = HAL_OSPI_MATCH_MODE_AND;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1008
|
sConfig.Interval = 0x10;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1009
|
sConfig.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1010
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1011
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1012
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1013
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1014
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1015
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1016
|
if (HAL_OSPI_AutoPolling(&OSPINORHandle, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1017
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1018
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1019
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1020
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1021
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1022
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1023
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1024
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1025
|
* @brief This function send a Write Enable and wait it is effective.
|
|
Jerome Coutant
0:31ddfafdd3da
|
1026
|
* @param hospi: OSPI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
1027
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
1028
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1029
|
static uint8_t OSPI_NOR_WriteEnable(OSPI_HandleTypeDef *hospi)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1030
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1031
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1032
|
OSPI_AutoPollingTypeDef sConfig;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1033
|
uint8_t reg[2];
|
|
Jerome Coutant
0:31ddfafdd3da
|
1034
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1035
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1036
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1037
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1038
|
sCommand.Instruction = OCTAL_WRITE_ENABLE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1039
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1040
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1041
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1042
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1043
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1044
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1045
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1046
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1047
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1048
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1049
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1050
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
1051
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1052
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1053
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1054
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1055
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1056
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1057
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1058
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1059
|
/* Configure automatic polling mode to wait for write enabling */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1060
|
sConfig.Match = MX25LM51245G_SR_WEL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1061
|
sConfig.Mask = MX25LM51245G_SR_WEL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1062
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1063
|
sCommand.Instruction = OCTAL_READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1064
|
sCommand.Address = 0x0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1065
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1066
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1067
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1068
|
sCommand.NbData = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1069
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1070
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1071
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1072
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1073
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1074
|
sCommand.DummyCycles = DUMMY_CYCLES_READ_OCTAL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1075
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
1076
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1077
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1078
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1079
|
sCommand.DummyCycles = 4;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1080
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1081
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1082
|
do
|
|
Jerome Coutant
0:31ddfafdd3da
|
1083
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1084
|
HAL_Delay(1); /* sConfig.Interval(0x10) / Clock(55 MHz) = 0.29 ms */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1085
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1086
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1087
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1088
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1089
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1090
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1091
|
if (HAL_OSPI_Receive(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1092
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1093
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1094
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1095
|
}while((reg[0] & sConfig.Mask ) != sConfig.Match);
|
|
Jerome Coutant
0:31ddfafdd3da
|
1096
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1097
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1098
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1099
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1100
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1101
|
* @brief This function read the SR of the memory and wait the EOP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
1102
|
* @param hospi: OSPI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
1103
|
* @param Timeout: Timeout for auto-polling
|
|
Jerome Coutant
0:31ddfafdd3da
|
1104
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
1105
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1106
|
static uint8_t OSPI_NOR_AutoPollingMemReady(OSPI_HandleTypeDef *hospi, uint32_t Timeout)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1107
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1108
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1109
|
OSPI_AutoPollingTypeDef sConfig;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1110
|
uint8_t reg[2];
|
|
Jerome Coutant
0:31ddfafdd3da
|
1111
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1112
|
/* Configure automatic polling mode to wait for memory ready */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1113
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1114
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1115
|
sCommand.Instruction = OCTAL_READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1116
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1117
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1118
|
sCommand.Address = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1119
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1120
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1121
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1122
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1123
|
sCommand.NbData = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1124
|
sCommand.DummyCycles = DUMMY_CYCLES_READ_OCTAL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1125
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1126
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1127
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1128
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1129
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1130
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1131
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1132
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
1133
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1134
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1135
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1136
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1137
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1138
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1139
|
sConfig.Match = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1140
|
sConfig.Mask = MX25LM51245G_SR_WIP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1141
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1142
|
do
|
|
Jerome Coutant
0:31ddfafdd3da
|
1143
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1144
|
HAL_Delay(1); /* sConfig.Interval(0x10) / Clock(55 MHz) = 0.29 ms */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1145
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1146
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1147
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1148
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1149
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1150
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1151
|
if (HAL_OSPI_Receive(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1152
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1153
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1154
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1155
|
}while((reg[0] & sConfig.Mask ) != sConfig.Match);
|
|
Jerome Coutant
0:31ddfafdd3da
|
1156
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1157
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1158
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1159
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1160
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1161
|
* @brief This function enables/disables the octal mode of the memory.
|
|
Jerome Coutant
0:31ddfafdd3da
|
1162
|
* @param hospi: OSPI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
1163
|
* @param Operation: Octal operation mode enable/disable
|
|
Jerome Coutant
0:31ddfafdd3da
|
1164
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
1165
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1166
|
static uint8_t OSPI_NOR_OctalMode(OSPI_HandleTypeDef *hospi, uint8_t Operation)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1167
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1168
|
OSPI_RegularCmdTypeDef sCommand;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1169
|
OSPI_AutoPollingTypeDef sConfig;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1170
|
uint8_t reg[2];
|
|
Jerome Coutant
0:31ddfafdd3da
|
1171
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1172
|
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1173
|
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1174
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1175
|
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1176
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1177
|
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1178
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1179
|
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1180
|
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1181
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1182
|
sConfig.MatchMode = HAL_OSPI_MATCH_MODE_AND;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1183
|
sConfig.Interval = 0x10;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1184
|
sConfig.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1185
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1186
|
/* Activate/deactivate the Octal mode */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1187
|
if (Operation == OSPI_NOR_OCTAL_ENABLE)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1188
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1189
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1190
|
sCommand.Instruction = WRITE_ENABLE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1191
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1192
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1193
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1194
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1195
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1196
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1197
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1198
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1199
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1200
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1201
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1202
|
/* Configure automatic polling mode to wait for write enabling */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1203
|
sConfig.Match = MX25LM51245G_SR_WEL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1204
|
sConfig.Mask = MX25LM51245G_SR_WEL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1205
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1206
|
sCommand.Instruction = READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1207
|
sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1208
|
sCommand.NbData = 1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1209
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1210
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1211
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1212
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1213
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1214
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1215
|
if (HAL_OSPI_AutoPolling(&OSPINORHandle, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1216
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1217
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1218
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1219
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1220
|
/* Write Configuration register 2 (with new dummy cycles) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1221
|
sCommand.Instruction = WRITE_CFG_REG_2_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1222
|
sCommand.Address = MX25LM51245G_CR2_REG3_ADDR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1223
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1224
|
reg[0] = DUMMY_CYCLES_CR_CFG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1225
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1226
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1227
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1228
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1229
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1230
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1231
|
if (HAL_OSPI_Transmit(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1232
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1233
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1234
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1235
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1236
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1237
|
sCommand.Instruction = WRITE_ENABLE_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1238
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1239
|
sCommand.DataMode = HAL_OSPI_DATA_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1240
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1241
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1242
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1243
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1244
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1245
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1246
|
/* Configure automatic polling mode to wait for write enabling */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1247
|
sCommand.Instruction = READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1248
|
sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1249
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1250
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1251
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1252
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1253
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1254
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1255
|
if (HAL_OSPI_AutoPolling(&OSPINORHandle, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1256
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1257
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1258
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1259
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1260
|
/* Write Configuration register 2 (with Octal I/O SPI protocol) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1261
|
sCommand.Instruction = WRITE_CFG_REG_2_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1262
|
sCommand.Address = MX25LM51245G_CR2_REG1_ADDR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1263
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1264
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1265
|
reg[0] = MX25LM51245G_CR2_SOPI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1266
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
1267
|
reg[0] = MX25LM51245G_CR2_DOPI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1268
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1269
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1270
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1271
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1272
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1273
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1274
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1275
|
if (HAL_OSPI_Transmit(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1276
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1277
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1278
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1279
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1280
|
/* Wait that the configuration is effective and check that memory is ready */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1281
|
HAL_Delay(MX25LM51245G_WRITE_REG_MAX_TIME);
|
|
Jerome Coutant
0:31ddfafdd3da
|
1282
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1283
|
if (OSPI_NOR_AutoPollingMemReady(&OSPINORHandle, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1284
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1285
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1286
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1287
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1288
|
/* Check the configuration has been correctly done */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1289
|
sCommand.Instruction = OCTAL_READ_CFG_REG_2_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1290
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1291
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1292
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1293
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1294
|
sCommand.DummyCycles = DUMMY_CYCLES_READ_OCTAL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1295
|
sCommand.NbData = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1296
|
reg[0] = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1297
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1298
|
#if !defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1299
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1300
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1301
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1302
|
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1303
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1304
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1305
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1306
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1307
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1308
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1309
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1310
|
if (HAL_OSPI_Receive(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1311
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1312
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1313
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1314
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1315
|
#if defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1316
|
if (reg[0] != MX25LM51245G_CR2_SOPI)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1317
|
#else
|
|
Jerome Coutant
0:31ddfafdd3da
|
1318
|
if (reg[0] != MX25LM51245G_CR2_DOPI)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1319
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1320
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1321
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1322
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1323
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1324
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
1325
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1326
|
/* Enable write operations */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1327
|
if (OSPI_NOR_WriteEnable(&OSPINORHandle) != OSPI_NOR_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1328
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1329
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1330
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1331
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1332
|
/* Write Configuration register 2 (with Octal I/O SPI protocol) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1333
|
sCommand.Instruction = OCTAL_WRITE_CFG_REG_2_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1334
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1335
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1336
|
sCommand.Address = MX25LM51245G_CR2_REG1_ADDR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1337
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1338
|
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1339
|
sCommand.NbData = 2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1340
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1341
|
reg[0] = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1342
|
reg[1] = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1343
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1344
|
#if !defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1345
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1346
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1347
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1348
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1349
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1350
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1351
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1352
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1353
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1354
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1355
|
if (HAL_OSPI_Transmit(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1356
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1357
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1358
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1359
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1360
|
/* Wait that the configuration is effective and check that memory is ready */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1361
|
HAL_Delay(MX25LM51245G_WRITE_REG_MAX_TIME);
|
|
Jerome Coutant
0:31ddfafdd3da
|
1362
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1363
|
sCommand.Instruction = READ_STATUS_REG_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1364
|
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1365
|
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1366
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1367
|
sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1368
|
sCommand.NbData = 1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1369
|
sCommand.DummyCycles = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1370
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1371
|
#if !defined BSP_OSPI_NOR_DDR_MODE_DEACTIVATED
|
|
Jerome Coutant
0:31ddfafdd3da
|
1372
|
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1373
|
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1374
|
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1375
|
#endif
|
|
Jerome Coutant
0:31ddfafdd3da
|
1376
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1377
|
sConfig.Match = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1378
|
sConfig.Mask = MX25LM51245G_SR_WIP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1379
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1380
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1381
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1382
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1383
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1384
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1385
|
if (HAL_OSPI_AutoPolling(&OSPINORHandle, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1386
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1387
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1388
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1389
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1390
|
/* Check the configuration has been correctly done */
|
|
Jerome Coutant
0:31ddfafdd3da
|
1391
|
sCommand.Instruction = READ_CFG_REG_2_CMD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1392
|
sCommand.Address = MX25LM51245G_CR2_REG1_ADDR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1393
|
sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1394
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1395
|
if (HAL_OSPI_Command(&OSPINORHandle, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1396
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1397
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1398
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1399
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1400
|
if (HAL_OSPI_Receive(&OSPINORHandle, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1401
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1402
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1403
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1404
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1405
|
if (reg[0] != 0)
|
|
Jerome Coutant
0:31ddfafdd3da
|
1406
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
1407
|
return OSPI_NOR_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1408
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1409
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1410
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1411
|
return OSPI_NOR_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
1412
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1413
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1414
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1415
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1416
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1417
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1418
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1419
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1420
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1421
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1422
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1423
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1424
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1425
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1426
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
1427
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
1428
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1429
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
1430
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
Jerome Coutant
0:31ddfafdd3da
|
1431
|
|
|