Make the non-working skeleton work
This commit is contained in:
parent
0002eb48e7
commit
33f4345e46
|
@ -5,13 +5,17 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern jmp_buf app_jmp_buf;
|
extern jmp_buf app_jmp_buf;
|
||||||
extern uint8_t should_stop;
|
extern volatile uint8_t should_stop;
|
||||||
|
|
||||||
|
// this code does not work ... i have no idea why
|
||||||
|
// putting the exact same statements at the calling line works ...
|
||||||
|
/*
|
||||||
// initialize lifecycle, stopped if return != 0
|
// initialize lifecycle, stopped if return != 0
|
||||||
inline static int enter_app(void) {
|
static int enter_app(void) {
|
||||||
should_stop = 0;
|
should_stop = 0;
|
||||||
return setjmp(app_jmp_buf);
|
return setjmp(app_jmp_buf);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// stop the running app
|
// stop the running app
|
||||||
inline static void stop_app(void) {
|
inline static void stop_app(void) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <pentabug/lifecycle.h>
|
#include <pentabug/lifecycle.h>
|
||||||
|
|
||||||
jmp_buf app_jmp_buf;
|
jmp_buf app_jmp_buf;
|
||||||
uint8_t should_stop;
|
volatile uint8_t should_stop;
|
||||||
|
|
|
@ -22,23 +22,24 @@ static inline void reset_hw(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void run_app(struct app_t* app) {
|
static inline void run_app(struct app_t* app) {
|
||||||
if(enter_app()) {
|
should_stop = 0;
|
||||||
// this is the exit
|
if(setjmp(app_jmp_buf) == 0) {
|
||||||
if(app->cleanup) {
|
if(app->init) {
|
||||||
app->cleanup();
|
app->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
for(;;) {
|
||||||
|
app->run();
|
||||||
|
test_stop_app();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(app->init) {
|
// this is the exit
|
||||||
app->init();
|
if(app->cleanup) {
|
||||||
|
app->cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(;;) {
|
return;
|
||||||
app->run();
|
|
||||||
test_stop_app();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
@ -57,8 +58,6 @@ int main(void) {
|
||||||
|
|
||||||
run_app(&apps[app_index]);
|
run_app(&apps[app_index]);
|
||||||
|
|
||||||
for(;;);
|
|
||||||
|
|
||||||
if(direction > 0) {
|
if(direction > 0) {
|
||||||
app_index++;
|
app_index++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user