Eurobot system lib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers system.h Source File

system.h

00001 
00002 #ifndef SYSTEM_H
00003 #define SYSTEM_H
00004 
00005 #include "globals.h"
00006 #include "rtos.h"
00007 
00008 //Declaring the onboard LED's for everyone to use
00009 extern DigitalOut     OLED1;//(LED1);
00010 extern DigitalOut     OLED2;//(LED2);
00011 extern DigitalOut     OLED3;//(LED3);
00012 extern DigitalOut     OLED4;//(LED4);
00013 
00014 //a type which is a pointer to a rtos thread function
00015 typedef void (*tfuncptr_t)(void const *argument);
00016 
00017 //---------------------
00018 //Signal ticker stuff
00019 #define SIGTICKARGS(thread, signal) \
00020     (tfuncptr_t) (&Signalsetter::callback), osTimerPeriodic, (void*)(new Signalsetter(thread, signal))
00021 
00022 class Signalsetter {
00023 public:
00024     Signalsetter(Thread& inthread, int insignal) :
00025             thread(inthread) {
00026         signal = insignal;
00027         //pc.printf("ptr saved as %#x \r\n", (int)(&(inthread)));
00028     }
00029 
00030     static void callback(void* thisin) {
00031 
00032         Signalsetter* fthis = (Signalsetter*)thisin;
00033         //pc.printf("callback will signal thread object at %#x \r\n", (int)(&(fthis->thread)));
00034         fthis->thread.signal_set(fthis->signal);
00035         //delete fthis; //this is useful for single fire tickers!
00036     }
00037 
00038 private:
00039     Thread& thread;
00040     int signal;
00041 };
00042 
00043 //---------------------
00044 //cpu usage measurement function
00045 extern float cpupercent;
00046 void measureCPUidle (void const* arg);
00047 
00048 #endif