Moved codeplug initialisation from state init function to main initialisation sequence
This commit is contained in:
parent
d39783af2f
commit
22ce4d6925
|
|
@ -21,6 +21,7 @@
|
|||
#include <interfaces/platform.h>
|
||||
#include <interfaces/graphics.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <interfaces/cps_io.h>
|
||||
#include <interfaces/gps.h>
|
||||
#include <threads.h>
|
||||
#include <openrtx.h>
|
||||
|
|
@ -42,6 +43,22 @@ void openrtx_init()
|
|||
display_setContrast(state.settings.contrast);
|
||||
#endif
|
||||
|
||||
// Load codeplug from nonvolatile memory, create a new one in case of failure.
|
||||
if(cps_open(NULL) < 0)
|
||||
{
|
||||
cps_create(NULL);
|
||||
if(cps_open(NULL) < 0)
|
||||
{
|
||||
// Unrecoverable error
|
||||
#ifdef PLATFORM_LINUX
|
||||
exit(-1);
|
||||
#else
|
||||
// TODO: implement error handling for non-linux targets
|
||||
while(1) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Display splash screen, turn on backlight after a suitable time to
|
||||
// hide random pixels during render process
|
||||
ui_drawSplashScreen(true);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <hwconfig.h>
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/cps_io.h>
|
||||
|
||||
state_t state;
|
||||
pthread_mutex_t state_mutex;
|
||||
|
|
@ -54,26 +53,6 @@ void state_init()
|
|||
state.channel = cps_getDefaultChannel();
|
||||
}
|
||||
|
||||
/*
|
||||
* Try loading default codeplug from nonvolatile memory, if fails create
|
||||
* an empty one.
|
||||
*/
|
||||
if(cps_open(NULL) < 0)
|
||||
{
|
||||
cps_create(NULL);
|
||||
|
||||
// If cannot open the newly created codeplug -> unrecoverable error
|
||||
if(cps_open(NULL) < 0)
|
||||
{
|
||||
#ifdef PLATFORM_LINUX
|
||||
exit(-1);
|
||||
#else
|
||||
// TODO: implement error handling for non-linux targets
|
||||
while(1) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise remaining fields
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue