STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_NAND_Init (NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing)
 Perform NAND memory Initialization sequence. More...
 
HAL_StatusTypeDef HAL_NAND_DeInit (NAND_HandleTypeDef *hnand)
 Perform NAND memory De-Initialization sequence. More...
 
HAL_StatusTypeDef HAL_NAND_ConfigDevice (NAND_HandleTypeDef *hnand, NAND_DeviceConfigTypeDef *pDeviceConfig)
 Configure the device: Enter the physical parameters of the device. More...
 
HAL_StatusTypeDef HAL_NAND_Read_ID (NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID)
 Read the NAND memory electronic signature. More...
 
void HAL_NAND_MspInit (NAND_HandleTypeDef *hnand)
 Initialize the NAND MSP. More...
 
void HAL_NAND_MspDeInit (NAND_HandleTypeDef *hnand)
 DeInitialize the NAND MSP. More...
 
void HAL_NAND_IRQHandler (NAND_HandleTypeDef *hnand)
 This function handles NAND device interrupt request. More...
 
void HAL_NAND_ITCallback (NAND_HandleTypeDef *hnand)
 NAND interrupt feature callback. More...
 

Detailed Description

Initialization and Configuration functions.

  ==============================================================================
            ##### NAND Initialization and de-initialization functions #####
  ==============================================================================
  [..]
    This section provides functions allowing to initialize/de-initialize
    the NAND memory

Function Documentation

◆ HAL_NAND_ConfigDevice()

HAL_StatusTypeDef HAL_NAND_ConfigDevice ( NAND_HandleTypeDef hnand,
NAND_DeviceConfigTypeDef pDeviceConfig 
)

Configure the device: Enter the physical parameters of the device.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
pDeviceConfigpointer to NAND_DeviceConfigTypeDef structure
Return values
HALstatus

Definition at line 406 of file stm32l4xx_hal_nand.c.

407 {
408  hnand->Config.PageSize = pDeviceConfig->PageSize;
409  hnand->Config.SpareAreaSize = pDeviceConfig->SpareAreaSize;
410  hnand->Config.BlockSize = pDeviceConfig->BlockSize;
411  hnand->Config.BlockNbr = pDeviceConfig->BlockNbr;
412  hnand->Config.PlaneSize = pDeviceConfig->PlaneSize;
413  hnand->Config.PlaneNbr = pDeviceConfig->PlaneNbr;
414  hnand->Config.ExtraCommandEnable = pDeviceConfig->ExtraCommandEnable;
415 
416  return HAL_OK;
417 }
NAND_DeviceConfigTypeDef Config
return HAL_OK
FunctionalState ExtraCommandEnable

◆ HAL_NAND_DeInit()

HAL_StatusTypeDef HAL_NAND_DeInit ( NAND_HandleTypeDef hnand)

Perform NAND memory De-Initialization sequence.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
Return values
HALstatus

Definition at line 160 of file stm32l4xx_hal_nand.c.

161 {
162  /* Initialize the low level hardware (MSP) */
163  HAL_NAND_MspDeInit(hnand);
164 
165  /* Configure the NAND registers with their reset values */
166  FMC_NAND_DeInit(hnand->Instance, hnand->Init.NandBank);
167 
168  /* Reset the NAND controller state */
169  hnand->State = HAL_NAND_STATE_RESET;
170 
171  /* Release Lock */
172  __HAL_UNLOCK(hnand);
173 
174  return HAL_OK;
175 }
__IO HAL_NAND_StateTypeDef State
__HAL_UNLOCK(hrtc)
void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand)
DeInitialize the NAND MSP.
FMC_NAND_InitTypeDef Init
return HAL_OK
FMC_NAND_TypeDef * Instance
HAL_StatusTypeDef FMC_NAND_DeInit(FMC_NAND_TypeDef *Device, uint32_t Bank)
DeInitializes the FMC_NAND device.

◆ HAL_NAND_Init()

HAL_StatusTypeDef HAL_NAND_Init ( NAND_HandleTypeDef hnand,
FMC_NAND_PCC_TimingTypeDef ComSpace_Timing,
FMC_NAND_PCC_TimingTypeDef AttSpace_Timing 
)

Perform NAND memory Initialization sequence.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
ComSpace_Timingpointer to Common space timing structure
AttSpace_Timingpointer to Attribute space timing structure
Return values
HALstatus

Definition at line 120 of file stm32l4xx_hal_nand.c.

