Allow the platform to provide its own main loop

This commit is contained in:
George Oikonomou 2017-10-15 17:08:43 +01:00 committed by George Oikonomou
parent 543f5ff1cd
commit d776ba035b
2 changed files with 27 additions and 0 deletions

View File

@ -104,6 +104,9 @@ main(void)
watchdog_start();
#if PLATFORM_PROVIDES_MAIN_LOOP
platform_main_loop();
#else
while(1) {
uint8_t r;
do {
@ -113,6 +116,7 @@ main(void)
platform_idle();
}
#endif
}
/*---------------------------------------------------------------------------*/
/**

View File

@ -86,6 +86,18 @@
#define PLATFORM_STARTUP_VERBOSE 1
#endif
/*---------------------------------------------------------------------------*/
/**
* Controls whether the platform provides a custom main loop
*
* By default we will use the main loop provided here. This however does not
* work for some platforms, so we allow them to override it.
*/
#ifdef PLATFORM_CONF_PROVIDES_MAIN_LOOP
#define PLATFORM_PROVIDES_MAIN_LOOP PLATFORM_CONF_PROVIDES_MAIN_LOOP
#else
#define PLATFORM_PROVIDES_MAIN_LOOP 0
#endif
/*---------------------------------------------------------------------------*/
/**
* \brief Basic (Stage 1) platform driver initialisation.
*
@ -167,6 +179,17 @@ void platform_init_stage_three(void);
*/
void platform_idle(void);
/*---------------------------------------------------------------------------*/
/**
* \brief The platform's main loop, if provided
*
* If the platform developer wishes to do so, it is possible to override the
* main loop provided by Contiki-NG's core. To do so, define
* PLATFORM_CONF_PROVIDES_MAIN_LOOP as 1.
*
* It is the port developer's responsibility to implement this function.
*/
void platform_main_loop(void);
/*---------------------------------------------------------------------------*/
#endif /* PLATFORM_H_ */
/*---------------------------------------------------------------------------*/
/**