Subversion Repositories FlightCtrl

Rev

Rev 1842 | Rev 1864 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1842 Rev 1854
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
 
Line 4... Line -...
4
#include <avr/io.h>
-
 
5
 
-
 
6
// This is for LEDs connected directly between +5V and the AVR port, without transistors.
-
 
7
// PORTbit = 0 --> LED on.
-
 
8
// To use the normal transistor set-up where 1 --> transistor conductive, reverse the 
-
 
9
// ON and OFF statements.
4
#include <avr/io.h>
10
 
5
 
-
 
6
// invert means: An "1" bit in digital debug data make a LOW on the output.
11
// invert means: An "1" bit in digital debug data make a LOW on the output.
7
#define DIGITAL_DEBUG_INVERT 1
12
#define DIGITAL_DEBUG_INVERT 1
8
 
13
#define OUTPUT_HIGH(num)        {PORTC |=  (4 << (num));}
9
#define OUTPUT_HIGH(num)        {PORTC |=  (4 << (num));}
14
#define OUTPUT_LOW(num)         {PORTC &= ~(4 << (num));}
10
#define OUTPUT_LOW(num)         {PORTC &= ~(4 << (num));}
Line -... Line 11...
-
 
11
#define OUTPUT_SET(num, state)  {if (DIGITAL_DEBUG_INVERT){if(state) OUTPUT_LOW(num) else OUTPUT_HIGH(num)} else {if(state) OUTPUT_HIGH(num) else OUTPUT_LOW(num)}}
-
 
12
#define OUTPUT_TOGGLE(num) (    {PORTC ^=  (4 << (num));}
-
 
13
 
-
 
14
/*
-
 
15
 * Some digital debugs. A digital debug is 2 signals on the 2 LED outputs,
-
 
16
 * turned on and off depending on some condtions given in the code.
-
 
17
 * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value
-
 
18
 * of the debug.
-
 
19
 * In the code one can do like:
-
 
20
 * if (whatever_condition) {
-
 
21
 *      DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER;
-
 
22
 * } else {
-
 
23
 *      DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER;
-
 
24
 * }
-
 
25
 * ...
-
 
26
 * if (whatever_other_condition) {
-
 
27
 *      DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER;
-
 
28
 * } else {
-
 
29
 *      DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER;
-
 
30
 * }
-
 
31
 *
15
#define OUTPUT_SET(num, state)  {if (DIGITAL_DEBUG_INVERT){if(state) OUTPUT_LOW(num) else OUTPUT_HIGH(num)} else {if(state) OUTPUT_HIGH(num) else OUTPUT_LOW(num)}}
32
 * Digital debugs may be added as desired, and removed when the mystery
16
#define OUTPUT_TOGGLE(num) (    {PORTC ^=  (4 << (num));}
33
 * at hand is resolved.
17
 
34
 */
18
#define DEBUG_LEDTEST 256
35
#define DEBUG_LEDTEST 256
19
#define DEBUG_HEIGHT_SWITCH 1
36
#define DEBUG_HEIGHT_SWITCH 1
20
#define DEBUG_HEIGHT_DIFF 2
37
#define DEBUG_HEIGHT_DIFF 2
21
#define DEBUG_HOVERTHROTTLE 4
38
#define DEBUG_HOVERTHROTTLE 4
22
#define DEBUG_ACC0THORDER 8
39
#define DEBUG_ACC0THORDER 8
-
 
40
#define DEBUG_COMMANDREPEATED 16
-
 
41
#define DEBUG_PRESSURERANGE 32
-
 
42
#define DEBUG_CLIP 64
-
 
43
#define DEBUG_SENSORLIMIT 128
-
 
44
 
-
 
45
/*
-
 
46
 * Set to 0 for using outputs as the usual flashing lights.
Line 23... Line 47...
23
#define DEBUG_COMMANDREPEATED 16
47
 * Set to one of the DEBUG_... defines h for using the outputs as debug lights.
24
#define DEBUG_PRESSURERANGE 32
48
 */
Line 25... Line 49...
25
#define DEBUG_CLIP 64
49
#define DIGITAL_DEBUG_MASK DEBUG_CLIP