1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Make saving occur within the system thread instead of the event system thread

This commit is contained in:
James Cotton 2012-07-22 23:03:27 -05:00
parent 4e42fb564e
commit 66191c4d01

View File

@ -73,6 +73,7 @@
static uint32_t idleCounter; static uint32_t idleCounter;
static uint32_t idleCounterClear; static uint32_t idleCounterClear;
static xTaskHandle systemTaskHandle; static xTaskHandle systemTaskHandle;
static xQueueHandle objectPersistenceQueue;
static bool stackOverflow; static bool stackOverflow;
static bool mallocFailed; static bool mallocFailed;
@ -124,6 +125,8 @@ int32_t SystemModInitialize(void)
SystemModStart(); SystemModStart();
objectPersistenceQueue = xQueueCreate(1, sizeof(UAVObjEvent));
return 0; return 0;
} }
@ -133,8 +136,6 @@ MODULE_INITCALL(SystemModInitialize, 0)
*/ */
static void systemTask(void *parameters) static void systemTask(void *parameters)
{ {
portTickType lastSysTime;
/* create all modules thread */ /* create all modules thread */
MODULE_TASKCREATE_ALL; MODULE_TASKCREATE_ALL;
@ -154,10 +155,9 @@ static void systemTask(void *parameters)
// Initialize vars // Initialize vars
idleCounter = 0; idleCounter = 0;
idleCounterClear = 0; idleCounterClear = 0;
lastSysTime = xTaskGetTickCount();
// Listen for SettingPersistance object updates, connect a callback function // Listen for SettingPersistance object updates, connect a callback function
ObjectPersistenceConnectCallback(&objectUpdatedCb); ObjectPersistenceConnectQueue(objectPersistenceQueue);
// Main system loop // Main system loop
while (1) { while (1) {
@ -193,11 +193,14 @@ static void systemTask(void *parameters)
FlightStatusData flightStatus; FlightStatusData flightStatus;
FlightStatusGet(&flightStatus); FlightStatusGet(&flightStatus);
// Wait until next period UAVObjEvent ev;
if(flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMED) { int delayTime = flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMED ?
vTaskDelayUntil(&lastSysTime, SYSTEM_UPDATE_PERIOD_MS / portTICK_RATE_MS / (LED_BLINK_RATE_HZ * 2) ); SYSTEM_UPDATE_PERIOD_MS / portTICK_RATE_MS / (LED_BLINK_RATE_HZ * 2) :
} else { SYSTEM_UPDATE_PERIOD_MS / portTICK_RATE_MS;
vTaskDelayUntil(&lastSysTime, SYSTEM_UPDATE_PERIOD_MS / portTICK_RATE_MS);
if(xQueueReceive(objectPersistenceQueue, &ev, delayTime) == pdTRUE) {
// If object persistence is updated call the callback
objectUpdatedCb(&ev);
} }
} }
} }