From 3e64dda5d5c350cc325650133f7e64967f1efe84 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 23 Mar 2022 23:19:02 -0700 Subject: Toy task start - 1/40u --- include/usr/main.h | 6 ++++++ src/cpu/irq.c | 6 +++--- src/usr/main.c | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 include/usr/main.h create mode 100644 src/usr/main.c diff --git a/include/usr/main.h b/include/usr/main.h new file mode 100644 index 0000000..9d0b76b --- /dev/null +++ b/include/usr/main.h @@ -0,0 +1,6 @@ +#ifndef USR_MAIN_H +#define USR_MAIN_H + +void main(void); + +#endif diff --git a/src/cpu/irq.c b/src/cpu/irq.c index dcca9e8..d3eefa2 100644 --- a/src/cpu/irq.c +++ b/src/cpu/irq.c @@ -9,6 +9,7 @@ #include #include #include +#include #define CPS 1000 @@ -59,10 +60,9 @@ unsigned long c_irq_handler(void) volatile unsigned long* timer_cs = (volatile unsigned long*)SYS_TIMER_CS; volatile unsigned long* timer_chi = (volatile unsigned long*)SYS_TIMER_CHI; volatile unsigned long* nexttime = (volatile unsigned long*)SYS_TIMER_C0; - add_thread_without_duplicate(test_entry, 0, 2); - *nexttime = *timer_chi + 4000000; + add_thread_without_duplicate(main, 0, 0); + *nexttime = *timer_chi + 40; *timer_cs = SYS_TIMER_SC_M0; - status(); return 1; } } diff --git a/src/usr/main.c b/src/usr/main.c new file mode 100644 index 0000000..67b9c3a --- /dev/null +++ b/src/usr/main.c @@ -0,0 +1,25 @@ +#include +#include + +char* ulong_to_string(unsigned long value, char* data) +{ + unsigned long t = value; + unsigned long c; + char* dptr = data + 9; + for (int i = 0; i <= 10; i++) { + c = t%10; + *dptr = 0x30 + (c&0xF); + t /= 10; + if (t==0) + break; + dptr -= 1; + } + return dptr; +} + +void main(void) +{ + static char str[13]; + char* start = ulong_to_string(*(volatile unsigned long*)SYS_TIMER_CHI, str); + draw_string(0, 10, start); +} -- cgit v1.2.1