![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
working version with calibration done
Fork of Eurobot2013 by
system/system.h@3:8c78c15a92e3, 2012-11-14 (annotated)
- Committer:
- xiaxia686
- Date:
- Wed Nov 14 15:48:20 2012 +0000
- Revision:
- 3:8c78c15a92e3
Merged with Sonar;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xiaxia686 | 3:8c78c15a92e3 | 1 | |
xiaxia686 | 3:8c78c15a92e3 | 2 | #ifndef SYSTEM_H |
xiaxia686 | 3:8c78c15a92e3 | 3 | #define SYSTEM_H |
xiaxia686 | 3:8c78c15a92e3 | 4 | |
xiaxia686 | 3:8c78c15a92e3 | 5 | #include "globals.h" |
xiaxia686 | 3:8c78c15a92e3 | 6 | #include "rtos.h" |
xiaxia686 | 3:8c78c15a92e3 | 7 | |
xiaxia686 | 3:8c78c15a92e3 | 8 | //Declaring the onboard LED's for everyone to use |
xiaxia686 | 3:8c78c15a92e3 | 9 | extern DigitalOut OLED1;//(LED1); |
xiaxia686 | 3:8c78c15a92e3 | 10 | extern DigitalOut OLED2;//(LED2); |
xiaxia686 | 3:8c78c15a92e3 | 11 | extern DigitalOut OLED3;//(LED3); |
xiaxia686 | 3:8c78c15a92e3 | 12 | extern DigitalOut OLED4;//(LED4); |
xiaxia686 | 3:8c78c15a92e3 | 13 | |
xiaxia686 | 3:8c78c15a92e3 | 14 | //nop style wait function |
xiaxia686 | 3:8c78c15a92e3 | 15 | void nopwait(int ms); |
xiaxia686 | 3:8c78c15a92e3 | 16 | |
xiaxia686 | 3:8c78c15a92e3 | 17 | //a type which is a pointer to a rtos thread function |
xiaxia686 | 3:8c78c15a92e3 | 18 | typedef void (*tfuncptr_t)(void const *argument); |
xiaxia686 | 3:8c78c15a92e3 | 19 | |
xiaxia686 | 3:8c78c15a92e3 | 20 | //--------------------- |
xiaxia686 | 3:8c78c15a92e3 | 21 | //Signal ticker stuff |
xiaxia686 | 3:8c78c15a92e3 | 22 | #define SIGTICKARGS(thread, signal) \ |
xiaxia686 | 3:8c78c15a92e3 | 23 | (tfuncptr_t) (&Signalsetter::callback), osTimerPeriodic, (void*)(new Signalsetter(thread, signal)) |
xiaxia686 | 3:8c78c15a92e3 | 24 | |
xiaxia686 | 3:8c78c15a92e3 | 25 | class Signalsetter { |
xiaxia686 | 3:8c78c15a92e3 | 26 | public: |
xiaxia686 | 3:8c78c15a92e3 | 27 | Signalsetter(Thread& inthread, int insignal) : |
xiaxia686 | 3:8c78c15a92e3 | 28 | thread(inthread) { |
xiaxia686 | 3:8c78c15a92e3 | 29 | signal = insignal; |
xiaxia686 | 3:8c78c15a92e3 | 30 | //pc.printf("ptr saved as %#x \r\n", (int)(&(inthread))); |
xiaxia686 | 3:8c78c15a92e3 | 31 | } |
xiaxia686 | 3:8c78c15a92e3 | 32 | |
xiaxia686 | 3:8c78c15a92e3 | 33 | static void callback(void* thisin) { |
xiaxia686 | 3:8c78c15a92e3 | 34 | |
xiaxia686 | 3:8c78c15a92e3 | 35 | Signalsetter* fthis = (Signalsetter*)thisin; |
xiaxia686 | 3:8c78c15a92e3 | 36 | //pc.printf("callback will signal thread object at %#x \r\n", (int)(&(fthis->thread))); |
xiaxia686 | 3:8c78c15a92e3 | 37 | fthis->thread.signal_set(fthis->signal); |
xiaxia686 | 3:8c78c15a92e3 | 38 | //delete fthis; //this is useful for single fire tickers! |
xiaxia686 | 3:8c78c15a92e3 | 39 | } |
xiaxia686 | 3:8c78c15a92e3 | 40 | |
xiaxia686 | 3:8c78c15a92e3 | 41 | private: |
xiaxia686 | 3:8c78c15a92e3 | 42 | Thread& thread; |
xiaxia686 | 3:8c78c15a92e3 | 43 | int signal; |
xiaxia686 | 3:8c78c15a92e3 | 44 | }; |
xiaxia686 | 3:8c78c15a92e3 | 45 | |
xiaxia686 | 3:8c78c15a92e3 | 46 | //--------------------- |
xiaxia686 | 3:8c78c15a92e3 | 47 | //cpu usage measurement function |
xiaxia686 | 3:8c78c15a92e3 | 48 | extern float cpupercent; |
xiaxia686 | 3:8c78c15a92e3 | 49 | void measureCPUidle (void const* arg); |
xiaxia686 | 3:8c78c15a92e3 | 50 | |
xiaxia686 | 3:8c78c15a92e3 | 51 | #endif |