Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: systick.cpp
- Revision:
- 0:7a97ebb833eb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/systick.cpp Sun May 05 00:02:11 2019 +0000
@@ -0,0 +1,35 @@
+#include "systick.h"
+#include "mbed.h"
+#include "globals.h"
+
+void systickFunction() {
+ // Update global counter
+ millis++;
+ mainController.update();
+
+ // Update other sensors
+ ir.update();
+}
+
+void Systick::start() {
+ m_systicker.attach(&systickFunction, SYS_TICK_TIME);
+}
+
+void Systick::stop() {
+ m_systicker.detach();
+}
+
+Systick::Systick() {
+ // A little bit of magic; if you want to know why, ask Robert
+ NVIC_SetPriority(TIM5_IRQn, 255);
+}
+
+void Systick::wait(float sec) {
+ // Utility function: allows you to wait while using systick.
+ int init = millis;
+
+ float num_ticks = sec / SYS_TICK_TIME;
+
+ while (millis - init < num_ticks)
+ ;
+}