Rev 2052 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2052 | Rev 2189 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _OUTPUT_H |
1 | #ifndef _OUTPUT_H |
2 | #define _OUTPUT_H |
2 | #define _OUTPUT_H |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | #include <avr/io.h> |
- | |
5 | - | ||
6 | #define J3HIGH PORTD |= (1<<PORTD5) |
- | |
7 | #define J3LOW PORTD &= ~(1<<PORTD5) |
- | |
8 | #define J3TOGGLE PORTD ^= (1<<PORTD5) |
- | |
9 | - | ||
10 | #define J4HIGH PORTD |= (1<<PORTD4) |
- | |
11 | #define J4LOW PORTD &= ~(1<<PORTD4) |
- | |
12 | #define J4TOGGLE PORTD ^= (1<<PORTD4) |
- | |
13 | - | ||
14 | #define J5HIGH PORTD |= (1<<PORTD3) |
- | |
15 | #define J5LOW PORTD &= ~(1<<PORTD3) |
- | |
16 | #define J5TOGGLE PORTD ^= (1<<PORTD3) |
- | |
17 | - | ||
18 | // invert means: An "1" bit in digital debug data make a LOW on the output. |
4 | #include <avr/io.h> |
Line 19... | Line 5... | ||
19 | #define DIGITAL_DEBUG_INVERT 0 |
5 | #include "configuration.h" |
20 | 6 | ||
21 | #define OUTPUT_HIGH(num) {PORTC |= (4 << (num));} |
7 | #define OUTPUT_HIGH(num) {PORTC |= (4 << (num));} |
Line 22... | Line -... | ||
22 | #define OUTPUT_LOW(num) {PORTC &= ~(4 << (num));} |
- | |
23 | #define OUTPUT_TOGGLE(num) ( {PORTC ^= (4 << (num));} |
- | |
24 | - | ||
25 | /* |
- | |
26 | * Some digital debugs. A digital debug is 2 signals on the 2 LED outputs, |
- | |
27 | * turned on and off depending on some condtions given in the code. |
8 | #define OUTPUT_LOW(num) {PORTC &= ~(4 << (num));} |
28 | * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value |
9 | #define OUTPUT_TOGGLE(num) ( {PORTC ^= (4 << (num));} |
29 | * of the debug. |
- | |
30 | * In the code one can do like: |
- | |
31 | * if (whatever_condition) { |
- | |
32 | * DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER; |
- | |
33 | * } else { |
- | |
34 | * DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER; |
10 | |
35 | * } |
- | |
36 | * ... |
- | |
37 | * if (whatever_other_condition) { |
- | |
38 | * DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER; |
- | |
39 | * } else { |
- | |
40 | * DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER; |
- | |
41 | * } |
11 | // Control terms (multicopter) |
42 | * |
- | |
Line 43... | Line -... | ||
43 | * Digital debugs may be added as desired, and removed when the mystery |
- | |
44 | * at hand is resolved. |
- | |
45 | */ |
- | |
46 | - | ||
47 | #define DEBUG_MAINLOOP_TIMER 1 |
- | |
48 | #define DEBUG_HEIGHT_DIFF 2 |
- | |
49 | #define DEBUG_FLIGHTCLIP 4 |
- | |
50 | #define DEBUG_ACC0THORDER 8 |
- | |
51 | #define DEBUG_COMPASS 16 |
- | |
52 | #define DEBUG_PRESSURERANGE 32 |
- | |
53 | #define DEBUG_CLIP 64 |
- | |
54 | #define DEBUG_SENSORLIMIT 128 |
- | |
55 | - | ||
56 | #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) |
- | |
57 | #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) |
- | |
58 | #define OUTPUTFLAGS_FLASH_0_AT_BEEP 4 // Flash LED when beeper beeps |
- | |
59 | #define OUTPUTFLAGS_FLASH_1_AT_BEEP 8 // Flash LED when beeper beeps |
- | |
60 | #define OUTPUTFLAGS_USE_ONBOARD_LEDS 16 // Control on-board LEDs in addition to outputs |
12 | // TODO: Multicopter stuff separate? |
61 | #define OUTPUTFLAGS_TEST_OFF 32 // For testing: Turn off both outputs |
- | |
62 | #define OUTPUTFLAGS_TEST_ON 64 // For testing: Turn on both outputs |
- | |
63 | 13 | extern int16_t throttleTerm; |
|
64 | // For practical reasons put here instead of in uart0.h |
- | |
Line 65... | Line -... | ||
65 | typedef struct { |
- | |
Line 66... | Line 14... | ||
66 | uint8_t digital[2]; |
14 | extern int32_t yawTerm, term[2]; |
67 | uint16_t analog[32]; // debug values |
15 | |
68 | }__attribute__((packed)) DebugOut_t; |
16 | // I2C and PWM motor and servo outputs. |
69 | 17 | // extern int16_t outputs[NUM_OUTPUTS]; |
|
70 | extern DebugOut_t debugOut; |
18 | |
Line 71... | Line 19... | ||
71 | 19 | ||
72 | /* |
20 | /* |
73 | * Set to 0 for using outputs as the usual flashing lights. |
21 | * Set to 0 for using outputs as the usual flashing lights. |
74 | * Set to one of the DEBUG_... defines h for using the outputs as debug lights. |
- | |
75 | */ |
- | |
76 | #define DIGITAL_DEBUG_MASK 0 |
- | |
77 | 22 | * Set to one of the DEBUG_... defines h for using the outputs as debug lights. |
|
78 | void output_init(void); |
23 | */ |
Line 79... | Line 24... | ||
79 | void outputSet(uint8_t num, uint8_t state); |
24 | #define DIGITAL_DEBUG_MASK 0 |