1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Added LogFS support for OPLinkMini with internal flash

This commit is contained in:
Alessio Morale 2013-05-07 01:29:30 +02:00
parent 8d57d8ff76
commit 07af6b5c80
3 changed files with 27 additions and 30 deletions

View File

@ -471,38 +471,41 @@ static void ProcessInputStream(UAVTalkConnection connectionHandle, uint8_t rxbyt
switch (obj_per.Operation) { switch (obj_per.Operation) {
case OBJECTPERSISTENCE_OPERATION_LOAD: case OBJECTPERSISTENCE_OPERATION_LOAD:
{ {
#if defined(PIOS_INCLUDE_FLASH_EEPROM) #if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
// Load the settings. // Load the settings.
OPLinkSettingsData oplinkSettings; void *obj = UAVObjGetByID(obj_per.ObjectID);
if (PIOS_EEPROM_Load((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData)) == 0) if (obj == 0) {
OPLinkSettingsSet(&oplinkSettings);
else
success = false; success = false;
} else {
// Load selected instance
success = (UAVObjLoad(obj, obj_per.InstanceID) == 0);
}
#endif #endif
break; break;
} }
case OBJECTPERSISTENCE_OPERATION_SAVE: case OBJECTPERSISTENCE_OPERATION_SAVE:
{ {
#if defined(PIOS_INCLUDE_FLASH_EEPROM) #if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
// Save the settings. void *obj = UAVObjGetByID(obj_per.ObjectID);
OPLinkSettingsData oplinkSettings; if (obj == 0) {
OPLinkSettingsGet(&oplinkSettings);
int32_t ret = PIOS_EEPROM_Save((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData));
if (ret != 0)
success = false; success = false;
} else {
// Save selected instance
success = UAVObjSave(obj, obj_per.InstanceID) == 0;
}
#endif #endif
break; break;
} }
case OBJECTPERSISTENCE_OPERATION_DELETE: case OBJECTPERSISTENCE_OPERATION_DELETE:
{ {
#if defined(PIOS_INCLUDE_FLASH_EEPROM) #if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
// Erase the settings. void *obj = UAVObjGetByID(obj_per.ObjectID);
OPLinkSettingsData oplinkSettings; if (obj == 0) {
uint8_t *ptr = (uint8_t*)&oplinkSettings;
memset(ptr, 0, sizeof(OPLinkSettingsData));
int32_t ret = PIOS_EEPROM_Save(ptr, sizeof(OPLinkSettingsData));
if (ret != 0)
success = false; success = false;
} else {
// Save selected instance
success = UAVObjDelete(obj, obj_per.InstanceID) == 0;
}
#endif #endif
break; break;
} }

View File

@ -109,7 +109,7 @@
#define PIOS_INCLUDE_FLASH_INTERNAL #define PIOS_INCLUDE_FLASH_INTERNAL
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
/* #define FLASH_FREERTOS */ /* #define FLASH_FREERTOS */
#define PIOS_INCLUDE_FLASH_EEPROM //#define PIOS_INCLUDE_FLASH_EEPROM
/* PIOS radio modules */ /* PIOS radio modules */
#define PIOS_INCLUDE_RFM22B #define PIOS_INCLUDE_RFM22B

View File

@ -117,8 +117,6 @@ void PIOS_Board_Init(void) {
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */
OPLinkSettingsData oplinkSettings; OPLinkSettingsData oplinkSettings;
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
PIOS_EEPROM_Init(&pios_eeprom_cfg);
/* IAP System Setup */ /* IAP System Setup */
PIOS_IAP_Init(); PIOS_IAP_Init();
@ -128,7 +126,8 @@ void PIOS_Board_Init(void) {
PIOS_IAP_ReadBootCmd(2) == PIOS_IAP_CLEAR_FLASH_CMD_2) { PIOS_IAP_ReadBootCmd(2) == PIOS_IAP_CLEAR_FLASH_CMD_2) {
OPLinkSettingsGet(&oplinkSettings); OPLinkSettingsGet(&oplinkSettings);
OPLinkSettingsSetDefaults(&oplinkSettings,0); OPLinkSettingsSetDefaults(&oplinkSettings,0);
PIOS_EEPROM_Save((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData)); OPLinkSettingsSet(&oplinkSettings);
//PIOS_EEPROM_Save((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData));
for (uint32_t i = 0; i < 10; i++) { for (uint32_t i = 0; i < 10; i++) {
PIOS_DELAY_WaitmS(100); PIOS_DELAY_WaitmS(100);
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
@ -137,15 +136,10 @@ void PIOS_Board_Init(void) {
PIOS_IAP_WriteBootCmd(1,0); PIOS_IAP_WriteBootCmd(1,0);
PIOS_IAP_WriteBootCmd(2,0); PIOS_IAP_WriteBootCmd(2,0);
} }
/* Read the settings from flash. */
/* NOTE: We probably need to save/restore the objID here incase the object changed but the size doesn't */
if (PIOS_EEPROM_Load((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData)) == 0)
OPLinkSettingsSet(&oplinkSettings);
else
OPLinkSettingsGet(&oplinkSettings); OPLinkSettingsGet(&oplinkSettings);
#else //#else
OPLinkSettingsGet(&oplinkSettings); // OPLinkSettingsGet(&oplinkSettings);
#endif /* PIOS_INCLUDE_FLASH_EEPROM */ //#endif /* PIOS_INCLUDE_FLASH_EEPROM */
/* Initialize the task monitor library */ /* Initialize the task monitor library */
TaskMonitorInitialize(); TaskMonitorInitialize();