Include sleep into library
This commit is contained in:
2
Makefile
2
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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
void puts(const char *s);
|
||||
void usleep(unsigned int usec);
|
||||
void sleep(unsigned int sec);
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user