summaryrefslogtreecommitdiff
path: root/project/Core/Src/System
diff options
context:
space:
mode:
Diffstat (limited to 'project/Core/Src/System')
-rw-r--r--project/Core/Src/System/systick.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/project/Core/Src/System/systick.c b/project/Core/Src/System/systick.c
index 58ee2b1..a9e38c7 100644
--- a/project/Core/Src/System/systick.c
+++ b/project/Core/Src/System/systick.c
@@ -16,9 +16,9 @@ void init_systick()
// Set the enable bit in the CTRL (CSR) to start the timer.
systick_t *s = get_systick();
- s->CSR = 0;
- s->RVR = 8000000;
+ s->CSR &= ~1;
s->CSR |= 1<<2;
+ s->RVR = 8000000; // 100 ms
s->CSR |= 1;
}
@@ -37,3 +37,19 @@ void delay_systick()
;
}
}
+
+int check_systick() {
+ static int i = 0;
+
+ systick_t *s = get_systick();
+ if (!(~s->CSR & (1<<16))) {
+ i++;
+ }
+
+ if (i >= 10) {
+ i = 0;
+ return 1;
+ } else {
+ return 0;
+ }
+}