@@ -45,8 +45,7 @@ static struct gpio_callback button_callback;
4545
4646struct led_indicator {
4747 struct device * dev ;
48- u32_t pin ;
49- u32_t flags ;
48+ gpio_pin_t pin ;
5049};
5150
5251static struct led_indicator led_green ;
@@ -68,11 +67,7 @@ static void led_callback(bool value, void *arg)
6867 return ;
6968 }
7069
71- if ((led -> flags & GPIO_INT_ACTIVE_HIGH ) == GPIO_INT_ACTIVE_LOW ) {
72- drive = !drive ;
73- }
74-
75- gpio_pin_write (led -> dev , led -> pin , drive );
70+ gpio_pin_set (led -> dev , led -> pin , drive );
7671}
7772
7873/**
@@ -88,17 +83,19 @@ static void config_leds(CO_NMT_t *nmt)
8883#ifdef LED_GREEN_PORT
8984 led_green .dev = device_get_binding (LED_GREEN_PORT );
9085 led_green .pin = LED_GREEN_PIN ;
91- led_green .flags = LED_GREEN_FLAGS ;
9286 if (led_green .dev ) {
93- gpio_pin_configure (led_green .dev , LED_GREEN_PIN , GPIO_DIR_OUT );
87+ gpio_pin_configure (led_green .dev , LED_GREEN_PIN ,
88+ GPIO_OUTPUT_INACTIVE
89+ | LED_GREEN_FLAGS );
9490 }
9591#endif /* LED_GREEN_PORT */
9692#ifdef LED_RED_PORT
9793 led_red .dev = device_get_binding (LED_RED_PORT );
9894 led_red .pin = LED_RED_PIN ;
99- led_red .flags = LED_RED_FLAGS ;
10095 if (led_red .dev ) {
101- gpio_pin_configure (led_red .dev , LED_RED_PIN , GPIO_DIR_OUT );
96+ gpio_pin_configure (led_red .dev , LED_RED_PIN ,
97+ GPIO_OUTPUT_INACTIVE
98+ | LED_RED_FLAGS );
10299 }
103100#endif /* LED_RED_PORT */
104101
@@ -175,9 +172,8 @@ static void config_button(void)
175172 return ;
176173 }
177174
178- err = gpio_pin_configure (dev , BUTTON_PIN , GPIO_DIR_IN |
179- GPIO_INT_DEBOUNCE | GPIO_INT |
180- GPIO_INT_EDGE | BUTTON_FLAGS );
175+ err = gpio_pin_configure (dev , BUTTON_PIN ,
176+ GPIO_INPUT | BUTTON_FLAGS );
181177
182178 gpio_init_callback (& button_callback , button_isr_callback ,
183179 BIT (BUTTON_PIN ));
@@ -188,7 +184,8 @@ static void config_button(void)
188184 return ;
189185 }
190186
191- err = gpio_pin_enable_callback (dev , BUTTON_PIN );
187+ err = gpio_pin_interrupt_configure (dev , BUTTON_PIN ,
188+ GPIO_INT_EDGE_TO_ACTIVE );
192189 if (err ) {
193190 LOG_ERR ("failed to enable button callback" );
194191 return ;
0 commit comments