diff --git a/conf/settings/dc.xml b/conf/settings/dc.xml new file mode 100644 index 0000000000..3ddacf01c2 --- /dev/null +++ b/conf/settings/dc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/sw/airborne/dc.c b/sw/airborne/dc.c new file mode 100644 index 0000000000..245124549c --- /dev/null +++ b/sw/airborne/dc.c @@ -0,0 +1,3 @@ +#include "dc.h" + +uint8_t dc_timer; diff --git a/sw/airborne/dc.h b/sw/airborne/dc.h new file mode 100644 index 0000000000..504155d722 --- /dev/null +++ b/sw/airborne/dc.h @@ -0,0 +1,47 @@ +#ifndef DC_H +#define DC_H + +#include + +extern uint8_t dc_timer; + +#ifdef SITL + +#define dc_Shutter(_) { } +#define dc_Zoom(_) { } + +#else /* SITL */ + +#include "LPC21xx.h" +#include "std.h" + +#define SHUTTER_DELAY 2 /* 4Hz */ +#define SHUTTER_BANK 0 /* Grey */ +#define SHUTTER_PIN 16 + +#define ZOOM_BANK 1 +#define ZOOM_PIN 20 + +static inline uint8_t dc_shutter() { + dc_timer = SHUTTER_DELAY; + IO0SET = _BV(SHUTTER_PIN); + return 0; +} + +static inline uint8_t dc_zoom() { + dc_timer = SHUTTER_DELAY; + IO1SET = _BV(ZOOM_PIN); + return 0; +} + +#define dc_Shutter(_) { dc_shutter(); } +#define dc_Zoom(_) { dc_zoom(); } + +#define dc_init() { IO0DIR |= _BV(SHUTTER_PIN); IO0CLR = _BV(SHUTTER_PIN); ClearBit(PINSEL2, 3); IO1DIR |= _BV(ZOOM_PIN); IO1CLR = _BV(ZOOM_PIN); } /* Output */ + +/* 4Hz */ +#define dc_periodic() { if (dc_timer) { dc_timer--; } else { IO0CLR = _BV(SHUTTER_PIN); IO1CLR = _BV(ZOOM_PIN); } } + +#endif /* ! SITL */ + +#endif