mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
Make the BMA180 sensor system acquire from the queue. Correct the orientation
and speed it up to 10 MHz communications.
This commit is contained in:
parent
8c208412c9
commit
5efbfb02fa
@ -371,39 +371,31 @@ static int32_t updateSensorsCC3D(AccelsData * accelsData, GyrosData * gyrosData)
|
||||
float accel_scaling = 1;
|
||||
|
||||
#if defined(PIOS_INCLUDE_BMA180)
|
||||
// accel_samples = 0;
|
||||
// bool error = false;
|
||||
// int32_t accel_read_good;
|
||||
accel_samples = 0;
|
||||
bool error = false;
|
||||
int32_t accel_read_good;
|
||||
|
||||
while((accel_read_good = PIOS_BMA180_ReadFifo(&accel)) != 0 && !error)
|
||||
error = ((xTaskGetTickCount() - lastSysTime) > 5) ? true : error;
|
||||
if (error) {
|
||||
// Unfortunately if the BMA180 ever misses getting read, then it will not
|
||||
// trigger more interrupts. In this case we must force a read to kickstart
|
||||
// it.
|
||||
struct pios_bma180_data data;
|
||||
PIOS_BMA180_ReadAccels(&data);
|
||||
lastSysTime = xTaskGetTickCount();
|
||||
|
||||
//
|
||||
// while((accel_read_good = PIOS_BMA180_ReadFifo(&accel)) != 0 && !error)
|
||||
// error = ((xTaskGetTickCount() - lastSysTime) > 5) ? true : error;
|
||||
// if (error) {
|
||||
// // Unfortunately if the BMA180 ever misses getting read, then it will not
|
||||
// // trigger more interrupts. In this case we must force a read to kickstarts
|
||||
// // it.
|
||||
// struct pios_bma180_data data;
|
||||
// PIOS_BMA180_ReadAccels(&data);
|
||||
// lastSysTime = xTaskGetTickCount();
|
||||
//
|
||||
// return -1;
|
||||
// }
|
||||
// while(accel_read_good == 0) {
|
||||
// accel_samples++;
|
||||
//
|
||||
// accel_accum[0] += accel.x;
|
||||
// accel_accum[1] += accel.y;
|
||||
// accel_accum[2] += accel.z;
|
||||
//
|
||||
// accel_read_good = PIOS_BMA180_ReadFifo(&accel);
|
||||
// }
|
||||
if(PIOS_BMA180_Test() < 0)
|
||||
return -1;
|
||||
PIOS_BMA180_ReadAccels(&accel);
|
||||
accel_accum[0] += accel.x;
|
||||
accel_accum[1] += accel.y;
|
||||
accel_accum[2] += accel.z;
|
||||
accel_samples = 1;
|
||||
}
|
||||
while(accel_read_good == 0) {
|
||||
accel_samples++;
|
||||
|
||||
accel_accum[0] += -accel.x;
|
||||
accel_accum[1] += -accel.y;
|
||||
accel_accum[2] += accel.z;
|
||||
|
||||
accel_read_good = PIOS_BMA180_ReadFifo(&accel);
|
||||
}
|
||||
accel_scaling = PIOS_BMA180_GetScale();
|
||||
#endif
|
||||
|
||||
|
@ -96,6 +96,7 @@ static int32_t PIOS_BMA180_Validate(struct bma180_dev * dev)
|
||||
return -3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize with good default settings
|
||||
* @returns 0 for success, -1 for failure
|
||||
|
@ -195,7 +195,7 @@ static const struct pios_spi_cfg pios_spi_flash_accel_cfg = {
|
||||
.SPI_CRCPolynomial = 7,
|
||||
.SPI_CPOL = SPI_CPOL_High,
|
||||
.SPI_CPHA = SPI_CPHA_2Edge,
|
||||
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256,
|
||||
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8,
|
||||
},
|
||||
.use_crc = false,
|
||||
.dma = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user