Add support for sending airspeed over can bus

This commit is contained in:
Allen Ibara
2010-01-19 20:20:14 +00:00
parent ee990ff81d
commit b45fdbe6ce
6 changed files with 31 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
#include "csc_airspeed.h"
#include "csc_ap_link.h"
float estimator_airspeed;
void csc_airspeed_periodic(void)
{
csc_ap_link_send_airspeed(estimator_airspeed, 0);
}
+1
View File
@@ -0,0 +1 @@
void csc_airspeed_periodic(void);
+12
View File
@@ -47,6 +47,18 @@ void csc_ap_link_send_vane(float *vane_angles)
}
void csc_ap_link_send_airspeed(float airspeed1, float airspeed2)
{
struct CscAirspeedMsg msg;
msg.airspeed1 = airspeed1;
msg.airspeed2 = airspeed2;
csc_ap_send_msg(CSC_AIRSPEED_MSG_ID, (const uint8_t *) &msg, sizeof(msg));
}
// Generic function for sending can messages
void can_write_csc(uint8_t board_id, uint8_t msg_id, const uint8_t *buf, uint8_t len)
{
+1
View File
@@ -15,6 +15,7 @@ void can_write_csc(uint8_t board_id, uint8_t msg_id, const uint8_t *buf, uint8_t
void csc_ap_link_send_status(uint32_t loops, uint32_t msgs);
void csc_ap_link_send_adc(float adc1, float adc2);
void csc_ap_link_send_vane(float *vane_angle);
void csc_ap_link_send_airspeed(float airspeed1, float airspeed2);
void csc_ap_link_set_servo_cmd_cb(void (* cb)(struct CscServoCmd *cmd));
void csc_ap_link_set_motor_cmd_cb(void (* cb)(struct CscMotorMsg *msg));
void csc_ap_link_set_prop_cmd_cb(void (* cb)(struct CscPropCmd *cmd, int idx));
+6
View File
@@ -19,6 +19,7 @@
#define CSC_GPS_ACC_ID 9
#define CSC_PROP2_CMD_ID 10
#define CSC_VANE_MSG_ID 11
#define CSC_AIRSPEED_MSG_ID 12
/* Received from the autopilot */
@@ -79,6 +80,11 @@ struct CscVaneMsg {
float vane_angle2;
} __attribute__((packed));
struct CscAirspeedMsg {
float airspeed1;
float airspeed2;
} __attribute__((packed));
#define CSC_RC_SCALE 20
#define CSC_RC_OFFSET 2*(MAX_PPRZ/CSC_RC_SCALE) /* Sorry this is a bit arbitrary. - mmt */
+2
View File
@@ -50,6 +50,7 @@
#include "periodic.h"
#include "downlink.h"
#include "pwm_input.h"
#include "csc_airspeed.h"
#include "csc_adc.h"
#include "csc_rc_spektrum.h"
@@ -173,6 +174,7 @@ static void csc_main_periodic( void ) {
#ifdef USE_AIRSPEED
airspeed_update();
csc_airspeed_periodic();
#endif
}