inmarket Posted February 28, 2015 Report Share Posted February 28, 2015 In some cases it is necessary to perform various initialisation tasks after the operating system is initialised but before certain other modules are initialised. An example of this might be when you are using GFILE to load calibration data while GINPUT is initialising the touch. That is, It may be necessary to start the block device (eg chibios's sdcInit()) after the operating system initialisation but before GFILE loads.Previously the solution was to define GFX_NO_OS_INIT, initialise the operating system yourself, initialise the block device and then call gfxInit().This was obviously a complicated solution to an initialisation order problem.We have now defined a macro GFX_OS_EXTRA_INIT_FUNCTION which you can put into your gfxconf.h file which contains the name of a function that is called immediately after gfxInit() initialises the operating system.As an example...In your gfxconf.h:#define GFX_OS_EXTRA_INIT_FUNCTION ExtraOSInit#define GINPUT_TOUCH_USER_CALIBRATION_LOAD TRUE#define GINPUT_TOUCH_USER_CALIBRATION_SAVE TRUEIn your main.c:#include void ExtraOSInit() { // Initialise my SD-Card device which is used by GFILE. sdInit(&sdcard_params);}bool_t SaveMouseCalibration(unsigned instance, const void *data, size_t sz){ (void)instance; GFILE* f; if(!(f = gfileOpen("calib.gfx", "w"))) return FALSE; if(gfileWrite(f, data, sz) != sz) { gfileClose(f); return FALSE; } gfileClose(f); return TRUE;}bool_t LoadMouseCalibration(unsigned instance, void *data, size_t sz){ (void)instance; GFILE* f; if(!(f = gfileOpen("calib.gfx", "r"))) return FALSE; if(gfileRead(f, data, sz) != sz) { gfileClose(f); return FALSE; } gfileClose(f); return TRUE;}void main(void) { // Initialise uGFX gfxInit(); // Everything is ready to go and mouse calibration data would have been loaded if it exists. ....}You can also define GFX_OS_EXTRA_DEINIT_FUNCTION which has a similar effect during de-initialisation. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now