Enhance configureInterrupt with interrupt source selection

- Add bmp5xx_interrupt_source_t enum for interrupt source types
- Update configureInterrupt() to accept interrupt sources parameter
- Support combining multiple interrupt sources with bitwise OR
- Add data ready, FIFO full, FIFO threshold, and pressure out-of-range sources
- Maintain backward compatibility with default data ready source
- Update I2C example to demonstrate new interrupt source parameter

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ladyada 2025-08-09 11:11:35 -04:00
parent a19a277532
commit 607cc2afc2
3 changed files with 35 additions and 8 deletions

View file

@ -110,9 +110,10 @@ void setup() {
* BMP5XX_INTERRUPT_PULSED / BMP5XX_INTERRUPT_LATCHED - Interrupt mode
* BMP5XX_INTERRUPT_ACTIVE_LOW / BMP5XX_INTERRUPT_ACTIVE_HIGH - Interrupt polarity
* BMP5XX_INTERRUPT_PUSH_PULL / BMP5XX_INTERRUPT_OPEN_DRAIN - Interrupt drive
* BMP5XX_INTERRUPT_DATA_READY, BMP5XX_INTERRUPT_FIFO_FULL, etc. - Interrupt sources (can combine with |)
*/
Serial.println(F("Configuring interrupt pin..."));
bmp.configureInterrupt(BMP5XX_INTERRUPT_LATCHED, BMP5XX_INTERRUPT_ACTIVE_HIGH, BMP5XX_INTERRUPT_PUSH_PULL, true);
Serial.println(F("Configuring interrupt pin with data ready source..."));
bmp.configureInterrupt(BMP5XX_INTERRUPT_LATCHED, BMP5XX_INTERRUPT_ACTIVE_HIGH, BMP5XX_INTERRUPT_PUSH_PULL, BMP5XX_INTERRUPT_DATA_READY, true);
Serial.println();
Serial.println(F("=== Current Sensor Configuration ==="));

View file

@ -362,24 +362,39 @@ bool Adafruit_BMP5xx::dataReady(void) {
}
/*!
* @brief Configure interrupt pin settings
* @brief Configure interrupt pin settings and sources
* @param mode Interrupt mode (pulsed or latched)
* @param polarity Interrupt polarity (active high or low)
* @param drive Interrupt drive (push-pull or open-drain)
* @param sources Interrupt sources (can be combined with bitwise OR)
* @param enable Enable or disable interrupt pin
* @return True if configuration was successful, false otherwise
*/
bool Adafruit_BMP5xx::configureInterrupt(bmp5xx_interrupt_mode_t mode,
bmp5xx_interrupt_polarity_t polarity,
bmp5xx_interrupt_drive_t drive,
uint8_t sources,
bool enable) {
// Configure interrupt sources first
struct bmp5_int_source_select int_source_select = {0};
int_source_select.drdy_en = (sources & BMP5XX_INTERRUPT_DATA_READY) ? BMP5_ENABLE : BMP5_DISABLE;
int_source_select.fifo_full_en = (sources & BMP5XX_INTERRUPT_FIFO_FULL) ? BMP5_ENABLE : BMP5_DISABLE;
int_source_select.fifo_thres_en = (sources & BMP5XX_INTERRUPT_FIFO_THRESHOLD) ? BMP5_ENABLE : BMP5_DISABLE;
int_source_select.oor_press_en = (sources & BMP5XX_INTERRUPT_PRESSURE_OUT_OF_RANGE) ? BMP5_ENABLE : BMP5_DISABLE;
int8_t rslt = bmp5_int_source_select(&int_source_select, &_bmp5_dev);
if (rslt != BMP5_OK) {
return false;
}
// Configure interrupt pin settings
enum bmp5_intr_en_dis int_enable = enable ? BMP5_INTR_ENABLE : BMP5_INTR_DISABLE;
int8_t rslt = bmp5_configure_interrupt((enum bmp5_intr_mode)mode,
(enum bmp5_intr_polarity)polarity,
(enum bmp5_intr_drive)drive,
int_enable,
&_bmp5_dev);
rslt = bmp5_configure_interrupt((enum bmp5_intr_mode)mode,
(enum bmp5_intr_polarity)polarity,
(enum bmp5_intr_drive)drive,
int_enable,
&_bmp5_dev);
return rslt == BMP5_OK;
}

View file

@ -145,6 +145,16 @@ typedef enum {
BMP5XX_INTERRUPT_LATCHED = BMP5_LATCHED ///< Latched interrupt
} bmp5xx_interrupt_mode_t;
/**
* @brief Interrupt source settings (can be combined with bitwise OR)
*/
typedef enum {
BMP5XX_INTERRUPT_DATA_READY = 0x01, ///< Data ready interrupt
BMP5XX_INTERRUPT_FIFO_FULL = 0x02, ///< FIFO full interrupt
BMP5XX_INTERRUPT_FIFO_THRESHOLD = 0x04, ///< FIFO threshold interrupt
BMP5XX_INTERRUPT_PRESSURE_OUT_OF_RANGE = 0x08 ///< Pressure out of range interrupt
} bmp5xx_interrupt_source_t;
/**
* @brief Adafruit Unified Sensor interface for temperature component of BMP5xx
*/
@ -224,6 +234,7 @@ public:
bool configureInterrupt(bmp5xx_interrupt_mode_t mode,
bmp5xx_interrupt_polarity_t polarity,
bmp5xx_interrupt_drive_t drive,
uint8_t sources = BMP5XX_INTERRUPT_DATA_READY,
bool enable = true);
/**! Temperature (Celsius) assigned after calling performReading() */