121 {
122  /* Check the NAND handle state */
123  if(hnand == NULL)
124  {
125  return HAL_ERROR;
126  }
127 
128  if(hnand->State == HAL_NAND_STATE_RESET)
129  {
130  /* Allocate lock resource and initialize it */
131  hnand->Lock = HAL_UNLOCKED;
132  /* Initialize the low level hardware (MSP) */
133  HAL_NAND_MspInit(hnand);
134  }
135 
136  /* Initialize NAND control Interface */
137  FMC_NAND_Init(hnand->Instance, &(hnand->Init));
138 
139  /* Initialize NAND common space timing Interface */
140  FMC_NAND_CommonSpace_Timing_Init(hnand->Instance, ComSpace_Timing, hnand->Init.NandBank);
141 
142  /* Initialize NAND attribute space timing Interface */
143  FMC_NAND_AttributeSpace_Timing_Init(hnand->Instance, AttSpace_Timing, hnand->Init.NandBank);
144 
145  /* Enable the NAND device */
146  __FMC_NAND_ENABLE(hnand->Instance);
147 
148  /* Update the NAND controller state */
149  hnand->State = HAL_NAND_STATE_READY;
150 
151  return HAL_OK;
152 }
__IO HAL_NAND_StateTypeDef State
HAL_LockTypeDef Lock
void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand)
Initialize the NAND MSP.
HAL_StatusTypeDef FMC_NAND_AttributeSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
Initializes the FMC_NAND Attribute space Timing according to the specified parameters in the FMC_NAND...
HAL_StatusTypeDef FMC_NAND_CommonSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
Initializes the FMC_NAND Common space Timing according to the specified parameters in the FMC_NAND_PC...
HAL_StatusTypeDef FMC_NAND_Init(FMC_NAND_TypeDef *Device, FMC_NAND_InitTypeDef *Init)
Initializes the FMC_NAND device according to the specified control parameters in the FMC_NAND_HandleT...
FMC_NAND_InitTypeDef Init
return HAL_OK
FMC_NAND_TypeDef * Instance

◆ HAL_NAND_IRQHandler()

void HAL_NAND_IRQHandler ( NAND_HandleTypeDef hnand)

This function handles NAND device interrupt request.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
Return values
HALstatus

Definition at line 216 of file stm32l4xx_hal_nand.c.

217 {
218  /* Check NAND interrupt Rising edge flag */
219  if(__FMC_NAND_GET_FLAG(hnand->Instance, hnand->Init.NandBank, FMC_FLAG_RISING_EDGE))
220  {
221  /* NAND interrupt callback*/
222  HAL_NAND_ITCallback(hnand);
223 
224  /* Clear NAND interrupt Rising edge pending bit */
225  __FMC_NAND_CLEAR_FLAG(hnand->Instance, FMC_FLAG_RISING_EDGE);
226  }
227 
228  /* Check NAND interrupt Level flag */
229  if(__FMC_NAND_GET_FLAG(hnand->Instance, hnand->Init.NandBank, FMC_FLAG_LEVEL))
230  {
231  /* NAND interrupt callback*/
232  HAL_NAND_ITCallback(hnand);
233 
234  /* Clear NAND interrupt Level pending bit */
235  __FMC_NAND_CLEAR_FLAG(hnand->Instance, FMC_FLAG_LEVEL);
236  }
237 
238  /* Check NAND interrupt Falling edge flag */
239  if(__FMC_NAND_GET_FLAG(hnand->Instance, hnand->Init.NandBank, FMC_FLAG_FALLING_EDGE))
240  {
241  /* NAND interrupt callback*/
242  HAL_NAND_ITCallback(hnand);
243 
244  /* Clear NAND interrupt Falling edge pending bit */
245  __FMC_NAND_CLEAR_FLAG(hnand->Instance, FMC_FLAG_FALLING_EDGE);
246  }
247 
248  /* Check NAND interrupt FIFO empty flag */
249  if(__FMC_NAND_GET_FLAG(hnand->Instance, hnand->Init.NandBank, FMC_FLAG_FEMPT))
250  {
251  /* NAND interrupt callback*/
252  HAL_NAND_ITCallback(hnand);
253 
254  /* Clear NAND interrupt FIFO empty pending bit */
255  __FMC_NAND_CLEAR_FLAG(hnand->Instance, FMC_FLAG_FEMPT);
256  }
257 
258 }
FMC_NAND_InitTypeDef Init
FMC_NAND_TypeDef * Instance
void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand)
NAND interrupt feature callback.

