Shuto Naruse
/
Eurobot_2012_Secondary
Eurobot_2012_Secondary
Embed:
(wiki syntax)
Show/hide line numbers
system.h
00001 00002 #ifndef SYSTEM_H 00003 #define SYSTEM_H 00004 00005 #include "globals.h" 00006 #include "rtos.h" 00007 00008 //a type which is a pointer to a rtos thread function 00009 typedef void (*tfuncptr_t)(void const *argument); 00010 00011 //--------------------- 00012 //Signal ticker stuff 00013 #define SIGTICKARGS(thread, signal) \ 00014 (tfuncptr_t) (&Signalsetter::callback), osTimerPeriodic, (void*)(new Signalsetter(thread, signal)) 00015 00016 class Signalsetter { 00017 public: 00018 Signalsetter(Thread& inthread, int insignal) : 00019 thread(inthread) { 00020 signal = insignal; 00021 //pc.printf("ptr saved as %#x \r\n", (int)(&(inthread))); 00022 } 00023 00024 static void callback(void* thisin) { 00025 00026 Signalsetter* fthis = (Signalsetter*)thisin; 00027 //pc.printf("callback will signal thread object at %#x \r\n", (int)(&(fthis->thread))); 00028 fthis->thread.signal_set(fthis->signal); 00029 //delete fthis; //this is useful for single fire tickers! 00030 } 00031 00032 private: 00033 Thread& thread; 00034 int signal; 00035 }; 00036 00037 //--------------------- 00038 //cpu usage measurement function 00039 extern float cpupercent; 00040 void measureCPUidle (void const* arg); 00041 00042 #endif
Generated on Sat Jul 16 2022 01:26:17 by 1.7.2