Eurobot2012_Primary
Dependencies: mbed Eurobot_2012_Primary
system.h@1:bbabbd997d21, 2012-04-20 (annotated)
- Committer:
- narshu
- Date:
- Fri Apr 20 21:56:15 2012 +0000
- Revision:
- 1:bbabbd997d21
- Parent:
- 0:f3bf6c7e2283
copied everything from secondary;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
narshu | 0:f3bf6c7e2283 | 1 | |
narshu | 0:f3bf6c7e2283 | 2 | #ifndef SYSTEM_H |
narshu | 0:f3bf6c7e2283 | 3 | #define SYSTEM_H |
narshu | 0:f3bf6c7e2283 | 4 | |
narshu | 0:f3bf6c7e2283 | 5 | #include "globals.h" |
narshu | 1:bbabbd997d21 | 6 | #include "rtos.h" |
narshu | 0:f3bf6c7e2283 | 7 | |
narshu | 1:bbabbd997d21 | 8 | //a type which is a pointer to a rtos thread function |
narshu | 1:bbabbd997d21 | 9 | typedef void (*tfuncptr_t)(void const *argument); |
narshu | 0:f3bf6c7e2283 | 10 | |
narshu | 1:bbabbd997d21 | 11 | //--------------------- |
narshu | 1:bbabbd997d21 | 12 | //Signal ticker stuff |
narshu | 0:f3bf6c7e2283 | 13 | #define SIGTICKARGS(thread, signal) \ |
narshu | 0:f3bf6c7e2283 | 14 | (tfuncptr_t) (&Signalsetter::callback), osTimerPeriodic, (void*)(new Signalsetter(thread, signal)) |
narshu | 0:f3bf6c7e2283 | 15 | |
narshu | 0:f3bf6c7e2283 | 16 | class Signalsetter { |
narshu | 0:f3bf6c7e2283 | 17 | public: |
narshu | 0:f3bf6c7e2283 | 18 | Signalsetter(Thread& inthread, int insignal) : |
narshu | 0:f3bf6c7e2283 | 19 | thread(inthread) { |
narshu | 0:f3bf6c7e2283 | 20 | signal = insignal; |
narshu | 0:f3bf6c7e2283 | 21 | //pc.printf("ptr saved as %#x \r\n", (int)(&(inthread))); |
narshu | 0:f3bf6c7e2283 | 22 | } |
narshu | 0:f3bf6c7e2283 | 23 | |
narshu | 0:f3bf6c7e2283 | 24 | static void callback(void* thisin) { |
narshu | 0:f3bf6c7e2283 | 25 | |
narshu | 0:f3bf6c7e2283 | 26 | Signalsetter* fthis = (Signalsetter*)thisin; |
narshu | 0:f3bf6c7e2283 | 27 | //pc.printf("callback will signal thread object at %#x \r\n", (int)(&(fthis->thread))); |
narshu | 0:f3bf6c7e2283 | 28 | fthis->thread.signal_set(fthis->signal); |
narshu | 0:f3bf6c7e2283 | 29 | //delete fthis; //this is useful for single fire tickers! |
narshu | 0:f3bf6c7e2283 | 30 | } |
narshu | 0:f3bf6c7e2283 | 31 | |
narshu | 0:f3bf6c7e2283 | 32 | private: |
narshu | 0:f3bf6c7e2283 | 33 | Thread& thread; |
narshu | 0:f3bf6c7e2283 | 34 | int signal; |
narshu | 0:f3bf6c7e2283 | 35 | }; |
narshu | 0:f3bf6c7e2283 | 36 | |
narshu | 1:bbabbd997d21 | 37 | //--------------------- |
narshu | 1:bbabbd997d21 | 38 | //cpu usage measurement function |
narshu | 1:bbabbd997d21 | 39 | extern float cpupercent; |
narshu | 1:bbabbd997d21 | 40 | void measureCPUidle (void const* arg); |
narshu | 1:bbabbd997d21 | 41 | |
narshu | 0:f3bf6c7e2283 | 42 | #endif |