70 #if defined(FMC_BANK1) 76 #ifdef HAL_NOR_MODULE_ENABLED 91 #define NOR_CMD_ADDRESS_FIRST (uint16_t)0x0555 92 #define NOR_CMD_ADDRESS_FIRST_CFI (uint16_t)0x0055 93 #define NOR_CMD_ADDRESS_SECOND (uint16_t)0x02AA 94 #define NOR_CMD_ADDRESS_THIRD (uint16_t)0x0555 95 #define NOR_CMD_ADDRESS_FOURTH (uint16_t)0x0555 96 #define NOR_CMD_ADDRESS_FIFTH (uint16_t)0x02AA 97 #define NOR_CMD_ADDRESS_SIXTH (uint16_t)0x0555 100 #define NOR_CMD_DATA_READ_RESET (uint16_t)0x00F0 101 #define NOR_CMD_DATA_FIRST (uint16_t)0x00AA 102 #define NOR_CMD_DATA_SECOND (uint16_t)0x0055 103 #define NOR_CMD_DATA_AUTO_SELECT (uint16_t)0x0090 104 #define NOR_CMD_DATA_PROGRAM (uint16_t)0x00A0 105 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD (uint16_t)0x0080 106 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH (uint16_t)0x00AA 107 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH (uint16_t)0x0055 108 #define NOR_CMD_DATA_CHIP_ERASE (uint16_t)0x0010 109 #define NOR_CMD_DATA_CFI (uint16_t)0x0098 111 #define NOR_CMD_DATA_BUFFER_AND_PROG (uint8_t)0x25 112 #define NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM (uint8_t)0x29 113 #define NOR_CMD_DATA_BLOCK_ERASE (uint8_t)0x30 116 #define NOR_MASK_STATUS_DQ5 (uint16_t)0x0020 117 #define NOR_MASK_STATUS_DQ6 (uint16_t)0x0040 172 if(hnor->
State == HAL_NOR_STATE_RESET)
203 hnor->
State = HAL_NOR_STATE_READY;
223 hnor->
State = HAL_NOR_STATE_RESET;
308 uint32_t deviceaddress = 0;
314 if(hnor->
State == HAL_NOR_STATE_BUSY)
322 deviceaddress = NOR_MEMORY_ADRESS1;
324 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
326 deviceaddress = NOR_MEMORY_ADRESS2;
328 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
330 deviceaddress = NOR_MEMORY_ADRESS3;
334 deviceaddress = NOR_MEMORY_ADRESS4;
338 hnor->
State = HAL_NOR_STATE_BUSY;
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);
352 hnor->
State = HAL_NOR_STATE_READY;
368 uint32_t deviceaddress = 0;
374 if(hnor->
State == HAL_NOR_STATE_BUSY)
382 deviceaddress = NOR_MEMORY_ADRESS1;
384 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
386 deviceaddress = NOR_MEMORY_ADRESS2;
388 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
390 deviceaddress = NOR_MEMORY_ADRESS3;
394 deviceaddress = NOR_MEMORY_ADRESS4;
397 NOR_WRITE(deviceaddress, NOR_CMD_DATA_READ_RESET);
400 hnor->
State = HAL_NOR_STATE_READY;
418 uint32_t deviceaddress = 0;
424 if(hnor->
State == HAL_NOR_STATE_BUSY)
432 deviceaddress = NOR_MEMORY_ADRESS1;
434 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
436 deviceaddress = NOR_MEMORY_ADRESS2;
438 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
440 deviceaddress = NOR_MEMORY_ADRESS3;
444 deviceaddress = NOR_MEMORY_ADRESS4;
448 hnor->
State = HAL_NOR_STATE_BUSY;
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);
456 *pData = *(__IO uint32_t *)(uint32_t)pAddress;
459 hnor->
State = HAL_NOR_STATE_READY;
477 uint32_t deviceaddress = 0;
483 if(hnor->
State == HAL_NOR_STATE_BUSY)
491 deviceaddress = NOR_MEMORY_ADRESS1;
493 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
495 deviceaddress = NOR_MEMORY_ADRESS2;
497 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
499 deviceaddress = NOR_MEMORY_ADRESS3;
503 deviceaddress = NOR_MEMORY_ADRESS4;
507 hnor->
State = HAL_NOR_STATE_BUSY;
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);
515 NOR_WRITE(pAddress, *pData);
518 hnor->
State = HAL_NOR_STATE_READY;
537 uint32_t deviceaddress = 0;
543 if(hnor->
State == HAL_NOR_STATE_BUSY)
551 deviceaddress = NOR_MEMORY_ADRESS1;
553 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
555 deviceaddress = NOR_MEMORY_ADRESS2;
557 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
559 deviceaddress = NOR_MEMORY_ADRESS3;
563 deviceaddress = NOR_MEMORY_ADRESS4;
567 hnor->
State = HAL_NOR_STATE_BUSY;
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);
575 while( uwBufferSize > 0)
577 *pData++ = *(__IO uint16_t *)uwAddress;
583 hnor->
State = HAL_NOR_STATE_READY;
602 uint16_t * p_currentaddress = (uint16_t *)NULL;
603 uint16_t * p_endaddress = (uint16_t *)NULL;
604 uint32_t lastloadedaddress = 0, deviceaddress = 0;
610 if(hnor->
State == HAL_NOR_STATE_BUSY)
618 deviceaddress = NOR_MEMORY_ADRESS1;
620 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
622 deviceaddress = NOR_MEMORY_ADRESS2;
624 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
626 deviceaddress = NOR_MEMORY_ADRESS3;
630 deviceaddress = NOR_MEMORY_ADRESS4;
634 hnor->
State = HAL_NOR_STATE_BUSY;
637 p_currentaddress = (uint16_t*)((uint32_t)(uwAddress));
638 p_endaddress = p_currentaddress + (uwBufferSize-1);
639 lastloadedaddress = (uint32_t)(uwAddress);
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);
646 NOR_WRITE((uint32_t)(p_currentaddress), NOR_CMD_DATA_BUFFER_AND_PROG);
647 NOR_WRITE((uint32_t)(p_currentaddress), (uwBufferSize-1));
650 while(p_currentaddress <= p_endaddress)
653 lastloadedaddress = (uint32_t)p_currentaddress;
655 NOR_WRITE(p_currentaddress, *pData++);
660 NOR_WRITE((uint32_t)(lastloadedaddress), NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM);
663 hnor->
State = HAL_NOR_STATE_READY;
682 uint32_t deviceaddress = 0;
688 if(hnor->
State == HAL_NOR_STATE_BUSY)
696 deviceaddress = NOR_MEMORY_ADRESS1;
698 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
700 deviceaddress = NOR_MEMORY_ADRESS2;
702 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
704 deviceaddress = NOR_MEMORY_ADRESS3;
708 deviceaddress = NOR_MEMORY_ADRESS4;
712 hnor->
State = HAL_NOR_STATE_BUSY;
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);
723 hnor->
State = HAL_NOR_STATE_READY;
741 uint32_t deviceaddress = 0;
750 if(hnor->
State == HAL_NOR_STATE_BUSY)
758 deviceaddress = NOR_MEMORY_ADRESS1;
760 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
762 deviceaddress = NOR_MEMORY_ADRESS2;
764 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
766 deviceaddress = NOR_MEMORY_ADRESS3;
770 deviceaddress = NOR_MEMORY_ADRESS4;
774 hnor->
State = HAL_NOR_STATE_BUSY;
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);
785 hnor->
State = HAL_NOR_STATE_READY;
802 uint32_t deviceaddress = 0;
808 if(hnor->
State == HAL_NOR_STATE_BUSY)
816 deviceaddress = NOR_MEMORY_ADRESS1;
818 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK2)
820 deviceaddress = NOR_MEMORY_ADRESS2;
822 else if (hnor->
Init.
NSBank == FMC_NORSRAM_BANK3)
824 deviceaddress = NOR_MEMORY_ADRESS3;
828 deviceaddress = NOR_MEMORY_ADRESS4;
832 hnor->
State = HAL_NOR_STATE_BUSY;
835 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress,
uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_CFI), NOR_CMD_DATA_CFI);
844 hnor->
State = HAL_NOR_STATE_READY;
886 hnor->
State = HAL_NOR_STATE_READY;
906 hnor->
State = HAL_NOR_STATE_BUSY;
912 hnor->
State = HAL_NOR_STATE_PROTECTED;
963 uint16_t tmpSR1 = 0, tmpSR2 = 0;
964 uint32_t tickstart = 0;
976 if(Timeout != HAL_MAX_DELAY)
978 if((Timeout == 0)||((
HAL_GetTick() - tickstart ) > Timeout))
985 tmpSR1 = *(__IO uint16_t *)Address;
986 tmpSR2 = *(__IO uint16_t *)Address;
989 if ((tmpSR1 & NOR_MASK_STATUS_DQ6) == (tmpSR2 & NOR_MASK_STATUS_DQ6))
994 if((tmpSR1 & NOR_MASK_STATUS_DQ5) != NOR_MASK_STATUS_DQ5)
999 tmpSR1 = *(__IO uint16_t *)Address;
1000 tmpSR2 = *(__IO uint16_t *)Address;
1003 if ((tmpSR1 & NOR_MASK_STATUS_DQ6) == (tmpSR2 & NOR_MASK_STATUS_DQ6))
1007 if ((tmpSR1 & NOR_MASK_STATUS_DQ5) == NOR_MASK_STATUS_DQ5)
HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor)
Perform NOR memory De-Initialization sequence.
FMC_NORSRAM_TypeDef * Instance
static uint32_t uwNORMemoryDataWidth
void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout)
NOR MSP Wait for Ready/Busy signal.
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address)
Erase the specified block of the NOR memory.
HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout)
Return the NOR operation status.
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
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 memor...
HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)
Perform the NOR memory Initialization sequence.
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.
HAL_StatusTypeDef FMC_NORSRAM_DeInit(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
DeInitialize the FMC_NORSRAM peripheral.
uint16_t Manufacturer_Code
FMC_NORSRAM_EXTENDED_TypeDef * Extended
HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor)
Enable dynamically NOR write operation.
HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID)
Read NOR flash IDs.
HAL_NOR_StatusTypeDef
FMC NOR Status typedef.
HAL_StatusTypeDef FMC_NORSRAM_Extended_Timing_Init(FMC_NORSRAM_EXTENDED_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode)
Initialize the FMC_NORSRAM Extended mode Timing according to the specified parameters in the FMC_NORS...
FMC_NORSRAM_InitTypeDef Init
HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address)
Erase the entire NOR chip.
FMC NORSRAM Timing parameters structure definition.
HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_InitTypeDef *Init)
Initialize the FMC_NORSRAM device according to the specified control parameters in the FMC_NORSRAM_In...
HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor)
Return the NOR memory to Read mode.
HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
Program data to NOR memory.
HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank)
Disables dynamically FMC_NORSRAM write operation.
HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor)
Disable dynamically NOR write operation.
HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI)
Read NOR flash CFI IDs.
HAL_StatusTypeDef FMC_NORSRAM_Timing_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank)
Initialize the FMC_NORSRAM Timing according to the specified parameters in the FMC_NORSRAM_TimingType...
HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Enable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank)
Enables dynamically FMC_NORSRAM write operation.
void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor)
DeInitialize the NOR MSP.
HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor)
Return the NOR controller state.
void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor)
Initialize the NOR MSP.
__IO HAL_NOR_StateTypeDef State
HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
Read data from NOR memory.
NOR handle Structure definition.