mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 15:30:08 +08:00
[baro] ms5611: actually write result to baro.absolute
This commit is contained in:
@@ -49,6 +49,8 @@ void ms5611_i2c_init(struct Ms5611_I2c *ms, struct i2c_periph *i2c_p, uint8_t ad
|
|||||||
void ms5611_i2c_start_configure(struct Ms5611_I2c *ms)
|
void ms5611_i2c_start_configure(struct Ms5611_I2c *ms)
|
||||||
{
|
{
|
||||||
if (ms->status == MS5611_STATUS_UNINIT) {
|
if (ms->status == MS5611_STATUS_UNINIT) {
|
||||||
|
ms->initialized = FALSE;
|
||||||
|
ms->prom_cnt = 0;
|
||||||
ms->i2c_trans.buf[0] = MS5611_SOFT_RESET;
|
ms->i2c_trans.buf[0] = MS5611_SOFT_RESET;
|
||||||
i2c_transmit(ms->i2c_p, &(ms->i2c_trans), ms->i2c_trans.slave_addr, 1);
|
i2c_transmit(ms->i2c_p, &(ms->i2c_trans), ms->i2c_trans.slave_addr, 1);
|
||||||
ms->status = MS5611_STATUS_RESET;
|
ms->status = MS5611_STATUS_RESET;
|
||||||
@@ -152,10 +154,13 @@ void ms5611_i2c_event(struct Ms5611_I2c *ms) {
|
|||||||
}
|
}
|
||||||
else if (ms->status != MS5611_STATUS_UNINIT) { // Configuring but not yet initialized
|
else if (ms->status != MS5611_STATUS_UNINIT) { // Configuring but not yet initialized
|
||||||
switch (ms->i2c_trans.status) {
|
switch (ms->i2c_trans.status) {
|
||||||
|
|
||||||
case I2CTransFailed:
|
case I2CTransFailed:
|
||||||
/* try again */
|
/* try again */
|
||||||
ms->prom_cnt = 0;
|
|
||||||
ms->status = MS5611_STATUS_UNINIT;
|
ms->status = MS5611_STATUS_UNINIT;
|
||||||
|
ms->i2c_trans.status = I2CTransDone;
|
||||||
|
break;
|
||||||
|
|
||||||
case I2CTransSuccess:
|
case I2CTransSuccess:
|
||||||
if (ms->status == MS5611_STATUS_PROM) {
|
if (ms->status == MS5611_STATUS_PROM) {
|
||||||
/* read prom data */
|
/* read prom data */
|
||||||
@@ -174,14 +179,13 @@ void ms5611_i2c_event(struct Ms5611_I2c *ms) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* checksum error, try again */
|
/* checksum error, try again */
|
||||||
ms->prom_cnt = 0;
|
|
||||||
ms->status = MS5611_STATUS_UNINIT;
|
ms->status = MS5611_STATUS_UNINIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case I2CTransDone:
|
|
||||||
ms->i2c_trans.status = I2CTransDone;
|
ms->i2c_trans.status = I2CTransDone;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t sl
|
|||||||
void ms5611_spi_start_configure(struct Ms5611_Spi *ms)
|
void ms5611_spi_start_configure(struct Ms5611_Spi *ms)
|
||||||
{
|
{
|
||||||
if (ms->status == MS5611_STATUS_UNINIT) {
|
if (ms->status == MS5611_STATUS_UNINIT) {
|
||||||
|
ms->initalized = FALSE;
|
||||||
|
ms->prom_cnt = 0;
|
||||||
ms->tx_buf[0] = MS5611_SOFT_RESET;
|
ms->tx_buf[0] = MS5611_SOFT_RESET;
|
||||||
spi_submit(ms->spi_p, &(ms->spi_trans));
|
spi_submit(ms->spi_p, &(ms->spi_trans));
|
||||||
ms->status = MS5611_STATUS_RESET;
|
ms->status = MS5611_STATUS_RESET;
|
||||||
@@ -166,10 +168,13 @@ void ms5611_spi_event(struct Ms5611_Spi *ms) {
|
|||||||
}
|
}
|
||||||
else if (ms->status != MS5611_STATUS_UNINIT) { // Configuring but not yet initialized
|
else if (ms->status != MS5611_STATUS_UNINIT) { // Configuring but not yet initialized
|
||||||
switch (ms->spi_trans.status) {
|
switch (ms->spi_trans.status) {
|
||||||
|
|
||||||
case SPITransFailed:
|
case SPITransFailed:
|
||||||
/* try again */
|
/* try again */
|
||||||
ms->prom_cnt = 0;
|
|
||||||
ms->status = MS5611_STATUS_UNINIT;
|
ms->status = MS5611_STATUS_UNINIT;
|
||||||
|
ms->spi_trans.status = SPITransDone;
|
||||||
|
break;
|
||||||
|
|
||||||
case SPITransSuccess:
|
case SPITransSuccess:
|
||||||
if (ms->status == MS5611_STATUS_PROM) {
|
if (ms->status == MS5611_STATUS_PROM) {
|
||||||
/* read prom data */
|
/* read prom data */
|
||||||
@@ -188,14 +193,13 @@ void ms5611_spi_event(struct Ms5611_Spi *ms) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* checksum error, try again */
|
/* checksum error, try again */
|
||||||
ms->prom_cnt = 0;
|
|
||||||
ms->status = MS5611_STATUS_UNINIT;
|
ms->status = MS5611_STATUS_UNINIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SPITransDone:
|
|
||||||
ms->spi_trans.status = SPITransDone;
|
ms->spi_trans.status = SPITransDone;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ void baro_event(void (*b_abs_handler)(void)){
|
|||||||
ms5611_i2c_event(&baro_ms5611);
|
ms5611_i2c_event(&baro_ms5611);
|
||||||
|
|
||||||
if (baro_ms5611.data_available) {
|
if (baro_ms5611.data_available) {
|
||||||
|
baro.absolute = baro_ms5611.data.pressure;
|
||||||
b_abs_handler();
|
b_abs_handler();
|
||||||
baro_ms5611.data_available = FALSE;
|
baro_ms5611.data_available = FALSE;
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ void baro_event(void (*b_abs_handler)(void)){
|
|||||||
ms5611_spi_event(&baro_ms5611);
|
ms5611_spi_event(&baro_ms5611);
|
||||||
|
|
||||||
if (baro_ms5611.data_available) {
|
if (baro_ms5611.data_available) {
|
||||||
|
baro.absolute = baro_ms5611.data.pressure;
|
||||||
b_abs_handler();
|
b_abs_handler();
|
||||||
baro_ms5611.data_available = FALSE;
|
baro_ms5611.data_available = FALSE;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user