Skip to content

Commit

Permalink
[MF_DAQ] add power control with a gpio
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Feb 22, 2014
1 parent 3109bc4 commit 782f996
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions conf/settings/modules/meteo_france_DAQ.xml
@@ -0,0 +1,12 @@
<!DOCTYPE settings SYSTEM "../settings.dtd">

<settings>
<dl_settings NAME="MF DAQ control">
<dl_settings NAME="MF DAQ">
<dl_setting MAX="1" MIN="0" STEP="1" VAR="mf_daq.power" module="meteo/meteo_france_DAQ" handler="SetPower" values="OFF|ON">
<strip_button name="MF DAQ power on" icon="on.png" value="1" group="MF_DAQ"/>
<strip_button name="MF DAQ power off" icon="off.png" value="0" group="MF_DAQ"/>
</dl_setting>
</dl_settings>
</dl_settings>
</settings>
10 changes: 10 additions & 0 deletions sw/airborne/modules/meteo/meteo_france_DAQ.c
Expand Up @@ -35,6 +35,7 @@

#include "state.h"
#include "autopilot.h"
#include "generated/airframe.h"
#include "subsystems/datalink/datalink.h"
#include "subsystems/datalink/downlink.h"
#include "subsystems/chibios-libopencm3/sdLog.h"
Expand All @@ -44,8 +45,17 @@

struct MF_DAQ mf_daq;

#ifndef MF_DAQ_POWER_INIT
#define MF_DAQ_POWER_INIT TRUE
#endif

void init_mf_daq(void) {
mf_daq.nb = 0;
mf_daq.power = MF_DAQ_POWER_INIT;
#if (defined MF_DAQ_POWER_PORT) && (defined MF_DAQ_POWER_PIN)
gpio_setup_output(MF_DAQ_POWER_PORT, MF_DAQ_POWER_PIN);
#endif
meteo_france_DAQ_SetPower(mf_daq.power)
}

void mf_daq_send_state(void) {
Expand Down
12 changes: 12 additions & 0 deletions sw/airborne/modules/meteo/meteo_france_DAQ.h
Expand Up @@ -35,12 +35,14 @@
#define METEO_FRANCE_DAQ_H

#include "std.h"
#include "mcu_periph/gpio.h"

#define MF_DAQ_SIZE 32

struct MF_DAQ {
float values[MF_DAQ_SIZE];
uint8_t nb;
uint8_t power;
};

extern struct MF_DAQ mf_daq;
Expand All @@ -50,5 +52,15 @@ extern void mf_daq_send_state(void);
extern void mf_daq_send_report(void);
extern void parse_mf_daq_msg(void);

#if (defined MF_DAQ_POWER_PORT) && (defined MF_DAQ_POWER_PIN)
#define meteo_france_DAQ_SetPower(_x) { \
mf_daq.power = _x; \
if (mf_daq.power) { gpio_set(MF_DAQ_POWER_PORT, MF_DAQ_POWER_PIN); } \
else { gpio_clear(MF_DAQ_POWER_PORT, MF_DAQ_POWER_PIN); } \
}
#else // POWER PORT and PIN undefined
#define meteo_france_DAQ_SetPower(_x) {}
#endif

#endif

0 comments on commit 782f996

Please sign in to comment.