MyFLASH_Ptr = FLASH1_Init(NULL); /* Initialization of FLASH1 component */
Error = FLASH1_Write(MyFLASH_Ptr, Data, MY_FLASH_LOCATION, sizeof(Data)); /* Start writing to the flash memory */
/* Here some other application code can be placed */
while (!DataWritten标志寄存器) { /* Wait until the data are written */
FLASH1_Main(MyFLASH_Ptr); /* Run the main method */
}
DataWritten标志寄存器 = FALSE;
if (FLASH1_GetOperationStatus(MyFLASH_Ptr) == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
Error = FLASH1_Read(MyFLASH_Ptr, MY_FLASH_LOCATION, Buffer, sizeof(Buffer)); /* Start reading from the flash memory */
do {
FLASH1_Main(MyFLASH_Ptr);
OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);
} while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
if (OpStatus == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
MyFLASH_Ptr = FLASH1_Init(NULL); /* Initialization of FLASH1 component */
Error = FLASH1_Write(MyFLASH_Ptr, Data, MY_FLASH_LOCATION, sizeof(Data)); /* Start writing to the flash memory */
while (!DataWritten标志寄存器) { /* Wait until the data are written */
FLASH1_Main(MyFLASH_Ptr); /* Run the main method */
}
DataWritten标志寄存器 = FALSE;
if (FLASH1_GetOperationStatus(MyFLASH_Ptr) == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
Error = FLASH1_Read(MyFLASH_Ptr, MY_FLASH_LOCATION, Buffer, sizeof(Buffer)); /* Start reading from the flash memory */
do {
FLASH1_Main(MyFLASH_Ptr);
OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);
}while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
if (OpStatus == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
while(1);