1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Airspeed module works, needs conversion

This commit is contained in:
Corvus Corax 2012-04-17 20:32:56 +02:00
parent 317cff10dd
commit 3da88601a1
2 changed files with 7 additions and 8 deletions

View File

@ -47,7 +47,7 @@
// Private constants // Private constants
#define STACK_SIZE_BYTES 500 #define STACK_SIZE_BYTES 500
#define TASK_PRIORITY (tskIDLE_PRIORITY+1) #define TASK_PRIORITY (tskIDLE_PRIORITY+1)
#define SENSITIVE_DELAY_MS 500 #define SAMPLING_DELAY_MS 50
// Private types // Private types
@ -113,17 +113,16 @@ static void airspeedTask(void *parameters)
// TODO: Check the pressure sensor and set a warning if it fails test // TODO: Check the pressure sensor and set a warning if it fails test
float test=0;
// Main task loop // Main task loop
while (1) while (1)
{ {
float airspeed; float airspeed;
// Update the airspeed // Update the airspeed
vTaskDelay(SENSITIVE_DELAY_MS); vTaskDelay(SAMPLING_DELAY_MS);
airspeed = PIOS_ETASV3_ReadAirspeed(); airspeed = PIOS_ETASV3_ReadAirspeed();
data.Airspeed = (test++)*1000.0f + airspeed; data.Airspeed = airspeed;
// Update the AirspeedActual UAVObject // Update the AirspeedActual UAVObject
BaroAirspeedSet(&data); BaroAirspeedSet(&data);

View File

@ -42,14 +42,14 @@ static bool PIOS_ETASV3_Read(uint8_t command, uint8_t * buffer, uint8_t len)
}; };
const struct pios_i2c_txn txn_list[] = { const struct pios_i2c_txn txn_list[] = {
{ /*{
.info = __func__, .info = __func__,
.addr = ETASV3_I2C_ADDR, .addr = ETASV3_I2C_ADDR,
.rw = PIOS_I2C_TXN_WRITE, .rw = PIOS_I2C_TXN_WRITE,
.len = sizeof(cmd_buffer), .len = sizeof(cmd_buffer),
.buf = cmd_buffer, .buf = cmd_buffer,
} }
, ,*/
{ {
.info = __func__, .info = __func__,
.addr = ETASV3_I2C_ADDR, .addr = ETASV3_I2C_ADDR,
@ -66,12 +66,12 @@ int16_t PIOS_ETASV3_ReadAirspeed (void)
{ {
uint8_t airspeed_raw[2]; uint8_t airspeed_raw[2];
if (!PIOS_ETASV3_Read(ETASV3_I2C_READ_CMD, airspeed_raw, sizeof(airspeed_raw))) { if (PIOS_ETASV3_Read(ETASV3_I2C_READ_CMD, airspeed_raw, sizeof(airspeed_raw)) != 0) {
/* Failed to read airspeed */ /* Failed to read airspeed */
return -1; return -1;
} }
return (airspeed_raw[0] << 8 || airspeed_raw[1]); return (airspeed_raw[0] | (airspeed_raw[1]<<8));
} }
#endif /* PIOS_INCLUDE_ETASV3 */ #endif /* PIOS_INCLUDE_ETASV3 */