Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1853 → Rev 1854

/branches/dongfang_FC_rewrite/output.h
3,18 → 3,35
 
#include <avr/io.h>
 
// This is for LEDs connected directly between +5V and the AVR port, without transistors.
// PORTbit = 0 --> LED on.
// To use the normal transistor set-up where 1 --> transistor conductive, reverse the
// ON and OFF statements.
 
// invert means: An "1" bit in digital debug data make a LOW on the output.
#define DIGITAL_DEBUG_INVERT 1
 
#define OUTPUT_HIGH(num) {PORTC |= (4 << (num));}
#define OUTPUT_LOW(num) {PORTC &= ~(4 << (num));}
#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)}}
#define OUTPUT_TOGGLE(num) ( {PORTC ^= (4 << (num));}
 
/*
* Some digital debugs. A digital debug is 2 signals on the 2 LED outputs,
* turned on and off depending on some condtions given in the code.
* Only one can be selected, by defining DIGITAL_DEBUG_MASK to the value
* of the debug.
* In the code one can do like:
* if (whatever_condition) {
* DebugOut.Digital[0] |= DEBUG_MYOWNDEBUGGER;
* } else {
* DebugOut.Digital[0] &= ~DEBUG_MYOWNDEBUGGER;
* }
* ...
* if (whatever_other_condition) {
* DebugOut.Digital[1] |= DEBUG_MYOWNDEBUGGER;
* } else {
* DebugOut.Digital[1] &= ~DEBUG_MYOWNDEBUGGER;
* }
*
* Digital debugs may be added as desired, and removed when the mystery
* at hand is resolved.
*/
#define DEBUG_LEDTEST 256
#define DEBUG_HEIGHT_SWITCH 1
#define DEBUG_HEIGHT_DIFF 2
23,7 → 40,14
#define DEBUG_COMMANDREPEATED 16
#define DEBUG_PRESSURERANGE 32
#define DEBUG_CLIP 64
#define DEBUG_SENSORLIMIT 128
 
/*
* Set to 0 for using outputs as the usual flashing lights.
* Set to one of the DEBUG_... defines h for using the outputs as debug lights.
*/
#define DIGITAL_DEBUG_MASK DEBUG_CLIP
 
void output_init(void);
void output_update(void);