STM32L4xx_HAL_Driver  1.14.0
Input and Output functions

Input Output and memory control functions. More...

Functions

HAL_StatusTypeDef HAL_NOR_Read_ID (NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID)
 Read NOR flash IDs. More...
 
HAL_StatusTypeDef HAL_NOR_ReturnToReadMode (NOR_HandleTypeDef *hnor)
 Return the NOR memory to Read mode. More...
 
HAL_StatusTypeDef HAL_NOR_Read (NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
 Read data from NOR memory. More...
 
HAL_StatusTypeDef HAL_NOR_Program (NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
 Program data to NOR memory. More...
 
HAL_StatusTypeDef HAL_NOR_ReadBuffer (NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)
 Read a half-word buffer from the NOR memory. More...
 
HAL_StatusTypeDef HAL_NOR_ProgramBuffer (NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)
 Writes a half-word buffer to the NOR memory. This function must be used only with S29GL128P NOR memory. More...
 
HAL_StatusTypeDef HAL_NOR_Erase_Block (NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address)
 Erase the specified block of the NOR memory. More...
 
HAL_StatusTypeDef HAL_NOR_Erase_Chip (NOR_HandleTypeDef *hnor, uint32_t Address)
 Erase the entire NOR chip. More...
 
HAL_StatusTypeDef HAL_NOR_Read_CFI (NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI)
 Read NOR flash CFI IDs. More...
 

Detailed Description

Input Output and memory control functions.

  ==============================================================================
                ##### NOR Input and Output functions #####
  ==============================================================================
  [..]
    This section provides functions allowing to use and control the NOR memory

Function Documentation

◆ HAL_NOR_Erase_Block()

HAL_StatusTypeDef HAL_NOR_Erase_Block ( NOR_HandleTypeDef hnor,
uint32_t  BlockAddress,
uint32_t  Address 
)

Erase the specified block of the NOR memory.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
BlockAddressBlock to erase address
AddressDevice address
Return values
HALstatus

Definition at line 680 of file stm32l4xx_hal_nor.c.

681 {
682  uint32_t deviceaddress = 0;
683 
684  /* Process Locked */
685  __HAL_LOCK(hnor);
686 
687  /* Check the NOR controller state */
688  if(hnor->State == HAL_NOR_STATE_BUSY)
689  {
690  return HAL_BUSY;
691  }
692 
693  /* Select the NOR device address */
694  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
695  {
696  deviceaddress = NOR_MEMORY_ADRESS1;
697  }
698  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
699  {
700  deviceaddress = NOR_MEMORY_ADRESS2;
701  }
702  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
703  {
704  deviceaddress = NOR_MEMORY_ADRESS3;
705  }
706  else /* FMC_NORSRAM_BANK4 */
707  {
708  deviceaddress = NOR_MEMORY_ADRESS4;
709  }
710 
711  /* Update the NOR controller state */
712  hnor->State = HAL_NOR_STATE_BUSY;
713 
714  /* Send block erase command sequence */
715  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
716  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
717  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);
718  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FOURTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH);
719  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIFTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH);
720  NOR_WRITE((uint32_t)(BlockAddress + Address), NOR_CMD_DATA_BLOCK_ERASE);
721 
722  /* Check the NOR memory status and update the controller state */
723  hnor->State = HAL_NOR_STATE_READY;
724 
725  /* Process unlocked */
726  __HAL_UNLOCK(hnor);
727 
728  return HAL_OK;
729 
730 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_Erase_Chip()

HAL_StatusTypeDef HAL_NOR_Erase_Chip ( NOR_HandleTypeDef hnor,
uint32_t  Address 
)

Erase the entire NOR chip.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
AddressDevice address
Return values
HALstatus

Definition at line 739 of file stm32l4xx_hal_nor.c.

740 {
741  uint32_t deviceaddress = 0;
742 
743  /* Prevent unused argument(s) compilation warning */
744  UNUSED(Address);
745 
746  /* Process Locked */
747  __HAL_LOCK(hnor);
748 
749  /* Check the NOR controller state */
750  if(hnor->State == HAL_NOR_STATE_BUSY)
751  {
752  return HAL_BUSY;
753  }
754 
755  /* Select the NOR device address */
756  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
757  {
758  deviceaddress = NOR_MEMORY_ADRESS1;
759  }
760  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
761  {
762  deviceaddress = NOR_MEMORY_ADRESS2;
763  }
764  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
765  {
766  deviceaddress = NOR_MEMORY_ADRESS3;
767  }
768  else /* FMC_NORSRAM_BANK4 */
769  {
770  deviceaddress = NOR_MEMORY_ADRESS4;
771  }
772 
773  /* Update the NOR controller state */
774  hnor->State = HAL_NOR_STATE_BUSY;
775 
776  /* Send NOR chip erase command sequence */
777  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
778  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
779  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);
780  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FOURTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH);
781  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIFTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH);
782  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SIXTH), NOR_CMD_DATA_CHIP_ERASE);
783 
784  /* Check the NOR memory status and update the controller state */
785  hnor->State = HAL_NOR_STATE_READY;
786 
787  /* Process unlocked */
788  __HAL_UNLOCK(hnor);
789 
790  return HAL_OK;
791 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_Program()

