Skip to content

Commit 59c44e9

Browse files
committed
drivers: sensor: bmi160: convert to new GPIO API
Document interrupt signal and replace legacy calls with new API. Signed-off-by: Peter Bigot <[email protected]>
1 parent 226a9f2 commit 59c44e9

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

drivers/sensor/bmi160/bmi160.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ const struct bmi160_device_config bmi160_config = {
901901
#if defined(CONFIG_BMI160_TRIGGER)
902902
.gpio_port = DT_INST_0_BOSCH_BMI160_INT_GPIOS_CONTROLLER,
903903
.int_pin = DT_INST_0_BOSCH_BMI160_INT_GPIOS_PIN,
904+
.int_flags = DT_INST_0_BOSCH_BMI160_INT_GPIOS_FLAGS,
904905
#endif
905906
};
906907

drivers/sensor/bmi160/bmi160.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ struct bmi160_range {
386386
struct bmi160_device_config {
387387
#if defined(CONFIG_BMI160_TRIGGER)
388388
const char *gpio_port;
389-
u8_t int_pin;
389+
gpio_pin_t int_pin;
390+
gpio_devicetree_flags_t int_flags;
390391
#endif
391392
};
392393

drivers/sensor/bmi160/bmi160_trigger.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ int bmi160_trigger_mode_init(struct device *dev)
301301
}
302302

303303
gpio_pin_configure(bmi160->gpio, cfg->int_pin,
304-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
305-
GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE);
304+
GPIO_INPUT | cfg->int_flags);
306305

307306
gpio_init_callback(&bmi160->gpio_cb,
308307
bmi160_gpio_callback,
309308
BIT(cfg->int_pin));
310309

311310
gpio_add_callback(bmi160->gpio, &bmi160->gpio_cb);
312-
gpio_pin_enable_callback(bmi160->gpio, cfg->int_pin);
311+
gpio_pin_interrupt_configure(bmi160->gpio, cfg->int_pin,
312+
GPIO_INT_EDGE_TO_ACTIVE);
313313

314314
return bmi160_byte_write(dev, BMI160_REG_INT_OUT_CTRL,
315315
BMI160_INT1_OUT_EN | BMI160_INT1_EDGE_CTRL);

dts/bindings/sensor/bosch,bmi160.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ properties:
1414
int-gpios:
1515
type: phandle-array
1616
required: false
17+
description: |
18+
This property specifies the connection for INT1, because the
19+
Zephyr driver maps all interrupts to INT1. The signal defaults
20+
to output low when produced by the sensor.

0 commit comments

Comments
 (0)