◆ HAL_NAND_ITCallback()

__weak void HAL_NAND_ITCallback ( NAND_HandleTypeDef hnand)

NAND interrupt feature callback.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
Return values
None

Definition at line 266 of file stm32l4xx_hal_nand.c.

267 {
268  /* Prevent unused argument(s) compilation warning */
269  UNUSED(hnand);
270 
271  /* NOTE : This function should not be modified, when the callback is needed,
272  the HAL_NAND_ITCallback could be implemented in the user file
273  */
274 }

◆ HAL_NAND_MspDeInit()

__weak void HAL_NAND_MspDeInit ( NAND_HandleTypeDef hnand)

DeInitialize the NAND MSP.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
Return values
None

Definition at line 199 of file stm32l4xx_hal_nand.c.

200 {
201  /* Prevent unused argument(s) compilation warning */
202  UNUSED(hnand);
203 
204  /* NOTE : This function should not be modified, when the callback is needed,
205  the HAL_NAND_MspDeInit could be implemented in the user file
206  */
207 }

◆ HAL_NAND_MspInit()

__weak void HAL_NAND_MspInit ( NAND_HandleTypeDef hnand)

Initialize the NAND MSP.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
Return values
None

Definition at line 183 of file stm32l4xx_hal_nand.c.

184 {
185  /* Prevent unused argument(s) compilation warning */
186  UNUSED(hnand);
187 
188  /* NOTE : This function should not be modified, when the callback is needed,
189  the HAL_NAND_MspInit could be implemented in the user file
190  */
191 }

◆ HAL_NAND_Read_ID()

HAL_StatusTypeDef HAL_NAND_Read_ID ( NAND_HandleTypeDef hnand,
NAND_IDTypeDef pNAND_ID 
)

Read the NAND memory electronic signature.

Parameters
hnandpointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module.
pNAND_IDNAND ID structure
Return values
HALstatus

Definition at line 302 of file stm32l4xx_hal_nand.c.

303 {
304  __IO uint32_t data = 0;
305  __IO uint32_t data1 = 0;
306  uint32_t deviceAddress = 0;
307 
308  /* Process Locked */
309  __HAL_LOCK(hnand);
310 
311  /* Check the NAND controller state */
312  if(hnand->State == HAL_NAND_STATE_BUSY)
313  {
314  return HAL_BUSY;
315  }
316 
317  /* Identify the device address */
318  deviceAddress = NAND_DEVICE;
319 
320  /* Update the NAND controller state */
321  hnand->State = HAL_NAND_STATE_BUSY;
322 
323  /* Send Read ID command sequence */
324  *(__IO uint8_t *)((uint32_t)(deviceAddress | CMD_AREA)) = NAND_CMD_READID;
325  __DSB();
326  *(__IO uint8_t *)((uint32_t)(deviceAddress | ADDR_AREA)) = 0x00;
327  __DSB();
328 
329  /* Read the electronic signature from NAND flash */
330  if (hnand->Init.MemoryDataWidth == FMC_NAND_MEM_BUS_WIDTH_8)
331  {
332  data = *(__IO uint32_t *)deviceAddress;
333 
334  /* Return the data read */
335  pNAND_ID->Maker_Id = ADDR_1ST_CYCLE(data);
336  pNAND_ID->Device_Id = ADDR_2ND_CYCLE(data);
337  pNAND_ID->Third_Id = ADDR_3RD_CYCLE(data);
338  pNAND_ID->Fourth_Id = ADDR_4TH_CYCLE(data);
339  }
340  else
341  {
342  data = *(__IO uint32_t *)deviceAddress;
343  data1 = *((__IO uint32_t *)deviceAddress + 4);
344 
345  /* Return the data read */
346  pNAND_ID->Maker_Id = ADDR_1ST_CYCLE(data);
347  pNAND_ID->Device_Id = ADDR_3RD_CYCLE(data);
348  pNAND_ID->Third_Id = ADDR_1ST_CYCLE(data1);
349  pNAND_ID->Fourth_Id = ADDR_3RD_CYCLE(data1);
350  }
351 
352  /* Update the NAND controller state */
353  hnand->State = HAL_NAND_STATE_READY;
354 
355  /* Process unlocked */
356  __HAL_UNLOCK(hnand);
357 
358  return HAL_OK;
359 }
__IO HAL_NAND_StateTypeDef State
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
FMC_NAND_InitTypeDef Init
return HAL_OK