diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-05 17:26:38 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-05 17:26:38 +0900 |
commit | 2fea34dd1c2224dad55b83700b944aa26c6cf9fc (patch) | |
tree | b28adc353567892fd6d775e0ce1cb68ec50638d5 /example-led | |
parent | 0ae3b2681fd3428baffc06cefadc40a90dcd5da4 (diff) |
bug fixes for SCHED_RR
Diffstat (limited to 'example-led')
-rw-r--r-- | example-led/Makefile | 3 | ||||
-rw-r--r-- | example-led/sample.c | 29 |
2 files changed, 26 insertions, 6 deletions
diff --git a/example-led/Makefile b/example-led/Makefile index 085d42b..f06a274 100644 --- a/example-led/Makefile +++ b/example-led/Makefile @@ -14,7 +14,8 @@ OBJCOPY = $(CROSS)objcopy MCU = cortex-m3 CWARN = -Wall -Wextra -Wstrict-prototypes -DEFS = -DFREE_STANDING +# DEFS = -DFREE_STANDING +DEFS = -DFREE_STANDING -DBUSY_LOOP -DCHX_FLAGS_MAIN=CHOPSTX_SCHED_RR OPT = -O3 -Os -g LIBS = diff --git a/example-led/sample.c b/example-led/sample.c index c1036d6..c89b2bc 100644 --- a/example-led/sample.c +++ b/example-led/sample.c @@ -10,6 +10,20 @@ static chopstx_cond_t cnd1; static uint8_t u, v; static uint8_t m; /* 0..100 */ +static void +wait_for (uint32_t usec) +{ +#if defined(BUSY_LOOP) + uint32_t count = usec *18; + uint32_t i; + + for (i = 0; i < count; i++) + asm volatile ("" : : "r" (i) : "memory"); +#else + chopstx_usec_wait (usec); +#endif +} + static void * pwm (void *arg) { @@ -22,9 +36,9 @@ pwm (void *arg) while (1) { set_led (u&v); - chopstx_usec_wait (m); + wait_for (m); set_led (0); - chopstx_usec_wait (100-m); + wait_for (100-m); } return NULL; @@ -42,16 +56,21 @@ blk (void *arg) while (1) { v = 0; - chopstx_usec_wait (200*1000); + wait_for (200*1000); v = 1; - chopstx_usec_wait (200*1000); + wait_for (200*1000); } return NULL; } +#if defined(BUSY_LOOP) +#define PRIO_PWM (CHOPSTX_SCHED_RR|1) +#define PRIO_BLK (CHOPSTX_SCHED_RR|1) +#else #define PRIO_PWM 3 #define PRIO_BLK 2 +#endif extern uint8_t __process1_stack_base__, __process1_stack_size__; extern uint8_t __process2_stack_base__, __process2_stack_size__; @@ -88,7 +107,7 @@ main (int argc, const char *argv[]) while (1) { u ^= 1; - chopstx_usec_wait (200*1000*6); + wait_for (200*1000*6); } return 0; |