Shuto Naruse
/
Eurobot2012_Secondary
Eurobot2012_Secondary
Fork of Eurobot_2012_Secondary by
Eurobot_shared/system/system.cpp@1:cc2a9eb0bd55, 2012-10-17 (annotated)
- Committer:
- narshu
- Date:
- Wed Oct 17 22:25:31 2012 +0000
- Revision:
- 1:cc2a9eb0bd55
Commit before publishing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
narshu | 1:cc2a9eb0bd55 | 1 | #include "system.h" |
narshu | 1:cc2a9eb0bd55 | 2 | |
narshu | 1:cc2a9eb0bd55 | 3 | //Defining the externs |
narshu | 1:cc2a9eb0bd55 | 4 | DigitalOut OLED1(LED1); |
narshu | 1:cc2a9eb0bd55 | 5 | DigitalOut OLED2(LED2); |
narshu | 1:cc2a9eb0bd55 | 6 | DigitalOut OLED3(LED3); |
narshu | 1:cc2a9eb0bd55 | 7 | DigitalOut OLED4(LED4); |
narshu | 1:cc2a9eb0bd55 | 8 | |
narshu | 1:cc2a9eb0bd55 | 9 | //nop style wait function |
narshu | 1:cc2a9eb0bd55 | 10 | void nopwait(int ms){ |
narshu | 1:cc2a9eb0bd55 | 11 | while(ms--) |
narshu | 1:cc2a9eb0bd55 | 12 | for (volatile int i = 0; i < 24000; i++); |
narshu | 1:cc2a9eb0bd55 | 13 | } |
narshu | 1:cc2a9eb0bd55 | 14 | |
narshu | 1:cc2a9eb0bd55 | 15 | float cpupercent; //defining the extern |
narshu | 1:cc2a9eb0bd55 | 16 | void measureCPUidle (void const* arg) { |
narshu | 1:cc2a9eb0bd55 | 17 | |
narshu | 1:cc2a9eb0bd55 | 18 | Timer timer; |
narshu | 1:cc2a9eb0bd55 | 19 | cpupercent = 0; //defined in system.h |
narshu | 1:cc2a9eb0bd55 | 20 | |
narshu | 1:cc2a9eb0bd55 | 21 | while(1) { |
narshu | 1:cc2a9eb0bd55 | 22 | timer.reset(); |
narshu | 1:cc2a9eb0bd55 | 23 | timer.start(); |
narshu | 1:cc2a9eb0bd55 | 24 | wait(1); |
narshu | 1:cc2a9eb0bd55 | 25 | |
narshu | 1:cc2a9eb0bd55 | 26 | int thistime = timer.read_us()-1000000; |
narshu | 1:cc2a9eb0bd55 | 27 | cpupercent = thistime; |
narshu | 1:cc2a9eb0bd55 | 28 | } |
narshu | 1:cc2a9eb0bd55 | 29 | } |