HAL_StatusTypeDef HAL_NOR_Program ( NOR_HandleTypeDef hnor,
uint32_t *  pAddress,
uint16_t *  pData 
)

Program data to NOR memory.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
pAddressDevice address
pDatapointer to the data to write
Return values
HALstatus

Definition at line 475 of file stm32l4xx_hal_nor.c.

476 {
477  uint32_t deviceaddress = 0;
478 
479  /* Process Locked */
480  __HAL_LOCK(hnor);
481 
482  /* Check the NOR controller state */
483  if(hnor->State == HAL_NOR_STATE_BUSY)
484  {
485  return HAL_BUSY;
486  }
487 
488  /* Select the NOR device address */
489  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
490  {
491  deviceaddress = NOR_MEMORY_ADRESS1;
492  }
493  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
494  {
495  deviceaddress = NOR_MEMORY_ADRESS2;
496  }
497  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
498  {
499  deviceaddress = NOR_MEMORY_ADRESS3;
500  }
501  else /* FMC_NORSRAM_BANK4 */
502  {
503  deviceaddress = NOR_MEMORY_ADRESS4;
504  }
505 
506  /* Update the NOR controller state */
507  hnor->State = HAL_NOR_STATE_BUSY;
508 
509  /* Send program data command */
510  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
511  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
512  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_PROGRAM);
513 
514  /* Write the data */
515  NOR_WRITE(pAddress, *pData);
516 
517  /* Check the NOR controller state */
518  hnor->State = HAL_NOR_STATE_READY;
519 
520  /* Process unlocked */
521  __HAL_UNLOCK(hnor);
522 
523  return HAL_OK;
524 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_ProgramBuffer()

HAL_StatusTypeDef HAL_NOR_ProgramBuffer ( NOR_HandleTypeDef hnor,
uint32_t  uwAddress,
uint16_t *  pData,
uint32_t  uwBufferSize 
)

Writes a half-word buffer to the NOR memory. This function must be used only with S29GL128P NOR memory.

Parameters
hnorpointer to the NOR handle
uwAddressNOR memory internal start write address
pDatapointer to source data buffer.
uwBufferSizeSize of the buffer to write
Return values
HALstatus

Definition at line 600 of file stm32l4xx_hal_nor.c.

