aboutsummaryrefslogtreecommitdiff
path: root/kernel/clock.c
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2011-11-02 02:54:40 +0000
committerDimitri Sokolyuk <demon@dim13.org>2011-11-02 02:54:40 +0000
commit87dd379c89dbe9b63dd3ab0f20f002a20d789c47 (patch)
treeafc0c66c7641377fd5228fd5a6aee5b35dc99a24 /kernel/clock.c
parente754d6f8f1288fa3ae5032ef675f35268a484c79 (diff)
major update: lot of bugfixes, lot of changes
- let compiler handle stack pointer arithmetic: switch to 16bit - improve update(): deadline depends on incremental release - resolve timing issues, new time convertion macros - major simplification of scheduler, most of garbage removed - new overflow interrupt for cycle counter, resolves also timing problems - simplify pwm generation, lookup tables are deferred, switch to 4bit - add blocking on shared values - remove garbage in lcd module and some bugfixes - add alternative reboot command to uart command interpreter - KISS
Diffstat (limited to 'kernel/clock.c')
-rw-r--r--kernel/clock.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/kernel/clock.c b/kernel/clock.c
index c098481..790391e 100644
--- a/kernel/clock.c
+++ b/kernel/clock.c
@@ -17,6 +17,7 @@
#include <inttypes.h>
#include <avr/io.h>
+#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "tasks.h"
@@ -24,27 +25,31 @@
void
clock(void *arg)
{
- struct clockarg *a = arg;
+ struct lcdarg *a = arg;
+ uint8_t d, h, m, s;
- a->s = a->m = a->h = a->d = 0;
+ d = h = m = s = 0;
- update(0, SEC(1));
+ update(0, SEC(500));
for (;;) {
- a->s += 1;
- if (a->s == 60) {
- a->s = 0;
- a->m += 1;
+ s += 1;
+ if (s == 60) {
+ s = 0;
+ m += 1;
}
- if (a->m == 60) {
- a->m = 0;
- a->h += 1;
+ if (m == 60) {
+ m = 0;
+ h += 1;
}
- if (a->h == 24) {
- a->h = 0;
- a->d += 1;
+ if (h == 24) {
+ h = 0;
+ d += 1;
}
- sleep(HARD, SEC(1));
+ sprintf(a->first, "%8lx", now());
+ sprintf(a->second, "%4d:%.2d:%.2d:%.2d", d, h, m, s);
+
+ update(SEC(1), MSEC(500));
}
}