summaryrefslogtreecommitdiff
path: root/project/Core/Src/System
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-10-01 23:38:18 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-10-01 23:38:18 -0400
commite2ba305068f3045944789bf65e29fb2f2f557879 (patch)
treec78a70b4e2641270f0804965b84dcddae38af4c0 /project/Core/Src/System
parente50a487f58941c49cace0783f80a3d4dc6de3c2a (diff)
download340-repo-Sowgro-e2ba305068f3045944789bf65e29fb2f2f557879.tar.gz
340-repo-Sowgro-e2ba305068f3045944789bf65e29fb2f2f557879.tar.bz2
340-repo-Sowgro-e2ba305068f3045944789bf65e29fb2f2f557879.zip
complete homework 4
Diffstat (limited to '')
-rw-r--r--project/Core/Src/System/systick.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/project/Core/Src/System/systick.c b/project/Core/Src/System/systick.c
index 263defd..58ee2b1 100644
--- a/project/Core/Src/System/systick.c
+++ b/project/Core/Src/System/systick.c
@@ -1,5 +1,9 @@
#include "systick.h"
+systick_t *get_systick() {
+ return (systick_t *) 0xE000E010;
+}
+
// This function is to Initialize SysTick registers
void init_systick()
{
@@ -10,6 +14,12 @@ void init_systick()
// Set the LOAD (RVR) to 8 million to give us a 100 milliseconds timer.
// Set the clock source bit in the CTRL (CSR) to the internal clock.
// 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<<2;
+ s->CSR |= 1;
}
// This fuction is to create delay using SysTick timer counter
@@ -20,4 +30,10 @@ void delay_systick()
// Inside that for loop check the COUNTFLAG bit in the CTRL (CSR)
// register in a loop. When that bit is set exit this inner loop
// to do another pass in the outer loop of 10.
+ systick_t *s = get_systick();
+
+ for (int i = 0; i < 10; i++) {
+ while (~s->CSR & (1<<16))
+ ;
+ }
}