Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Sun Apr 29 00:09:35 2012 +0000
Revision:
17:bafcef1c3579
Parent:
9:377560539b74
uptodate kalman lib; edit this one only!

Who changed what in which revision?

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