mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Added LogFS support for OPLinkMini with internal flash
This commit is contained in:
parent
8d57d8ff76
commit
07af6b5c80
@ -471,38 +471,41 @@ static void ProcessInputStream(UAVTalkConnection connectionHandle, uint8_t rxbyt
|
||||
switch (obj_per.Operation) {
|
||||
case OBJECTPERSISTENCE_OPERATION_LOAD:
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
|
||||
// Load the settings.
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
if (PIOS_EEPROM_Load((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData)) == 0)
|
||||
OPLinkSettingsSet(&oplinkSettings);
|
||||
else
|
||||
void *obj = UAVObjGetByID(obj_per.ObjectID);
|
||||
if (obj == 0) {
|
||||
success = false;
|
||||
} else {
|
||||
// Load selected instance
|
||||
success = (UAVObjLoad(obj, obj_per.InstanceID) == 0);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case OBJECTPERSISTENCE_OPERATION_SAVE:
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
// Save the settings.
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
int32_t ret = PIOS_EEPROM_Save((uint8_t*)&oplinkSettings, sizeof(OPLinkSettingsData));
|
||||
if (ret != 0)
|
||||
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
|
||||
void *obj = UAVObjGetByID(obj_per.ObjectID);
|
||||
if (obj == 0) {
|
||||
success = false;
|
||||
} else {
|
||||
// Save selected instance
|
||||
success = UAVObjSave(obj, obj_per.InstanceID) == 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case OBJECTPERSISTENCE_OPERATION_DELETE:
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
// Erase the settings.
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
uint8_t *ptr = (uint8_t*)&oplinkSettings;
|
||||
memset(ptr, 0, sizeof(OPLinkSettingsData));
|
||||
int32_t ret = PIOS_EEPROM_Save(ptr, sizeof(OPLinkSettingsData));
|
||||
if (ret != 0)
|
||||
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
|
||||
void *obj = UAVObjGetByID(obj_per.ObjectID);
|
||||
if (obj == 0) {
|
||||
success = false;
|
||||
} else {
|
||||
// Save selected instance
|
||||
success = UAVObjDelete(obj, obj_per.InstanceID) == 0;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@
|
||||
#define PIOS_INCLUDE_FLASH_INTERNAL
|
||||
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
||||
/* #define FLASH_FREERTOS */
|
||||
#define PIOS_INCLUDE_FLASH_EEPROM
|
||||
//#define PIOS_INCLUDE_FLASH_EEPROM
|
||||
|
||||
/* PIOS radio modules */
|
||||
#define PIOS_INCLUDE_RFM22B
|
||||
|
@ -117,8 +117,6 @@ void PIOS_Board_Init(void) {
|
||||
#endif /* PIOS_INCLUDE_LED */
|
||||
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
PIOS_EEPROM_Init(&pios_eeprom_cfg);
|
||||
|
||||
/* IAP System Setup */
|
||||
PIOS_IAP_Init();
|
||||
@ -128,7 +126,8 @@ void PIOS_Board_Init(void) {
|
||||
PIOS_IAP_ReadBootCmd(2) == PIOS_IAP_CLEAR_FLASH_CMD_2) {
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
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++) {
|
||||
PIOS_DELAY_WaitmS(100);
|
||||
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
|
||||
@ -137,15 +136,10 @@ void PIOS_Board_Init(void) {
|
||||
PIOS_IAP_WriteBootCmd(1,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);
|
||||
#else
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
#endif /* PIOS_INCLUDE_FLASH_EEPROM */
|
||||
//#else
|
||||
// OPLinkSettingsGet(&oplinkSettings);
|
||||
//#endif /* PIOS_INCLUDE_FLASH_EEPROM */
|
||||
|
||||
/* Initialize the task monitor library */
|
||||
TaskMonitorInitialize();
|
||||
|
Loading…
Reference in New Issue
Block a user