time.cpp 397 B

1234567891011121314
  1. #include "all-headers.h"
  2. void startSystick (void) {
  3. SYST_RVR = CPU_MHZ * 1000 - 1 ; // Underflow every ms
  4. SYST_CVR = 0 ;
  5. SYST_CSR = SYST_CSR_CLKSOURCE | SYST_CSR_ENABLE ;
  6. }
  7. void busyWaitDuring (const uint32_t inDelayMS) {
  8. const uint32_t COUNTFLAG_MASK = 1 << 16 ;
  9. for (uint32_t i = 0; i < inDelayMS; i++) {
  10. while ((SYST_CSR & COUNTFLAG_MASK) == 0) {} // Busy wait, polling COUNTFLAG
  11. }
  12. }