From 5a6c8f4c22e6581f1b970afd68bf4c2c4db4ebf2 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 21 Feb 2018 09:13:53 -0500 Subject: [PATCH] task pausing --- include/task.h | 2 ++ initrd/init | 22 +++++++++++----------- run.sh | 8 ++++---- src/display_draw.c | 4 ++-- src/task.c | 5 +++++ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/task.h b/include/task.h index eda2dcd..7077b00 100644 --- a/include/task.h +++ b/include/task.h @@ -22,4 +22,6 @@ void task_init(void (*init)(void)); */ void task_start(void (*task)(void), uint16_t stackSize); +void task_hold(uint8_t hold); + #endif // TASK_H_ diff --git a/initrd/init b/initrd/init index c7ce93b..1837b27 100644 --- a/initrd/init +++ b/initrd/init @@ -8,15 +8,15 @@ line 50 160 430 160 fg line 240 50 240 270 fg set x 50 -#do -# delay 10 -# line x 170 x 150 fg -# set x (x + 20) -#while (x < 430) +do + line x 170 x 150 fg + set x (x + 20) +while (x < 430) -#set y 50 -#do -# delay 10 -# line 230 y 250 y fg -# set y (y + 20) -#while (y < 270) +set y 50 +do + line 230 y 250 y fg + set y (y + 20) +while (y < 270) + +line 80 250 380 90 511 diff --git a/run.sh b/run.sh index a031d27..88be7fa 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,7 @@ #!/bin/bash -#openocd -f /usr/share/openocd/scripts/board/st_nucleo_l476rg.cfg \ -# -c "init; reset halt; flash write_image erase main.hex; reset run; exit" +openocd -f /usr/share/openocd/scripts/board/st_nucleo_l476rg.cfg \ + -c "init; reset halt; flash write_image erase main.hex; reset run; exit" -openocd -f /usr/share/openocd/scripts/board/st_nucleo_l476rg.cfg > /dev/null & -gdb-multiarch +#openocd -f /usr/share/openocd/scripts/board/st_nucleo_l476rg.cfg > /dev/null & +#gdb-multiarch diff --git a/src/display_draw.c b/src/display_draw.c index 0d26e9a..be4becf 100644 --- a/src/display_draw.c +++ b/src/display_draw.c @@ -4,8 +4,8 @@ #include volatile uint8_t lock = 0; -#define LOCK while (lock) { delay(5); } lock = 1 -#define UNLOCK lock = 0 +#define LOCK while (lock) { delay(5); } task_hold(1); lock = 1 +#define UNLOCK task_hold(0); lock = 0 static unsigned int curx = 0; static unsigned int cury = 0; diff --git a/src/task.c b/src/task.c index ee338de..b290e3c 100644 --- a/src/task.c +++ b/src/task.c @@ -16,6 +16,11 @@ static volatile int next_idx = 0; static uint8_t task_enable = 0; +void task_hold(uint8_t hold) +{ + task_enable = !hold; +} + void task_init(void (*init)(void)) { for (int i = 0; i < MAX_TASKS; i++)