diff --git a/flight/modules/gpsp/gpsdsysmod.c b/flight/modules/gpsp/gpsdsysmod.c index 1586f1964..bd7443bdc 100644 --- a/flight/modules/gpsp/gpsdsysmod.c +++ b/flight/modules/gpsp/gpsdsysmod.c @@ -44,6 +44,7 @@ #include "inc/gps9flashhandler.h" #include "inc/gps9protocol.h" #include "pios_board_info.h" +#include "pios_board_init.h" extern uint32_t pios_com_main_id; @@ -107,9 +108,17 @@ static void gpspSystemTask(__attribute__((unused)) void *parameters) #ifdef PIOS_INCLUDE_WDG PIOS_WDG_UpdateFlag(PIOS_WDG_SYSTEM); #endif + + /* board driver init */ + PIOS_Board_Init(); + + /* Initialize all modules */ + MODULE_INITIALISE_ALL; + while (!initTaskDone) { vTaskDelay(10); } + #ifndef PIOS_INCLUDE_WDG // if no watchdog is enabled, don't reset watchdog in MODULE_TASKCREATE_ALL loop #define PIOS_WDG_Clear() @@ -127,6 +136,7 @@ static void gpspSystemTask(__attribute__((unused)) void *parameters) #if defined(PIOS_INCLUDE_IAP) PIOS_IAP_WriteBootCount(0); #endif + /* Right now there is no configuration and uart speed is fixed at 57600. * TODO: * 1) add a tiny ubx parser on gps side to intercept CFG-RINV and use that for config storage; diff --git a/flight/targets/boards/gpsplatinum/firmware/gpsp.c b/flight/targets/boards/gpsplatinum/firmware/gpsp.c index 0768c2a55..8bed9b50c 100644 --- a/flight/targets/boards/gpsplatinum/firmware/gpsp.c +++ b/flight/targets/boards/gpsplatinum/firmware/gpsp.c @@ -42,6 +42,7 @@ /* Global Variables */ extern void Stack_Change(void); +extern void GPSPSystemModStart(void); /** * OpenPilot Main function: @@ -54,32 +55,19 @@ extern void Stack_Change(void); */ int main() { - /* NOTE: Do NOT modify the following start-up sequence */ - /* Any new initialization functions should be added in OpenPilotInit() */ - /* Brings up System using CMSIS functions, enables the LEDs. */ PIOS_SYS_Init(); - /* Architecture dependant Hardware and - * core subsystem initialisation - * (see pios_board.c for your arch) - * */ - PIOS_Board_Init(); + /* + * Initialize the system module, which configures the board and + * starts the other modules. + */ + GPSPSystemModStart(); - /* Initialize modules */ - MODULE_INITIALISE_ALL /* swap the stack to use the IRQ stack */ Stack_Change(); - /* Start the FreeRTOS scheduler, which should never return. - * - * NOTE: OpenPilot runs an operating system (FreeRTOS), which constantly calls - * (schedules) function files (modules). These functions never return from their - * while loops, which explains why each module has a while(1){} segment. Thus, - * the OpenPilot software actually starts at the vTaskStartScheduler() function, - * even though this is somewhat obscure. - * - */ + /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); /* If all is well we will never reach here as the scheduler will now be running. */