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.
systick.cpp
- Committer:
- rzalog
- Date:
- 2019-05-05
- Revision:
- 0:7a97ebb833eb
File content as of revision 0:7a97ebb833eb:
#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)
;
}