601 {
602  uint16_t * p_currentaddress = (uint16_t *)NULL;
603  uint16_t * p_endaddress = (uint16_t *)NULL;
604  uint32_t lastloadedaddress = 0, deviceaddress = 0;
605 
606  /* Process Locked */
607  __HAL_LOCK(hnor);
608 
609  /* Check the NOR controller state */
610  if(hnor->State == HAL_NOR_STATE_BUSY)
611  {
612  return HAL_BUSY;
613  }
614 
615  /* Select the NOR device address */
616  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
617  {
618  deviceaddress = NOR_MEMORY_ADRESS1;
619  }
620  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
621  {
622  deviceaddress = NOR_MEMORY_ADRESS2;
623  }
624  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
625  {
626  deviceaddress = NOR_MEMORY_ADRESS3;
627  }
628  else /* FMC_NORSRAM_BANK4 */
629  {
630  deviceaddress = NOR_MEMORY_ADRESS4;
631  }
632 
633  /* Update the NOR controller state */
634  hnor->State = HAL_NOR_STATE_BUSY;
635 
636  /* Initialize variables */
637  p_currentaddress = (uint16_t*)((uint32_t)(uwAddress));
638  p_endaddress = p_currentaddress + (uwBufferSize-1);
639  lastloadedaddress = (uint32_t)(uwAddress);
640 
641  /* Issue unlock command sequence */
642  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
643  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
644 
645  /* Write Buffer Load Command */
646  NOR_WRITE((uint32_t)(p_currentaddress), NOR_CMD_DATA_BUFFER_AND_PROG);
647  NOR_WRITE((uint32_t)(p_currentaddress), (uwBufferSize-1));
648 
649  /* Load Data into NOR Buffer */
650  while(p_currentaddress <= p_endaddress)
651  {
652  /* Store last loaded address & data value (for polling) */
653  lastloadedaddress = (uint32_t)p_currentaddress;
654 
655  NOR_WRITE(p_currentaddress, *pData++);
656 
657  p_currentaddress++;
658  }
659 
660  NOR_WRITE((uint32_t)(lastloadedaddress), NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM);
661 
662  /* Check the NOR controller state */
663  hnor->State = HAL_NOR_STATE_READY;
664 
665  /* Process unlocked */
666  __HAL_UNLOCK(hnor);
667 
668  return HAL_OK;
669 
670 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_Read()

HAL_StatusTypeDef HAL_NOR_Read ( NOR_HandleTypeDef hnor,
uint32_t *  pAddress,
uint16_t *  pData 
)

Read data from NOR memory.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
pAddresspointer to Device address
pDatapointer to read data
Return values
HALstatus

Definition at line 416 of file stm32l4xx_hal_nor.c.

417 {
418  uint32_t deviceaddress = 0;
419 
420  /* Process Locked */
421  __HAL_LOCK(hnor);
422 
423  /* Check the NOR controller state */
424  if(hnor->State == HAL_NOR_STATE_BUSY)
425  {
426  return HAL_BUSY;
427  }
428 
429  /* Select the NOR device address */
430  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
431  {
432  deviceaddress = NOR_MEMORY_ADRESS1;
433  }
434  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
435  {
436  deviceaddress = NOR_MEMORY_ADRESS2;
437  }
438  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
439  {
440  deviceaddress = NOR_MEMORY_ADRESS3;
441  }
442  else /* FMC_NORSRAM_BANK4 */
443  {
444  deviceaddress = NOR_MEMORY_ADRESS4;
445  }
446 
447  /* Update the NOR controller state */
448  hnor->State = HAL_NOR_STATE_BUSY;
449 
450  /* Send read data command */
451  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
452  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
453  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_READ_RESET);
454 
455  /* Read the data */
456  *pData = *(__IO uint32_t *)(uint32_t)pAddress;
457 
458  /* Check the NOR controller state */
459  hnor->State = HAL_NOR_STATE_READY;
460 
461  /* Process unlocked */
462  __HAL_UNLOCK(hnor);
463 
464  return HAL_OK;
465 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_Read_CFI()

HAL_StatusTypeDef HAL_NOR_Read_CFI ( NOR_HandleTypeDef hnor,
NOR_CFITypeDef pNOR_CFI 
)

Read NOR flash CFI IDs.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
pNOR_CFIpointer to NOR CFI IDs structure
Return values
HALstatus

Definition at line 800 of file stm32l4xx_hal_nor.c.

801 {
802  uint32_t deviceaddress = 0;
803 
804  /* Process Locked */
805  __HAL_LOCK(hnor);
806 
807  /* Check the NOR controller state */
808  if(hnor->State == HAL_NOR_STATE_BUSY)
809  {
810  return HAL_BUSY;
811  }
812 
813  /* Select the NOR device address */
814  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
815  {
816  deviceaddress = NOR_MEMORY_ADRESS1;
817  }
818  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
819  {
820  deviceaddress = NOR_MEMORY_ADRESS2;
821  }
822  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
823  {
824  deviceaddress = NOR_MEMORY_ADRESS3;
825  }
826  else /* FMC_NORSRAM_BANK4 */
827  {
828  deviceaddress = NOR_MEMORY_ADRESS4;
829  }
830 
831  /* Update the NOR controller state */
832  hnor->State = HAL_NOR_STATE_BUSY;
833 
834  /* Send read CFI query command */
835  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_CFI), NOR_CMD_DATA_CFI);
836 
837  /* read the NOR CFI information */
838  pNOR_CFI->CFI_1 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI1_ADDRESS);
839  pNOR_CFI->CFI_2 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI2_ADDRESS);
840  pNOR_CFI->CFI_3 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI3_ADDRESS);
841  pNOR_CFI->CFI_4 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI4_ADDRESS);
842 
843  /* Check the NOR controller state */
844  hnor->State = HAL_NOR_STATE_READY;
845 
846  /* Process unlocked */
847  __HAL_UNLOCK(hnor);
848 
849  return HAL_OK;
850 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_Read_ID()

HAL_StatusTypeDef HAL_NOR_Read_ID ( NOR_HandleTypeDef hnor,
NOR_IDTypeDef pNOR_ID 
)

Read NOR flash IDs.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
pNOR_IDpointer to NOR ID structure
Return values
HALstatus

Definition at line 306 of file stm32l4xx_hal_nor.c.

