1515#include <logging/log.h>
1616LOG_MODULE_DECLARE (BMA280 , CONFIG_SENSOR_LOG_LEVEL );
1717
18+ static inline void setup_int1 (struct device * dev ,
19+ bool enable )
20+ {
21+ struct bma280_data * data = dev -> driver_data ;
22+
23+ gpio_pin_interrupt_configure (data -> gpio ,
24+ DT_INST_0_BOSCH_BMA280_INT1_GPIOS_PIN ,
25+ (enable
26+ ? GPIO_INT_EDGE_TO_ACTIVE
27+ : GPIO_INT_DISABLE ));
28+ }
29+
1830int bma280_attr_set (struct device * dev ,
1931 enum sensor_channel chan ,
2032 enum sensor_attribute attr ,
@@ -61,7 +73,7 @@ static void bma280_gpio_callback(struct device *dev,
6173
6274 ARG_UNUSED (pins );
6375
64- gpio_pin_disable_callback ( dev , DT_INST_0_BOSCH_BMA280_INT1_GPIOS_PIN );
76+ setup_int1 ( drv_data -> dev , false );
6577
6678#if defined(CONFIG_BMA280_TRIGGER_OWN_THREAD )
6779 k_sem_give (& drv_data -> gpio_sem );
@@ -108,8 +120,7 @@ static void bma280_thread_cb(void *arg)
108120 }
109121 }
110122
111- gpio_pin_enable_callback (drv_data -> gpio ,
112- DT_INST_0_BOSCH_BMA280_INT1_GPIOS_PIN );
123+ setup_int1 (dev , true);
113124}
114125
115126#ifdef CONFIG_BMA280_TRIGGER_OWN_THREAD
@@ -220,8 +231,8 @@ int bma280_init_interrupt(struct device *dev)
220231
221232 gpio_pin_configure (drv_data -> gpio ,
222233 DT_INST_0_BOSCH_BMA280_INT1_GPIOS_PIN ,
223- GPIO_DIR_IN | GPIO_INT | GPIO_INT_LEVEL |
224- GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE );
234+ DT_INST_0_BOSCH_BMA280_INT1_GPIOS_FLAGS
235+ | GPIO_INPUT );
225236
226237 gpio_init_callback (& drv_data -> gpio_cb ,
227238 bma280_gpio_callback ,
@@ -265,6 +276,8 @@ int bma280_init_interrupt(struct device *dev)
265276 return - EIO ;
266277 }
267278
279+ drv_data -> dev = dev ;
280+
268281#if defined(CONFIG_BMA280_TRIGGER_OWN_THREAD )
269282 k_sem_init (& drv_data -> gpio_sem , 0 , UINT_MAX );
270283
@@ -275,11 +288,9 @@ int bma280_init_interrupt(struct device *dev)
275288 0 , K_NO_WAIT );
276289#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_THREAD )
277290 drv_data -> work .handler = bma280_work_cb ;
278- drv_data -> dev = dev ;
279291#endif
280292
281- gpio_pin_enable_callback (drv_data -> gpio ,
282- DT_INST_0_BOSCH_BMA280_INT1_GPIOS_PIN );
293+ setup_int1 (dev , true);
283294
284295 return 0 ;
285296}
0 commit comments