Rev 2135 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2108 | - | 1 | #ifndef _OUTPUT_H |
2 | #define _OUTPUT_H |
||
3 | |||
4 | #include <avr/io.h> |
||
5 | |||
2110 | - | 6 | #define PD2HIGH PORTD |= (1<<PORTD2) |
7 | #define PD2LOW PORTD &= ~(1<<PORTD2) |
||
8 | #define PD2TOGGLE PORTD ^= (1<<PORTD2) |
||
2108 | - | 9 | |
10 | // invert means: An "1" bit in digital debug data make a LOW on the output. |
||
11 | #define DIGITAL_DEBUG_INVERT 0 |
||
12 | |||
2135 | - | 13 | #define OUTPUT_HIGH(num) {PORTB |= ((1<<1) << (num));} |
14 | #define OUTPUT_LOW(num) {PORTB &= ~((1<<1) << (num));} |
||
15 | #define OUTPUT_TOGGLE(num) ( {PORTB ^= ((1<<1) << (num));} |
||
2108 | - | 16 | |
17 | /* |
||
18 | * Some digital debugs. A digital debug is 2 signals on the 2 LED outputs, |
||
19 | * turned on and off depending on some condtions given in the code. |
||
20 | * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value |
||
21 | * of the debug. |
||
22 | * In the code one can do like: |
||
23 | * if (whatever_condition) { |
||
24 | * DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER; |
||
25 | * } else { |
||
26 | * DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER; |
||
27 | * } |
||
28 | * ... |
||
29 | * if (whatever_other_condition) { |
||
30 | * DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER; |
||
31 | * } else { |
||
32 | * DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER; |
||
33 | * } |
||
34 | * |
||
35 | * Digital debugs may be added as desired, and removed when the mystery |
||
36 | * at hand is resolved. |
||
37 | */ |
||
38 | |||
39 | #define DEBUG_MAINLOOP_TIMER 1 |
||
2143 | - | 40 | #define DEBUG_AIRSPEED 2 |
2108 | - | 41 | #define DEBUG_FLIGHTCLIP 4 |
42 | #define DEBUG_ACC0THORDER 8 |
||
43 | #define DEBUG_COMPASS 16 |
||
44 | #define DEBUG_PRESSURERANGE 32 |
||
45 | #define DEBUG_CLIP 64 |
||
46 | #define DEBUG_SENSORLIMIT 128 |
||
47 | |||
48 | #define OUTPUTFLAGS_INVERT_0 1 // Inverted: 1 means low output on atmega. Does not affect on-board LED (if used with the OUTPUTOPTIONS_USE_ONBOARD_LEDS option) |
||
49 | #define OUTPUTFLAGS_INVERT_1 2 // Inverted: 1 means low output on atmega. Does not affect on-board LED (if used with the OUTPUTOPTIONS_USE_ONBOARD_LEDS option) |
||
50 | #define OUTPUTFLAGS_FLASH_0_AT_BEEP 4 // Flash LED when beeper beeps |
||
51 | #define OUTPUTFLAGS_FLASH_1_AT_BEEP 8 // Flash LED when beeper beeps |
||
52 | #define OUTPUTFLAGS_USE_ONBOARD_LEDS 16 // Control on-board LEDs in addition to outputs |
||
53 | #define OUTPUTFLAGS_TEST_OFF 32 // For testing: Turn off both outputs |
||
54 | #define OUTPUTFLAGS_TEST_ON 64 // For testing: Turn on both outputs |
||
55 | |||
56 | // For practical reasons put here instead of in uart0.h |
||
57 | typedef struct { |
||
58 | uint8_t digital[2]; |
||
59 | uint16_t analog[32]; // debug values |
||
60 | }__attribute__((packed)) DebugOut_t; |
||
61 | |||
62 | extern DebugOut_t debugOut; |
||
63 | |||
64 | /* |
||
65 | * Set to 0 for using outputs as the usual flashing lights. |
||
66 | * Set to one of the DEBUG_... defines h for using the outputs as debug lights. |
||
67 | */ |
||
68 | #define DIGITAL_DEBUG_MASK 0 |
||
69 | |||
70 | void output_init(void); |
||
71 | void outputSet(uint8_t num, uint8_t state); |
||
72 | void output_update(void); |
||
73 | void beep(uint16_t millis); |
||
74 | void beepNumber(uint8_t numbeeps); |
||
75 | void beepRCAlarm(void); |
||
76 | void beepBatteryAlarm(void); |
||
77 | |||
78 | #endif //_output_H |