We are going to win! wohoo

Dependencies:   mbed mbed-rtos

Committer:
madcowswe
Date:
Wed Nov 14 17:15:53 2012 +0000
Revision:
9:08552997b544
Parent:
5:a229f40c1210
Added an important comment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 5:a229f40c1210 1
madcowswe 5:a229f40c1210 2 #ifndef SYSTEM_H
madcowswe 5:a229f40c1210 3 #define SYSTEM_H
madcowswe 5:a229f40c1210 4
madcowswe 5:a229f40c1210 5 #include "globals.h"
madcowswe 5:a229f40c1210 6 #include "rtos.h"
madcowswe 5:a229f40c1210 7
madcowswe 5:a229f40c1210 8 //Declaring the onboard LED's for everyone to use
madcowswe 5:a229f40c1210 9 extern DigitalOut OLED1;//(LED1);
madcowswe 5:a229f40c1210 10 extern DigitalOut OLED2;//(LED2);
madcowswe 5:a229f40c1210 11 extern DigitalOut OLED3;//(LED3);
madcowswe 5:a229f40c1210 12 extern DigitalOut OLED4;//(LED4);
madcowswe 5:a229f40c1210 13
madcowswe 5:a229f40c1210 14 //nop style wait function
madcowswe 5:a229f40c1210 15 void nopwait(int ms);
madcowswe 5:a229f40c1210 16
madcowswe 5:a229f40c1210 17 //a type which is a pointer to a rtos thread function
madcowswe 5:a229f40c1210 18 typedef void (*tfuncptr_t)(void const *argument);
madcowswe 5:a229f40c1210 19
madcowswe 5:a229f40c1210 20 //---------------------
madcowswe 5:a229f40c1210 21 //Signal ticker stuff
madcowswe 5:a229f40c1210 22 #define SIGTICKARGS(thread, signal) \
madcowswe 5:a229f40c1210 23 (tfuncptr_t) (&Signalsetter::callback), osTimerPeriodic, (void*)(new Signalsetter(thread, signal))
madcowswe 5:a229f40c1210 24
madcowswe 5:a229f40c1210 25 class Signalsetter {
madcowswe 5:a229f40c1210 26 public:
madcowswe 5:a229f40c1210 27 Signalsetter(Thread& inthread, int insignal) :
madcowswe 5:a229f40c1210 28 thread(inthread) {
madcowswe 5:a229f40c1210 29 signal = insignal;
madcowswe 5:a229f40c1210 30 //pc.printf("ptr saved as %#x \r\n", (int)(&(inthread)));
madcowswe 5:a229f40c1210 31 }
madcowswe 5:a229f40c1210 32
madcowswe 5:a229f40c1210 33 static void callback(void* thisin) {
madcowswe 5:a229f40c1210 34
madcowswe 5:a229f40c1210 35 Signalsetter* fthis = (Signalsetter*)thisin;
madcowswe 5:a229f40c1210 36 //pc.printf("callback will signal thread object at %#x \r\n", (int)(&(fthis->thread)));
madcowswe 5:a229f40c1210 37 fthis->thread.signal_set(fthis->signal);
madcowswe 5:a229f40c1210 38 //delete fthis; //this is useful for single fire tickers!
madcowswe 5:a229f40c1210 39 }
madcowswe 5:a229f40c1210 40
madcowswe 5:a229f40c1210 41 private:
madcowswe 5:a229f40c1210 42 Thread& thread;
madcowswe 5:a229f40c1210 43 int signal;
madcowswe 5:a229f40c1210 44 };
madcowswe 5:a229f40c1210 45
madcowswe 5:a229f40c1210 46 //---------------------
madcowswe 5:a229f40c1210 47 //cpu usage measurement function
madcowswe 5:a229f40c1210 48 extern float cpupercent;
madcowswe 5:a229f40c1210 49 void measureCPUidle (void const* arg);
madcowswe 5:a229f40c1210 50
madcowswe 5:a229f40c1210 51 #endif