109 #if defined(FMC_Bank1) || defined(FSMC_Bank1)
115 #ifdef HAL_NOR_MODULE_ENABLED
130 #define NOR_CMD_ADDRESS_FIRST_BYTE (uint16_t)0x0AAA
131 #define NOR_CMD_ADDRESS_FIRST_CFI_BYTE (uint16_t)0x00AA
132 #define NOR_CMD_ADDRESS_SECOND_BYTE (uint16_t)0x0555
133 #define NOR_CMD_ADDRESS_THIRD_BYTE (uint16_t)0x0AAA
135 #define NOR_CMD_ADDRESS_FIRST (uint16_t)0x0555
136 #define NOR_CMD_ADDRESS_FIRST_CFI (uint16_t)0x0055
137 #define NOR_CMD_ADDRESS_SECOND (uint16_t)0x02AA
138 #define NOR_CMD_ADDRESS_THIRD (uint16_t)0x0555
139 #define NOR_CMD_ADDRESS_FOURTH (uint16_t)0x0555
140 #define NOR_CMD_ADDRESS_FIFTH (uint16_t)0x02AA
141 #define NOR_CMD_ADDRESS_SIXTH (uint16_t)0x0555
144 #define NOR_CMD_DATA_READ_RESET (uint16_t)0x00F0
145 #define NOR_CMD_DATA_FIRST (uint16_t)0x00AA
146 #define NOR_CMD_DATA_SECOND (uint16_t)0x0055
147 #define NOR_CMD_DATA_AUTO_SELECT (uint16_t)0x0090
148 #define NOR_CMD_DATA_PROGRAM (uint16_t)0x00A0
149 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD (uint16_t)0x0080
150 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH (uint16_t)0x00AA
151 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH (uint16_t)0x0055
152 #define NOR_CMD_DATA_CHIP_ERASE (uint16_t)0x0010
153 #define NOR_CMD_DATA_CFI (uint16_t)0x0098
155 #define NOR_CMD_DATA_BUFFER_AND_PROG (uint8_t)0x25
156 #define NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM (uint8_t)0x29
157 #define NOR_CMD_DATA_BLOCK_ERASE (uint8_t)0x30
159 #define NOR_CMD_READ_ARRAY (uint16_t)0x00FF
160 #define NOR_CMD_WORD_PROGRAM (uint16_t)0x0040
161 #define NOR_CMD_BUFFERED_PROGRAM (uint16_t)0x00E8
162 #define NOR_CMD_CONFIRM (uint16_t)0x00D0
163 #define NOR_CMD_BLOCK_ERASE (uint16_t)0x0020
164 #define NOR_CMD_BLOCK_UNLOCK (uint16_t)0x0060
165 #define NOR_CMD_READ_STATUS_REG (uint16_t)0x0070
166 #define NOR_CMD_CLEAR_STATUS_REG (uint16_t)0x0050
169 #define NOR_MASK_STATUS_DQ4 (uint16_t)0x0010
170 #define NOR_MASK_STATUS_DQ5 (uint16_t)0x0020
171 #define NOR_MASK_STATUS_DQ6 (uint16_t)0x0040
172 #define NOR_MASK_STATUS_DQ7 (uint16_t)0x0080
175 #define NOR_ADDRESS_COMMAND_SET (uint16_t)0x0013
178 #define NOR_INTEL_SHARP_EXT_COMMAND_SET (uint16_t)0x0001
179 #define NOR_AMD_FUJITSU_COMMAND_SET (uint16_t)0x0002
180 #define NOR_INTEL_STANDARD_COMMAND_SET (uint16_t)0x0003
181 #define NOR_AMD_FUJITSU_EXT_COMMAND_SET (uint16_t)0x0004
182 #define NOR_WINDBOND_STANDARD_COMMAND_SET (uint16_t)0x0006
183 #define NOR_MITSUBISHI_STANDARD_COMMAND_SET (uint16_t)0x0100
184 #define NOR_MITSUBISHI_EXT_COMMAND_SET (uint16_t)0x0101
185 #define NOR_PAGE_WRITE_COMMAND_SET (uint16_t)0x0102
186 #define NOR_INTEL_PERFORMANCE_COMMAND_SET (uint16_t)0x0200
187 #define NOR_INTEL_DATA_COMMAND_SET (uint16_t)0x0210
199 static uint32_t uwNORMemoryDataWidth = NOR_MEMORY_8B;
237 uint32_t deviceaddress;
238 HAL_StatusTypeDef status = HAL_OK;
249 hnor->Lock = HAL_UNLOCKED;
251 #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1)
252 if (hnor->MspInitCallback == NULL)
258 hnor->MspInitCallback(hnor);
273 hnor->Init.NSBank, hnor->Init.ExtendedMode);
276 __FMC_NORSRAM_ENABLE(hnor->Instance, hnor->Init.NSBank);
279 if (hnor->Init.MemoryDataWidth == FMC_NORSRAM_MEM_BUS_WIDTH_8)
281 uwNORMemoryDataWidth = NOR_MEMORY_8B;
285 uwNORMemoryDataWidth = NOR_MEMORY_16B;
292 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
294 deviceaddress = NOR_MEMORY_ADRESS1;
296 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
298 deviceaddress = NOR_MEMORY_ADRESS2;
300 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
302 deviceaddress = NOR_MEMORY_ADRESS3;
306 deviceaddress = NOR_MEMORY_ADRESS4;
309 if (hnor->Init.WriteOperation == FMC_WRITE_OPERATION_DISABLE)
319 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
321 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_CFI_BYTE),
326 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_CFI), NOR_CMD_DATA_CFI);
329 hnor->CommandSet = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_ADDRESS_COMMAND_SET);
345 #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1)
346 if (hnor->MspDeInitCallback == NULL)
352 hnor->MspDeInitCallback(hnor);
447 uint32_t deviceaddress;
449 HAL_StatusTypeDef status = HAL_OK;
470 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
472 deviceaddress = NOR_MEMORY_ADRESS1;
474 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
476 deviceaddress = NOR_MEMORY_ADRESS2;
478 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
480 deviceaddress = NOR_MEMORY_ADRESS3;
484 deviceaddress = NOR_MEMORY_ADRESS4;
488 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
490 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
492 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
494 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
495 NOR_CMD_DATA_SECOND);
496 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD_BYTE),
497 NOR_CMD_DATA_AUTO_SELECT);
501 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
502 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
503 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD),
504 NOR_CMD_DATA_AUTO_SELECT);
507 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
509 NOR_WRITE(deviceaddress, NOR_CMD_DATA_AUTO_SELECT);
517 if (status != HAL_ERROR)
520 pNOR_ID->
Manufacturer_Code = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, MC_ADDRESS);
521 pNOR_ID->Device_Code1 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth,
523 pNOR_ID->Device_Code2 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth,
525 pNOR_ID->
Device_Code3 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth,
551 uint32_t deviceaddress;
553 HAL_StatusTypeDef status = HAL_OK;
574 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
576 deviceaddress = NOR_MEMORY_ADRESS1;
578 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
580 deviceaddress = NOR_MEMORY_ADRESS2;
582 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
584 deviceaddress = NOR_MEMORY_ADRESS3;
588 deviceaddress = NOR_MEMORY_ADRESS4;
591 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
593 NOR_WRITE(deviceaddress, NOR_CMD_DATA_READ_RESET);
595 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
597 NOR_WRITE(deviceaddress, NOR_CMD_READ_ARRAY);
629 uint32_t deviceaddress;
631 HAL_StatusTypeDef status = HAL_OK;
652 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
654 deviceaddress = NOR_MEMORY_ADRESS1;
656 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
658 deviceaddress = NOR_MEMORY_ADRESS2;
660 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
662 deviceaddress = NOR_MEMORY_ADRESS3;
666 deviceaddress = NOR_MEMORY_ADRESS4;
670 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
672 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
674 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
676 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
677 NOR_CMD_DATA_SECOND);
678 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD_BYTE),
679 NOR_CMD_DATA_READ_RESET);
683 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
684 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
685 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD),
686 NOR_CMD_DATA_READ_RESET);
689 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
691 NOR_WRITE(pAddress, NOR_CMD_READ_ARRAY);
699 if (status != HAL_ERROR)
702 *pData = (uint16_t)(*(__IO uint32_t *)pAddress);
729 uint32_t deviceaddress;
730 HAL_StatusTypeDef status = HAL_OK;
746 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
748 deviceaddress = NOR_MEMORY_ADRESS1;
750 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
752 deviceaddress = NOR_MEMORY_ADRESS2;
754 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
756 deviceaddress = NOR_MEMORY_ADRESS3;
760 deviceaddress = NOR_MEMORY_ADRESS4;
764 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
766 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
768 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
770 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
771 NOR_CMD_DATA_SECOND);
772 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD_BYTE),
773 NOR_CMD_DATA_PROGRAM);
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_PROGRAM);
782 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
784 NOR_WRITE(pAddress, NOR_CMD_WORD_PROGRAM);
792 if (status != HAL_ERROR)
795 NOR_WRITE(pAddress, *pData);
822 uint32_t uwBufferSize)
824 uint32_t deviceaddress;
825 uint32_t size = uwBufferSize;
826 uint32_t address = uwAddress;
827 uint16_t *data = pData;
829 HAL_StatusTypeDef status = HAL_OK;
850 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
852 deviceaddress = NOR_MEMORY_ADRESS1;
854 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
856 deviceaddress = NOR_MEMORY_ADRESS2;
858 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
860 deviceaddress = NOR_MEMORY_ADRESS3;
864 deviceaddress = NOR_MEMORY_ADRESS4;
868 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
870 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
872 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
874 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
875 NOR_CMD_DATA_SECOND);
876 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD_BYTE),
877 NOR_CMD_DATA_READ_RESET);
881 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
882 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
883 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD),
884 NOR_CMD_DATA_READ_RESET);
887 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
889 NOR_WRITE(deviceaddress, NOR_CMD_READ_ARRAY);
897 if (status != HAL_ERROR)
902 *data = *(__IO uint16_t *)address;
933 uint32_t uwBufferSize)
935 uint16_t *p_currentaddress;
936 const uint16_t *p_endaddress;
937 uint16_t *data = pData;
938 uint32_t deviceaddress;
939 HAL_StatusTypeDef status = HAL_OK;
955 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
957 deviceaddress = NOR_MEMORY_ADRESS1;
959 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
961 deviceaddress = NOR_MEMORY_ADRESS2;
963 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
965 deviceaddress = NOR_MEMORY_ADRESS3;
969 deviceaddress = NOR_MEMORY_ADRESS4;
973 p_currentaddress = (uint16_t *)(deviceaddress + uwAddress);
974 p_endaddress = (uint16_t *)(deviceaddress + uwAddress + (2U * (uwBufferSize - 1U)));
976 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
978 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
981 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
983 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
984 NOR_CMD_DATA_SECOND);
989 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
990 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
993 NOR_WRITE((deviceaddress + uwAddress), NOR_CMD_DATA_BUFFER_AND_PROG);
994 NOR_WRITE((deviceaddress + uwAddress), (uint16_t)(uwBufferSize - 1U));
996 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
999 NOR_WRITE((deviceaddress + uwAddress), NOR_CMD_BUFFERED_PROGRAM);
1000 NOR_WRITE((deviceaddress + uwAddress), (uint16_t)(uwBufferSize - 1U));
1008 if (status != HAL_ERROR)
1011 while (p_currentaddress <= p_endaddress)
1013 NOR_WRITE(p_currentaddress, *data);
1016 p_currentaddress ++;
1019 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
1021 NOR_WRITE((deviceaddress + uwAddress), NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM);
1025 NOR_WRITE((deviceaddress + uwAddress), NOR_CMD_CONFIRM);
1054 uint32_t deviceaddress;
1055 HAL_StatusTypeDef status = HAL_OK;
1071 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
1073 deviceaddress = NOR_MEMORY_ADRESS1;
1075 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
1077 deviceaddress = NOR_MEMORY_ADRESS2;
1079 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
1081 deviceaddress = NOR_MEMORY_ADRESS3;
1085 deviceaddress = NOR_MEMORY_ADRESS4;
1089 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
1091 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
1093 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
1094 NOR_CMD_DATA_FIRST);
1095 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
1096 NOR_CMD_DATA_SECOND);
1097 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD_BYTE),
1098 NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);
1102 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
1103 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
1104 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD),
1105 NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);
1106 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FOURTH),
1107 NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH);
1108 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIFTH),
1109 NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH);
1111 NOR_WRITE((uint32_t)(BlockAddress + Address), NOR_CMD_DATA_BLOCK_ERASE);
1113 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
1115 NOR_WRITE((BlockAddress + Address), NOR_CMD_BLOCK_UNLOCK);
1116 NOR_WRITE((BlockAddress + Address), NOR_CMD_CONFIRM);
1117 NOR_WRITE((BlockAddress + Address), NOR_CMD_BLOCK_ERASE);
1118 NOR_WRITE((BlockAddress + Address), NOR_CMD_CONFIRM);
1150 uint32_t deviceaddress;
1151 HAL_StatusTypeDef status = HAL_OK;
1168 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
1170 deviceaddress = NOR_MEMORY_ADRESS1;
1172 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
1174 deviceaddress = NOR_MEMORY_ADRESS2;
1176 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
1178 deviceaddress = NOR_MEMORY_ADRESS3;
1182 deviceaddress = NOR_MEMORY_ADRESS4;
1186 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
1188 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
1190 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_BYTE),
1191 NOR_CMD_DATA_FIRST);
1192 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND_BYTE),
1193 NOR_CMD_DATA_SECOND);
1194 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD_BYTE),
1195 NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);
1199 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);
1200 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);
1201 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_THIRD),
1202 NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);
1203 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FOURTH),
1204 NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH);
1205 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIFTH),
1206 NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH);
1207 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_SIXTH),
1208 NOR_CMD_DATA_CHIP_ERASE);
1240 uint32_t deviceaddress;
1244 state = hnor->State;
1262 if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)
1264 deviceaddress = NOR_MEMORY_ADRESS1;
1266 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)
1268 deviceaddress = NOR_MEMORY_ADRESS2;
1270 else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)
1272 deviceaddress = NOR_MEMORY_ADRESS3;
1276 deviceaddress = NOR_MEMORY_ADRESS4;
1280 if (uwNORMemoryDataWidth == NOR_MEMORY_8B)
1282 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_CFI_BYTE),
1287 NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, NOR_CMD_ADDRESS_FIRST_CFI), NOR_CMD_DATA_CFI);
1290 pNOR_CFI->
CFI_1 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI1_ADDRESS);
1291 pNOR_CFI->CFI_2 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI2_ADDRESS);
1292 pNOR_CFI->CFI_3 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI3_ADDRESS);
1293 pNOR_CFI->CFI_4 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, uwNORMemoryDataWidth, CFI4_ADDRESS);
1296 hnor->State = state;
1309 #if (USE_HAL_NOR_REGISTER_CALLBACKS == 1)
1324 HAL_StatusTypeDef status = HAL_OK;
1327 if (pCallback == NULL)
1332 state = hnor->State;
1338 hnor->MspInitCallback = pCallback;
1341 hnor->MspDeInitCallback = pCallback;
1370 HAL_StatusTypeDef status = HAL_OK;
1373 state = hnor->State;
1541 if (hnor->CommandSet == NOR_AMD_FUJITSU_COMMAND_SET)
1543 while ((status != HAL_NOR_STATUS_SUCCESS) && (status != HAL_NOR_STATUS_TIMEOUT))
1546 if (Timeout != HAL_MAX_DELAY)
1548 if (((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1550 status = HAL_NOR_STATUS_TIMEOUT;
1555 tmpsr1 = *(__IO uint16_t *)Address;
1556 tmpsr2 = *(__IO uint16_t *)Address;
1559 if ((tmpsr1 & NOR_MASK_STATUS_DQ6) == (tmpsr2 & NOR_MASK_STATUS_DQ6))
1561 return HAL_NOR_STATUS_SUCCESS ;
1564 if ((tmpsr1 & NOR_MASK_STATUS_DQ5) == NOR_MASK_STATUS_DQ5)
1566 status = HAL_NOR_STATUS_ONGOING;
1569 tmpsr1 = *(__IO uint16_t *)Address;
1570 tmpsr2 = *(__IO uint16_t *)Address;
1573 if ((tmpsr1 & NOR_MASK_STATUS_DQ6) == (tmpsr2 & NOR_MASK_STATUS_DQ6))
1575 return HAL_NOR_STATUS_SUCCESS;
1577 if ((tmpsr1 & NOR_MASK_STATUS_DQ5) == NOR_MASK_STATUS_DQ5)
1579 return HAL_NOR_STATUS_ERROR;
1583 else if (hnor->CommandSet == NOR_INTEL_SHARP_EXT_COMMAND_SET)
1587 NOR_WRITE(Address, NOR_CMD_READ_STATUS_REG);
1588 tmpsr2 = *(__IO uint16_t *)(Address);
1591 if (Timeout != HAL_MAX_DELAY)
1593 if (((
HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1595 return HAL_NOR_STATUS_TIMEOUT;
1598 }
while ((tmpsr2 & NOR_MASK_STATUS_DQ7) == 0U);
1600 NOR_WRITE(Address, NOR_CMD_READ_STATUS_REG);
1601 tmpsr1 = *(__IO uint16_t *)(Address);
1602 if ((tmpsr1 & (NOR_MASK_STATUS_DQ5 | NOR_MASK_STATUS_DQ4)) != 0U)
1605 NOR_WRITE(Address, NOR_CMD_READ_STATUS_REG);
1606 status = HAL_NOR_STATUS_ERROR;
1610 status = HAL_NOR_STATUS_SUCCESS;
1616 status = HAL_NOR_STATUS_ERROR;
FMC NORSRAM Timing parameters structure definition.
HAL_StatusTypeDef FMC_NORSRAM_DeInit(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
DeInitialize the FMC_NORSRAM peripheral.
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 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_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...
HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank)
Disables dynamically FMC_NORSRAM write operation.
HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Enable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank)
Enables dynamically FMC_NORSRAM write operation.
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor)
Perform NOR memory De-Initialization sequence.
void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor)
NOR MSP Init.
HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)
Perform the NOR memory Initialization sequence.
void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor)
NOR MSP DeInit.
void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout)
NOR MSP Wait for Ready/Busy signal.
HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
Read data from NOR memory.
HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address)
Erase the specified block of the NOR memory.
HAL_StatusTypeDef HAL_NOR_UnRegisterCallback(NOR_HandleTypeDef *hnor, HAL_NOR_CallbackIDTypeDef CallbackId)
Unregister a User NOR Callback NOR Callback is redirected to the weak predefined callback.
HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)
Reads a half-word buffer from the NOR memory.
HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)
Program data to NOR memory.
HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor)
Returns the NOR memory to Read mode.
HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI)
Read NOR flash CFI IDs.
HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID)
Read NOR flash IDs.
HAL_StatusTypeDef HAL_NOR_RegisterCallback(NOR_HandleTypeDef *hnor, HAL_NOR_CallbackIDTypeDef CallbackId, pNOR_CallbackTypeDef pCallback)
Register a User NOR Callback To be used to override the weak predefined callback.
HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address)
Erase the entire NOR chip.
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_WriteOperation_Disable(NOR_HandleTypeDef *hnor)
Disables dynamically NOR write operation.
HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor)
Enables dynamically NOR write operation.
HAL_NOR_StateTypeDef HAL_NOR_GetState(const NOR_HandleTypeDef *hnor)
return the NOR controller state
HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout)
Returns the NOR operation status.
uint16_t Manufacturer_Code
struct __NOR_HandleTypeDef else typedef struct endif NOR_HandleTypeDef
NOR handle Structure definition.
void(* pNOR_CallbackTypeDef)(NOR_HandleTypeDef *hnor)
HAL NOR Callback pointer definition.
HAL_NOR_CallbackIDTypeDef
HAL NOR Callback ID enumeration definition.
HAL_NOR_StateTypeDef
HAL SRAM State structures definition.
HAL_NOR_StatusTypeDef
FMC NOR Status typedef.
@ HAL_NOR_MSP_DEINIT_CB_ID
@ HAL_NOR_STATE_PROTECTED
This file contains all the functions prototypes for the HAL module driver.