File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -332,8 +332,9 @@ const struct bmg160_device_config bmg160_config = {
332332 .i2c_addr = DT_INST_0_BOSCH_BMG160_BASE_ADDRESS ,
333333 .i2c_speed = BMG160_BUS_SPEED ,
334334#ifdef CONFIG_BMG160_TRIGGER
335- .gpio_port = DT_INST_0_BOSCH_BMG160_INT_GPIOS_CONTROLLER ,
336335 .int_pin = DT_INST_0_BOSCH_BMG160_INT_GPIOS_PIN ,
336+ .int_flags = DT_INST_0_BOSCH_BMG160_INT_GPIOS_FLAGS ,
337+ .gpio_port = DT_INST_0_BOSCH_BMG160_INT_GPIOS_CONTROLLER ,
337338#endif
338339};
339340
Original file line number Diff line number Diff line change 179179
180180struct bmg160_device_config {
181181 const char * i2c_port ;
182- #ifdef CONFIG_BMG160_TRIGGER
183- const char * gpio_port ;
184- #endif
185182 u16_t i2c_addr ;
186183 u8_t i2c_speed ;
187184#ifdef CONFIG_BMG160_TRIGGER
188- u8_t int_pin ;
185+ gpio_pin_t int_pin ;
186+ gpio_devicetree_flags_t int_flags ;
187+ const char * gpio_port ;
189188#endif
190189};
191190
Original file line number Diff line number Diff line change @@ -18,6 +18,20 @@ extern struct bmg160_device_data bmg160_data;
1818#include <logging/log.h>
1919LOG_MODULE_DECLARE (BMG160 , CONFIG_SENSOR_LOG_LEVEL );
2020
21+ static inline void setup_int (struct device * dev ,
22+ bool enable )
23+ {
24+ struct bmg160_device_data * data = dev -> driver_data ;
25+ const struct bmg160_device_config * const cfg =
26+ dev -> config -> config_info ;
27+
28+ gpio_pin_interrupt_configure (data -> gpio ,
29+ cfg -> int_pin ,
30+ enable
31+ ? GPIO_INT_EDGE_TO_ACTIVE
32+ : GPIO_INT_DISABLE );
33+ }
34+
2135static void bmg160_gpio_callback (struct device * port , struct gpio_callback * cb ,
2236 u32_t pin )
2337{
@@ -244,12 +258,11 @@ int bmg160_trigger_init(struct device *dev)
244258#endif
245259
246260 gpio_pin_configure (bmg160 -> gpio , cfg -> int_pin ,
247- GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
248- GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE );
261+ cfg -> int_flags | GPIO_INT_EDGE_TO_ACTIVE );
249262 gpio_init_callback (& bmg160 -> gpio_cb , bmg160_gpio_callback ,
250263 BIT (cfg -> int_pin ));
251264 gpio_add_callback (bmg160 -> gpio , & bmg160 -> gpio_cb );
252- gpio_pin_enable_callback ( bmg160 -> gpio , cfg -> int_pin );
265+ setup_int ( dev , true );
253266
254267 return 0 ;
255268}
You can’t perform that action at this time.
0 commit comments