maxrefdes117

Committer:
zinnetyazicii53
Date:
Tue Aug 06 12:19:46 2019 +0000
Revision:
0:78a2573ad768
commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zinnetyazicii53 0:78a2573ad768 1 #include "mbed.h"
zinnetyazicii53 0:78a2573ad768 2 #include "millis.h"
zinnetyazicii53 0:78a2573ad768 3
zinnetyazicii53 0:78a2573ad768 4 static volatile uint32_t millisValue = 0;
zinnetyazicii53 0:78a2573ad768 5
zinnetyazicii53 0:78a2573ad768 6 static Ticker ticker;
zinnetyazicii53 0:78a2573ad768 7
zinnetyazicii53 0:78a2573ad768 8 void millisTicker ()
zinnetyazicii53 0:78a2573ad768 9 {
zinnetyazicii53 0:78a2573ad768 10 millisValue ++;
zinnetyazicii53 0:78a2573ad768 11 }
zinnetyazicii53 0:78a2573ad768 12
zinnetyazicii53 0:78a2573ad768 13 uint32_t millis ()
zinnetyazicii53 0:78a2573ad768 14 {
zinnetyazicii53 0:78a2573ad768 15 return millisValue;
zinnetyazicii53 0:78a2573ad768 16 }
zinnetyazicii53 0:78a2573ad768 17
zinnetyazicii53 0:78a2573ad768 18 void setMillis (uint32_t theValue) {
zinnetyazicii53 0:78a2573ad768 19 millisValue = theValue;
zinnetyazicii53 0:78a2573ad768 20 }
zinnetyazicii53 0:78a2573ad768 21
zinnetyazicii53 0:78a2573ad768 22 void startMillis () {
zinnetyazicii53 0:78a2573ad768 23 ticker.attach (millisTicker, 0.001);
zinnetyazicii53 0:78a2573ad768 24 }
zinnetyazicii53 0:78a2573ad768 25
zinnetyazicii53 0:78a2573ad768 26 void stopMillis () {
zinnetyazicii53 0:78a2573ad768 27 ticker.detach ();
zinnetyazicii53 0:78a2573ad768 28 }
zinnetyazicii53 0:78a2573ad768 29