307 {
308  uint32_t deviceaddress = 0;
309 
310  /* Process Locked */
311  __HAL_LOCK(hnor);
312 
313  /* Check the NOR controller state */
314  if(hnor->State == HAL_NOR_STATE_BUSY)
315  {
316  return HAL_BUSY;
317  }
318 
319  /* Select the NOR device address */
320  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
321  {
322  deviceaddress = NOR_MEMORY_ADRESS1;
323  }
324  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
325  {
326  deviceaddress = NOR_MEMORY_ADRESS2;
327  }
328  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
329  {
330  deviceaddress = NOR_MEMORY_ADRESS3;
331  }
332  else /* FMC_NORSRAM_BANK4 */
333  {
334  deviceaddress = NOR_MEMORY_ADRESS4;
335  }
336 
337  /* Update the NOR controller state */
338  hnor->State = HAL_NOR_STATE_BUSY;
339 
340  /* Send read ID command */
341  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
342  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
343  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_AUTO_SELECT);
344 
345  /* Read the NOR IDs */
346  pNOR_ID->Manufacturer_Code = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, MC_ADDRESS);
347  pNOR_ID->Device_Code1 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, DEVICE_CODE1_ADDR);
348  pNOR_ID->Device_Code2 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, DEVICE_CODE2_ADDR);
349  pNOR_ID->Device_Code3 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, DEVICE_CODE3_ADDR);
350 
351  /* Check the NOR controller state */
352  hnor->State = HAL_NOR_STATE_READY;
353 
354  /* Process unlocked */
355  __HAL_UNLOCK(hnor);
356 
357  return HAL_OK;
358 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
uint16_t Device_Code1
__HAL_LOCK(hrtc)
uint16_t Manufacturer_Code
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
uint16_t Device_Code3
uint16_t Device_Code2
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_ReadBuffer()

HAL_StatusTypeDef HAL_NOR_ReadBuffer ( NOR_HandleTypeDef hnor,
uint32_t  uwAddress,
uint16_t *  pData,
uint32_t  uwBufferSize 
)

Read a half-word buffer from the NOR memory.

Parameters
hnorpointer to the NOR handle
uwAddressNOR memory internal address to read from.
pDatapointer to the buffer that receives the data read from the NOR memory.
uwBufferSizenumber of Half word to read.
Return values
HALstatus

Definition at line 535 of file stm32l4xx_hal_nor.c.

536 {
537  uint32_t deviceaddress = 0;
538 
539  /* Process Locked */
540  __HAL_LOCK(hnor);
541 
542  /* Check the NOR controller state */
543  if(hnor->State == HAL_NOR_STATE_BUSY)
544  {
545  return HAL_BUSY;
546  }
547 
548  /* Select the NOR device address */
549  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
550  {
551  deviceaddress = NOR_MEMORY_ADRESS1;
552  }
553  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
554  {
555  deviceaddress = NOR_MEMORY_ADRESS2;
556  }
557  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
558  {
559  deviceaddress = NOR_MEMORY_ADRESS3;
560  }
561  else /* FMC_NORSRAM_BANK4 */
562  {
563  deviceaddress = NOR_MEMORY_ADRESS4;
564  }
565 
566  /* Update the NOR controller state */
567  hnor->State = HAL_NOR_STATE_BUSY;
568 
569  /* Send read data command */
570  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
571  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
572  NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_READ_RESET);
573 
574  /* Read buffer */
575  while( uwBufferSize > 0)
576  {
577  *pData++ = *(__IO uint16_t *)uwAddress;
578  uwAddress += 2;
579  uwBufferSize--;
580  }
581 
582  /* Check the NOR controller state */
583  hnor->State = HAL_NOR_STATE_READY;
584 
585  /* Process unlocked */
586  __HAL_UNLOCK(hnor);
587 
588  return HAL_OK;
589 }
static uint32_t uwNORMemoryDataWidth
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State

◆ HAL_NOR_ReturnToReadMode()

HAL_StatusTypeDef HAL_NOR_ReturnToReadMode ( NOR_HandleTypeDef hnor)

Return the NOR memory to Read mode.

Parameters
hnorpointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module.
Return values
HALstatus

Definition at line 366 of file stm32l4xx_hal_nor.c.

367 {
368  uint32_t deviceaddress = 0;
369 
370  /* Process Locked */
371  __HAL_LOCK(hnor);
372 
373  /* Check the NOR controller state */
374  if(hnor->State == HAL_NOR_STATE_BUSY)
375  {
376  return HAL_BUSY;
377  }
378 
379  /* Select the NOR device address */
380  if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
381  {
382  deviceaddress = NOR_MEMORY_ADRESS1;
383  }
384  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
385  {
386  deviceaddress = NOR_MEMORY_ADRESS2;
387  }
388  else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
389  {
390  deviceaddress = NOR_MEMORY_ADRESS3;
391  }
392  else /* FMC_NORSRAM_BANK4 */
393  {
394  deviceaddress = NOR_MEMORY_ADRESS4;
395  }
396 
397  NOR_WRITE(deviceaddress, NOR_CMD_DATA_READ_RESET);
398 
399  /* Check the NOR controller state */
400  hnor->State = HAL_NOR_STATE_READY;
401 
402  /* Process unlocked */
403  __HAL_UNLOCK(hnor);
404 
405  return HAL_OK;
406 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
FMC_NORSRAM_InitTypeDef Init
__IO HAL_NOR_StateTypeDef State