Make the non-working skeleton work
This commit is contained in:
parent
0002eb48e7
commit
33f4345e46
|
@ -5,13 +5,17 @@
|
|||
#include <stdint.h>
|
||||
|
||||
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
|
||||
inline static int enter_app(void) {
|
||||
static int enter_app(void) {
|
||||
should_stop = 0;
|
||||
return setjmp(app_jmp_buf);
|
||||
}
|
||||
*/
|
||||
|
||||
// stop the running app
|
||||
inline static void stop_app(void) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <pentabug/lifecycle.h>
|
||||
|
||||
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) {
|
||||
if(enter_app()) {
|
||||
// this is the exit
|
||||
if(app->cleanup) {
|
||||
app->cleanup();
|
||||
should_stop = 0;
|
||||
if(setjmp(app_jmp_buf) == 0) {
|
||||
if(app->init) {
|
||||
app->init();
|
||||
}
|
||||
|
||||
return;
|
||||
for(;;) {
|
||||
app->run();
|
||||
test_stop_app();
|
||||
}
|
||||
}
|
||||
|
||||
if(app->init) {
|
||||
app->init();
|
||||
// this is the exit
|
||||
if(app->cleanup) {
|
||||
app->cleanup();
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
app->run();
|
||||
test_stop_app();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
@ -57,8 +58,6 @@ int main(void) {
|
|||
|
||||
run_app(&apps[app_index]);
|
||||
|
||||
for(;;);
|
||||
|
||||
if(direction > 0) {
|
||||
app_index++;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user