diff options
author | px4dev <px4@purgatory.org> | 2012-12-20 21:31:02 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-12-20 21:31:02 -0800 |
commit | 5b92c517779500d79e6e5f5cff48336550ce5edb (patch) | |
tree | 38cf26fd5718c53c4cbe99e7433791ee45430902 /apps/px4io | |
parent | f40e4d13aa1c6cd854b848f1cd0c3a017e719138 (diff) | |
download | px4-firmware-5b92c517779500d79e6e5f5cff48336550ce5edb.tar.gz px4-firmware-5b92c517779500d79e6e5f5cff48336550ce5edb.tar.bz2 px4-firmware-5b92c517779500d79e6e5f5cff48336550ce5edb.zip |
Initial implementation of application access to the PX4IO relays.
Diffstat (limited to 'apps/px4io')
-rw-r--r-- | apps/px4io/comms.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/apps/px4io/comms.c b/apps/px4io/comms.c index 40ea38cf7..ffb7fd679 100644 --- a/apps/px4io/comms.c +++ b/apps/px4io/comms.c @@ -178,7 +178,7 @@ comms_handle_command(const void *buffer, size_t length) system_state.fmu_channel_data[i] = cmd->servo_command[i]; /* if the IO is armed and the FMU gets disarmed, the IO must also disarm */ - if(system_state.arm_ok && !cmd->arm_ok) { + if (system_state.arm_ok && !cmd->arm_ok) { system_state.armed = false; } @@ -191,9 +191,26 @@ comms_handle_command(const void *buffer, size_t length) // if (!system_state.arm_ok && system_state.armed) // system_state.armed = false; - /* XXX do relay changes here */ - for (unsigned i = 0; i < PX4IO_RELAY_CHANNELS; i++) - system_state.relays[i] = cmd->relay_state[i]; + /* handle relay state changes here */ + for (unsigned i = 0; i < PX4IO_RELAY_CHANNELS; i++) { + if (system_state.relays[i] != cmd->relay_state[i]) { + switch (i) { + case 0: + POWER_ACC1(cmd->relay_state[i]); + break; + case 1: + POWER_ACC2(cmd->relay_state[i]); + break; + case 2: + POWER_RELAY1(cmd->relay_state[i]); + break; + case 3: + POWER_RELAY2(cmd->relay_state[i]); + break; + } + } + system_state.relays[i] != cmd->relay_state[i] + } irqrestore(flags); } |