Subversion Repositories FlightCtrl

Rev

Rev 1964 | Rev 1986 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1964 Rev 1968
1
#ifndef _OUTPUT_H
1
#ifndef _OUTPUT_H
2
#define _OUTPUT_H
2
#define _OUTPUT_H
3
 
3
 
4
#include <avr/io.h>
4
#include <avr/io.h>
5
 
5
 
6
#define J3HIGH    PORTD |= (1<<PORTD5)
6
#define J3HIGH    PORTD |= (1<<PORTD5)
7
#define J3LOW     PORTD &= ~(1<<PORTD5)
7
#define J3LOW     PORTD &= ~(1<<PORTD5)
8
#define J3TOGGLE  PORTD ^= (1<<PORTD5)
8
#define J3TOGGLE  PORTD ^= (1<<PORTD5)
9
 
9
 
10
#define J4HIGH    PORTD |= (1<<PORTD4)
10
#define J4HIGH    PORTD |= (1<<PORTD4)
11
#define J4LOW     PORTD &= ~(1<<PORTD4)
11
#define J4LOW     PORTD &= ~(1<<PORTD4)
12
#define J4TOGGLE  PORTD ^= (1<<PORTD4)
12
#define J4TOGGLE  PORTD ^= (1<<PORTD4)
13
 
13
 
14
#define J5HIGH    PORTD |= (1<<PORTD3)
14
#define J5HIGH    PORTD |= (1<<PORTD3)
15
#define J5LOW     PORTD &= ~(1<<PORTD3)
15
#define J5LOW     PORTD &= ~(1<<PORTD3)
16
#define J5TOGGLE  PORTD ^= (1<<PORTD3)
16
#define J5TOGGLE  PORTD ^= (1<<PORTD3)
17
 
17
 
18
// invert means: An "1" bit in digital debug data make a LOW on the output.
18
// invert means: An "1" bit in digital debug data make a LOW on the output.
19
#define DIGITAL_DEBUG_INVERT 0
19
#define DIGITAL_DEBUG_INVERT 0
20
 
20
 
21
#define OUTPUT_HIGH(num)        {PORTC |=  (4 << (num));}
21
#define OUTPUT_HIGH(num)        {PORTC |=  (4 << (num));}
22
#define OUTPUT_LOW(num)         {PORTC &= ~(4 << (num));}
22
#define OUTPUT_LOW(num)         {PORTC &= ~(4 << (num));}
23
#define OUTPUT_TOGGLE(num) (    {PORTC ^=  (4 << (num));}
23
#define OUTPUT_TOGGLE(num) (    {PORTC ^=  (4 << (num));}
24
 
24
 
25
/*
25
/*
26
 * Some digital debugs. A digital debug is 2 signals on the 2 LED outputs,
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.
27
 * turned on and off depending on some condtions given in the code.
28
 * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value
28
 * Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value
29
 * of the debug.
29
 * of the debug.
30
 * In the code one can do like:
30
 * In the code one can do like:
31
 * if (whatever_condition) {
31
 * if (whatever_condition) {
32
 *      DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER;
32
 *      DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER;
33
 * } else {
33
 * } else {
34
 *      DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER;
34
 *      DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER;
35
 * }
35
 * }
36
 * ...
36
 * ...
37
 * if (whatever_other_condition) {
37
 * if (whatever_other_condition) {
38
 *      DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER;
38
 *      DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER;
39
 * } else {
39
 * } else {
40
 *      DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER;
40
 *      DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER;
41
 * }
41
 * }
42
 *
42
 *
43
 * Digital debugs may be added as desired, and removed when the mystery
43
 * Digital debugs may be added as desired, and removed when the mystery
44
 * at hand is resolved.
44
 * at hand is resolved.
45
 */
45
 */
46
 
-
 
47
// Both on
-
 
48
#define DEBUG_LEDTEST_ON  1000
-
 
49
 
-
 
50
// Both off
-
 
51
#define DEBUG_LEDTEST_OFF 1001
-
 
52
 
-
 
53
// #0 on
-
 
54
#define DEBUG_LEDTEST_0   1002
-
 
55
 
-
 
56
// #1 on
-
 
57
#define DEBUG_LEDTEST_1   1003
-
 
58
 
46
 
59
#define DEBUG_MAINLOOP_TIMER 1
47
#define DEBUG_MAINLOOP_TIMER 1
60
#define DEBUG_HEIGHT_DIFF    2
48
#define DEBUG_HEIGHT_DIFF    2
61
#define DEBUG_HOVERTHROTTLE  4
49
#define DEBUG_HOVERTHROTTLE  4
62
#define DEBUG_ACC0THORDER    8
50
#define DEBUG_ACC0THORDER    8
63
#define DEBUG_SIGNAL        16
51
#define DEBUG_SIGNAL        16
64
#define DEBUG_PRESSURERANGE 32
52
#define DEBUG_PRESSURERANGE 32
65
#define DEBUG_CLIP          64
53
#define DEBUG_CLIP          64
66
#define DEBUG_SENSORLIMIT  128
54
#define DEBUG_SENSORLIMIT  128
67
 
55
 
68
#define OUTPUTOPTIONS_INVERT_0         1
56
#define OUTPUTOPTIONS_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)
69
#define OUTPUTOPTIONS_INVERT_1         2
57
#define OUTPUTOPTIONS_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)
70
#define OUTPUTOPTIONS_FLASH_AT_BEEP    4
58
#define OUTPUTOPTIONS_FLASH_AT_BEEP    4 // Flash LEDs when beeper beeps
71
#define OUTPUTOPTIONS_USE_ONBOARD_LEDS 8
59
#define OUTPUTOPTIONS_USE_ONBOARD_LEDS 8 // Control on-board LEDs in addition to outputs
72
#define OUTPUTOPTIONS_TEST_LO         64
60
#define OUTPUTOPTIONS_TEST_OFF        64 // For testing: Turn off both outputs
73
#define OUTPUTOPTIONS_TEST_HI        128 
61
#define OUTPUTOPTIONS_TEST_ON        128 // For testing: Turn on both outputs
74
 
62
 
75
/*
63
/*
76
 * Set to 0 for using outputs as the usual flashing lights.
64
 * Set to 0 for using outputs as the usual flashing lights.
77
 * Set to one of the DEBUG_... defines h for using the outputs as debug lights.
65
 * Set to one of the DEBUG_... defines h for using the outputs as debug lights.
78
 */
66
 */
79
#define DIGITAL_DEBUG_MASK 0
67
#define DIGITAL_DEBUG_MASK 0
80
 
68
 
81
void output_init(void);
69
void output_init(void);
82
void outputSet(uint8_t num, uint8_t state);
70
void outputSet(uint8_t num, uint8_t state);
83
void output_update(void);
71
void output_update(void);
84
void beep(uint16_t millis);
72
void beep(uint16_t millis);
85
void beepNumber(uint8_t numbeeps);
73
void beepNumber(uint8_t numbeeps);
86
void beepRCAlarm(void);
74
void beepRCAlarm(void);
87
void beepI2CAlarm(void);
75
void beepI2CAlarm(void);
88
void beepBatteryAlarm(void);
76
void beepBatteryAlarm(void);
89
 
77
 
90
#endif //_output_H
78
#endif //_output_H
91
 
79