Subversion Repositories FlightCtrl

Rev

Rev 1986 | Rev 2052 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef _OUTPUT_H
#define _OUTPUT_H

#include <avr/io.h>

#define J3HIGH    PORTD |= (1<<PORTD5)
#define J3LOW     PORTD &= ~(1<<PORTD5)
#define J3TOGGLE  PORTD ^= (1<<PORTD5)

#define J4HIGH    PORTD |= (1<<PORTD4)
#define J4LOW     PORTD &= ~(1<<PORTD4)
#define J4TOGGLE  PORTD ^= (1<<PORTD4)

#define J5HIGH    PORTD |= (1<<PORTD3)
#define J5LOW     PORTD &= ~(1<<PORTD3)
#define J5TOGGLE  PORTD ^= (1<<PORTD3)

// invert means: An "1" bit in digital debug data make a LOW on the output.
#define DIGITAL_DEBUG_INVERT 0

#define OUTPUT_HIGH(num)        {PORTC |=  (4 << (num));}
#define OUTPUT_LOW(num)         {PORTC &= ~(4 << (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_MAINLOOP_TIMER 1
#define DEBUG_HEIGHT_DIFF    2
#define DEBUG_HOVERTHROTTLE  4
#define DEBUG_ACC0THORDER    8
#define DEBUG_COMPASS       16
#define DEBUG_PRESSURERANGE 32
#define DEBUG_CLIP          64
#define DEBUG_SENSORLIMIT  128

#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)
#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)
#define OUTPUTFLAGS_FLASH_0_AT_BEEP  4 // Flash LED when beeper beeps
#define OUTPUTFLAGS_FLASH_1_AT_BEEP  8 // Flash LED when beeper beeps
#define OUTPUTFLAGS_USE_ONBOARD_LEDS 16 // Control on-board LEDs in addition to outputs
#define OUTPUTFLAGS_TEST_OFF         32 // For testing: Turn off both outputs
#define OUTPUTFLAGS_TEST_ON          64 // For testing: Turn on both outputs

/*
 * 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 0

void output_init(void);
void outputSet(uint8_t num, uint8_t state);
void output_update(void);
void beep(uint16_t millis);
void beepNumber(uint8_t numbeeps);
void beepRCAlarm(void);
void beepI2CAlarm(void);
void beepBatteryAlarm(void);

#endif //_output_H