Oskar Weigl
/
Quadcopter_copy
Very early flyable code.
System.h@0:9fcb3bf5c231, 2011-10-01 (annotated)
- Committer:
- madcowswe
- Date:
- Sat Oct 01 12:57:23 2011 +0000
- Revision:
- 0:9fcb3bf5c231
This edit is for testing: not flyable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
madcowswe | 0:9fcb3bf5c231 | 1 | |
madcowswe | 0:9fcb3bf5c231 | 2 | //General system functions |
madcowswe | 0:9fcb3bf5c231 | 3 | |
madcowswe | 0:9fcb3bf5c231 | 4 | #include <string> |
madcowswe | 0:9fcb3bf5c231 | 5 | |
madcowswe | 0:9fcb3bf5c231 | 6 | // |
madcowswe | 0:9fcb3bf5c231 | 7 | void kill(string reason = "Killed for no reason!") { |
madcowswe | 0:9fcb3bf5c231 | 8 | PWMleft = NOPOWER - 0.004; |
madcowswe | 0:9fcb3bf5c231 | 9 | PWMright = NOPOWER - 0.004; |
madcowswe | 0:9fcb3bf5c231 | 10 | PWMfront = NOPOWER - 0.004; |
madcowswe | 0:9fcb3bf5c231 | 11 | PWMrear = NOPOWER - 0.004; |
madcowswe | 0:9fcb3bf5c231 | 12 | //TODO: send this over RF as well.. |
madcowswe | 0:9fcb3bf5c231 | 13 | pc.printf("%s\r\n", reason.c_str()); |
madcowswe | 0:9fcb3bf5c231 | 14 | /*wait(0.5); |
madcowswe | 0:9fcb3bf5c231 | 15 | left = 0; |
madcowswe | 0:9fcb3bf5c231 | 16 | right = 0; |
madcowswe | 0:9fcb3bf5c231 | 17 | front = 0; |
madcowswe | 0:9fcb3bf5c231 | 18 | rear = 0; |
madcowswe | 0:9fcb3bf5c231 | 19 | */ |
madcowswe | 0:9fcb3bf5c231 | 20 | while (1); |
madcowswe | 0:9fcb3bf5c231 | 21 | } |
madcowswe | 0:9fcb3bf5c231 | 22 | |
madcowswe | 0:9fcb3bf5c231 | 23 | // |
madcowswe | 0:9fcb3bf5c231 | 24 | void wdt() { |
madcowswe | 0:9fcb3bf5c231 | 25 | if (!loopalive) |
madcowswe | 0:9fcb3bf5c231 | 26 | kill("Killed by WDT: loop has stalled"); |
madcowswe | 0:9fcb3bf5c231 | 27 | if (!commandsalive) |
madcowswe | 0:9fcb3bf5c231 | 28 | kill("Killed by WDT: command starvation"); |
madcowswe | 0:9fcb3bf5c231 | 29 | |
madcowswe | 0:9fcb3bf5c231 | 30 | loopalive = 0; |
madcowswe | 0:9fcb3bf5c231 | 31 | commandsalive = 0; |
madcowswe | 0:9fcb3bf5c231 | 32 | } |