1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 22:05:17 +03:00

Disable bmp085 interrupt if no baro

This commit is contained in:
Steveis 2015-05-04 13:00:43 +01:00
parent 14a95a3f18
commit 3fdbe68ee1

View file

@ -154,11 +154,6 @@ bool bmp085Detect(const bmp085Config_t *config, baro_t *baro)
if (bmp085InitDone) if (bmp085InitDone)
return true; return true;
delay(20); // datasheet says 10ms, we'll be careful and do 20.
ack = i2cRead(BMP085_I2C_ADDR, BMP085_CHIP_ID__REG, 1, &data); /* read Chip Id */
if(!ack)
return false;
#if defined(BARO_XCLR_GPIO) && defined(BARO_EOC_GPIO) #if defined(BARO_XCLR_GPIO) && defined(BARO_EOC_GPIO)
if (config) { if (config) {
EXTI_InitTypeDef EXTI_InitStructure; EXTI_InitTypeDef EXTI_InitStructure;
@ -193,26 +188,37 @@ bool bmp085Detect(const bmp085Config_t *config, baro_t *baro)
UNUSED(config); UNUSED(config);
#endif #endif
bmp085.chip_id = BMP085_GET_BITSLICE(data, BMP085_CHIP_ID); delay(20); // datasheet says 10ms, we'll be careful and do 20.
bmp085.oversampling_setting = 3;
if (bmp085.chip_id == BMP085_CHIP_ID) { /* get bitslice */ ack = i2cRead(BMP085_I2C_ADDR, BMP085_CHIP_ID__REG, 1, &data); /* read Chip Id */
i2cRead(BMP085_I2C_ADDR, BMP085_VERSION_REG, 1, &data); /* read Version reg */ if (ack) {
bmp085.ml_version = BMP085_GET_BITSLICE(data, BMP085_ML_VERSION); /* get ML Version */ bmp085.chip_id = BMP085_GET_BITSLICE(data, BMP085_CHIP_ID);
bmp085.al_version = BMP085_GET_BITSLICE(data, BMP085_AL_VERSION); /* get AL Version */ bmp085.oversampling_setting = 3;
bmp085_get_cal_param(); /* readout bmp085 calibparam structure */
bmp085InitDone = true; if (bmp085.chip_id == BMP085_CHIP_ID) { /* get bitslice */
baro->ut_delay = 6000; // 1.5ms margin according to the spec (4.5ms T conversion time) i2cRead(BMP085_I2C_ADDR, BMP085_VERSION_REG, 1, &data); /* read Version reg */
baro->up_delay = 27000; // 6000+21000=27000 1.5ms margin according to the spec (25.5ms P conversion time with OSS=3) bmp085.ml_version = BMP085_GET_BITSLICE(data, BMP085_ML_VERSION); /* get ML Version */
baro->start_ut = bmp085_start_ut; bmp085.al_version = BMP085_GET_BITSLICE(data, BMP085_AL_VERSION); /* get AL Version */
baro->get_ut = bmp085_get_ut; bmp085_get_cal_param(); /* readout bmp085 calibparam structure */
baro->start_up = bmp085_start_up; bmp085InitDone = true;
baro->get_up = bmp085_get_up; baro->ut_delay = 6000; // 1.5ms margin according to the spec (4.5ms T conversion time)
baro->calculate = bmp085_calculate; baro->up_delay = 27000; // 6000+21000=27000 1.5ms margin according to the spec (25.5ms P conversion time with OSS=3)
return true; baro->start_ut = bmp085_start_ut;
baro->get_ut = bmp085_get_ut;
baro->start_up = bmp085_start_up;
baro->get_up = bmp085_get_up;
baro->calculate = bmp085_calculate;
return true;
}
} }
#ifdef BARO_EOC_GPIO #ifdef BARO_EOC_GPIO
EXTI_InitTypeDef EXTI_InitStructure;
// Disable EXTI interrupt for barometer EOC
EXTI_InitStructure.EXTI_Line = EXTI_Line14;
EXTI_InitStructure.EXTI_LineCmd = DISABLE;
EXTI_Init(&EXTI_InitStructure);
unregisterExti15_10_CallbackHandler(BMP085_EOC_EXTI_Handler); unregisterExti15_10_CallbackHandler(BMP085_EOC_EXTI_Handler);
#endif #endif