void SaveAppConfig(const APP_CONFIG *ptrAppConfig) { NVM_VALIDATION_STRUCT NVMValidationStruct; // Ensure adequate space has been reserved in non-volatile storage to // store the entire AppConfig structure. If you get stuck in this while(1) // trap, it means you have a design time misconfiguration in TCPIPConfig.h. // You must increase MPFS_RESERVE_BLOCK to allocate more space. #if defined(STACK_USE_MPFS2) if (sizeof (NVMValidationStruct) + sizeof (AppConfig) > MPFS_RESERVE_BLOCK) while (1); #endif // Get proper values for the validation structure indicating that we can use // these EEPROM/Flash contents on future boot ups NVMValidationStruct.wOriginalChecksum = wOriginalAppConfigChecksum; NVMValidationStruct.wCurrentChecksum = CalcIPChecksum((BYTE*) ptrAppConfig, sizeof (APP_CONFIG)); NVMValidationStruct.wConfigurationLength = sizeof (APP_CONFIG); // Write the validation struct and current AppConfig contents to EEPROM/Flash #if defined(EEPROM_CS_TRIS) XEEBeginWrite(0x0000); XEEWriteArray((BYTE*) & NVMValidationStruct, sizeof (NVMValidationStruct)); XEEWriteArray((BYTE*) ptrAppConfig, sizeof (APP_CONFIG)); #else SPIFlashBeginWrite(0x0000); SPIFlashWriteArray((BYTE*) & NVMValidationStruct, sizeof (NVMValidationStruct)); SPIFlashWriteArray((BYTE*) ptrAppConfig, sizeof (APP_CONFIG)); #endif }
/* ********************************************* #define WIFI_STORAGET_PARTITION_SIZE (140) This setting "WIFI_STORAGET_PARTITION_SIZE" is the memory size for WiFi setting. ***************************************************/ void WiFi_WriteConfigToMemory(void) { #if defined(MEDIA_STORAGE_EEPROM) XEEBeginWrite(0); XEEWriteArray((uint8_t*)p_wifi_ConfigData, sizeof(DRV_WIFI_CONFIG_DATA)); #endif }
void WiFi_EraseConfigFromMemory(void) { DRV_WIFI_CONFIG_DATA tmp_wifi_ConfigData; memset(&tmp_wifi_ConfigData,0x00,sizeof(DRV_WIFI_CONFIG_DATA)); #if defined(MEDIA_STORAGE_EEPROM) XEEBeginWrite(0); XEEWriteArray((uint8_t*)&tmp_wifi_ConfigData, sizeof(DRV_WIFI_CONFIG_DATA)); #endif }
void WX_writePerm_data(void) { unsigned short loc = sizeof (NVM_VALIDATION_STRUCT) + sizeof (APP_CONFIG); if (loc + sizeof (WX) >= MPFS_RESERVE_BLOCK) { putrsUART((ROM char*) "MPFS_RESERVE_BLOCK too small!"); while (1); } XEEBeginWrite(loc); XEEWriteArray((BYTE *) & WX, sizeof (WX)); XEEEndWrite(); }
void SaveAppConfig(void) { // Ensure adequate space has been reserved in non-volatile storage to // store the entire AppConfig structure. If you get stuck in this while(1) // trap, it means you have a design time misconfiguration in TCPIPConfig.h. // You must increase MPFS_RESERVE_BLOCK to allocate more space. #if defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2) if(sizeof(AppConfig) > MPFS_RESERVE_BLOCK) while(1); #endif #if defined(EEPROM_CS_TRIS) XEEBeginWrite(0x0000); XEEWrite(0x60); XEEWriteArray((BYTE*)&AppConfig, sizeof(AppConfig)); #else SPIFlashBeginWrite(0x0000); SPIFlashWrite(0x60); SPIFlashWriteArray((BYTE*)&AppConfig, sizeof(AppConfig)); #endif }