diff --git a/Makefile b/Makefile index 4a9ef52..cdf8f28 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ LDFLAGS = -T linker.ld CFLAGS = $(CPU) $(THUMB) -I libc/ -I ./ QEMU = qemu-system-arm -BOARD = netduino2 +BOARD = netduinoplus2 # Output file TARGET = main.elf diff --git a/libc/library.c b/libc/library.c index 650534a..bb0dda4 100644 --- a/libc/library.c +++ b/libc/library.c @@ -1,6 +1,15 @@ #include "library.h" #include "os/driver/usart.h" +#include "os/delay.h" void puts(const char *s) { usart_tx_write_string(s); } + +void usleep(unsigned int usec) { + delay_ms(usec); +} + +void sleep(unsigned int sec) { + usleep(sec*1000); +} \ No newline at end of file diff --git a/libc/library.h b/libc/library.h index 3aa8f9b..4798291 100644 --- a/libc/library.h +++ b/libc/library.h @@ -1 +1,3 @@ void puts(const char *s); +void usleep(unsigned int usec); +void sleep(unsigned int sec); \ No newline at end of file diff --git a/os/delay.c b/os/delay.c index b0a86a3..6edef8a 100644 --- a/os/delay.c +++ b/os/delay.c @@ -1,4 +1,4 @@ -#define CLOCK_FREQUENCY 120000 +#define CLOCK_FREQUENCY 168000ULL unsigned int ms_to_ticks(unsigned int ms) { return ms * (CLOCK_FREQUENCY/3); @@ -6,10 +6,9 @@ unsigned int ms_to_ticks(unsigned int ms) { void delay_routine(unsigned int delay_counter) { asm("mov r1, %[input]\n" - "loop_2:\n" + "delay_loop:\n" "subs r1, #1\n" - "cmp r1, #0\n" - "bne loop_2\n" + "bne delay_loop\n" : [input] "=r" (delay_counter)); } diff --git a/tasks/tasks.c b/tasks/tasks.c index c3a0118..96f0ac3 100644 --- a/tasks/tasks.c +++ b/tasks/tasks.c @@ -1,11 +1,13 @@ #include "library.h" int task2(void) { - puts("Hello World from task 1\n"); + puts("Hello World from task 2\n"); + sleep(4); return 0; } int task1(void) { - puts("Hello World from task 2\n"); + puts("Hello World from task 1\n"); + sleep(2); return 0; }