drivers: gpio_nrfx: update to use new GPIO API
Update driver code and board files to use new GPIO configuration flags such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver API as well as gpio_pin_interrupt_configure function. Tested on nrf52840_pca10056 board. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com> Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
39effb4397
commit
ff90b2c1d6
22 changed files with 223 additions and 142 deletions
|
@ -59,16 +59,12 @@
|
||||||
/* Push button switch 0 KEY1 */
|
/* Push button switch 0 KEY1 */
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 16 (GPIO_PUD_PULL_UP |
|
gpios = <&gpio0 16 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
GPIO_INT_ACTIVE_LOW |
|
|
||||||
GPIO_INT_EDGE)>;
|
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
/* Push button switch 1 KEY2 */
|
/* Push button switch 1 KEY2 */
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
gpios = <&gpio0 17 (GPIO_PUD_PULL_UP |
|
gpios = <&gpio0 17 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
GPIO_INT_ACTIVE_LOW |
|
|
||||||
GPIO_INT_EDGE)>;
|
|
||||||
label = "Push button switch 1";
|
label = "Push button switch 1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,19 +26,19 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 21 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 22 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 23 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 2";
|
label = "Green LED 2";
|
||||||
};
|
};
|
||||||
led3: led_3 {
|
led3: led_3 {
|
||||||
gpios = <&gpio0 24 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 3";
|
label = "Green LED 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -53,19 +53,19 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 17 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 17 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
gpios = <&gpio0 18 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 18 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 1";
|
label = "Push button switch 1";
|
||||||
};
|
};
|
||||||
button2: button_2 {
|
button2: button_2 {
|
||||||
gpios = <&gpio0 19 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 19 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 2";
|
label = "Push button switch 2";
|
||||||
};
|
};
|
||||||
button3: button_3 {
|
button3: button_3 {
|
||||||
gpios = <&gpio0 20 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 20 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 3";
|
label = "Push button switch 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,15 +26,15 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0_red: led_0 {
|
led0_red: led_0 {
|
||||||
gpios = <&gpio0 21 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
|
||||||
label = "Red LED 0";
|
label = "Red LED 0";
|
||||||
};
|
};
|
||||||
led0_green: led_1 {
|
led0_green: led_1 {
|
||||||
gpios = <&gpio0 22 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led0_blue: led_2 {
|
led0_blue: led_2 {
|
||||||
gpios = <&gpio0 23 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 0";
|
label = "Blue LED 0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
/* gpio flags need validation */
|
/* gpio flags need validation */
|
||||||
gpios = <&gpio0 15 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||||
label = "Button";
|
label = "Button";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,19 +28,19 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 17 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 18 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 19 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 2";
|
label = "Green LED 2";
|
||||||
};
|
};
|
||||||
led3: led_3 {
|
led3: led_3 {
|
||||||
gpios = <&gpio0 20 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 3";
|
label = "Green LED 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -49,19 +49,19 @@
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
gpios = <&gpio0 13 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
};
|
};
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
label = "Push button switch 1";
|
label = "Push button switch 1";
|
||||||
gpios = <&gpio0 14 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
};
|
};
|
||||||
button2: button_2 {
|
button2: button_2 {
|
||||||
label = "Push button switch 2";
|
label = "Push button switch 2";
|
||||||
gpios = <&gpio0 15 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 15 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
};
|
};
|
||||||
button3: button_3 {
|
button3: button_3 {
|
||||||
label = "Push button switch 3";
|
label = "Push button switch 3";
|
||||||
gpios = <&gpio0 16 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 16 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,19 +26,19 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 13 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 14 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 15 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 2";
|
label = "Green LED 2";
|
||||||
};
|
};
|
||||||
led3: led_3 {
|
led3: led_3 {
|
||||||
gpios = <&gpio0 16 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 3";
|
label = "Green LED 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -53,19 +53,19 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 11 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
gpios = <&gpio0 12 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 1";
|
label = "Push button switch 1";
|
||||||
};
|
};
|
||||||
button2: button_2 {
|
button2: button_2 {
|
||||||
gpios = <&gpio0 24 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 2";
|
label = "Push button switch 2";
|
||||||
};
|
};
|
||||||
button3: button_3 {
|
button3: button_3 {
|
||||||
gpios = <&gpio0 25 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 25 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 3";
|
label = "Push button switch 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,15 +27,15 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0_green: led_0 {
|
led0_green: led_0 {
|
||||||
gpios = <&gpio0 22 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1_red: led_1 {
|
led1_red: led_1 {
|
||||||
gpios = <&gpio0 23 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
|
||||||
label = "Red LED 1";
|
label = "Red LED 1";
|
||||||
};
|
};
|
||||||
led2_blue: led_2 {
|
led2_blue: led_2 {
|
||||||
gpios = <&gpio0 24 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 1";
|
label = "Blue LED 1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 18 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 18 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,15 +28,15 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 13 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 14 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
|
||||||
label = "Red LED 1";
|
label = "Red LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 15 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 2";
|
label = "Blue LED 2";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio1 7 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,15 +26,15 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0_green: led_0 {
|
led0_green: led_0 {
|
||||||
gpios = <&gpio0 22 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1_red: led_1 {
|
led1_red: led_1 {
|
||||||
gpios = <&gpio0 23 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
|
||||||
label = "Red LED 1";
|
label = "Red LED 1";
|
||||||
};
|
};
|
||||||
led2_blue: led_2 {
|
led2_blue: led_2 {
|
||||||
gpios = <&gpio0 24 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 2";
|
label = "Blue LED 2";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio1 0 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio1 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,15 +25,15 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 13 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 15 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 1";
|
label = "Blue LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 14 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
|
||||||
label = "Red LED 2";
|
label = "Red LED 2";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 18 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,19 +26,19 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 13 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 14 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 15 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 2";
|
label = "Green LED 2";
|
||||||
};
|
};
|
||||||
led3: led_3 {
|
led3: led_3 {
|
||||||
gpios = <&gpio0 16 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 3";
|
label = "Green LED 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -53,19 +53,19 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 11 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
gpios = <&gpio0 12 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 1";
|
label = "Push button switch 1";
|
||||||
};
|
};
|
||||||
button2: button_2 {
|
button2: button_2 {
|
||||||
gpios = <&gpio0 24 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 2";
|
label = "Push button switch 2";
|
||||||
};
|
};
|
||||||
button3: button_3 {
|
button3: button_3 {
|
||||||
gpios = <&gpio0 25 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 25 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 3";
|
label = "Push button switch 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,19 +27,19 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0_green: led_0 {
|
led0_green: led_0 {
|
||||||
gpios = <&gpio0 6 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1_red: led_1 {
|
led1_red: led_1 {
|
||||||
gpios = <&gpio0 8 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
|
||||||
label = "Red LED 1";
|
label = "Red LED 1";
|
||||||
};
|
};
|
||||||
led1_green: led_2 {
|
led1_green: led_2 {
|
||||||
gpios = <&gpio1 9 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led1_blue: led_3 {
|
led1_blue: led_3 {
|
||||||
gpios = <&gpio0 12 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 1";
|
label = "Blue LED 1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio1 6 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio1 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -184,12 +184,12 @@ static int pins_configure(struct device *port, const struct pin_config cfg[],
|
||||||
/* The swiches on the board are active low, so we need
|
/* The swiches on the board are active low, so we need
|
||||||
* to negate the IS_ENABLED() value from the tables.
|
* to negate the IS_ENABLED() value from the tables.
|
||||||
*/
|
*/
|
||||||
err = gpio_pin_write(port, cfg[i].pin, !cfg[i].val);
|
err = gpio_pin_set(port, cfg[i].pin, !cfg[i].val);
|
||||||
if (err) {
|
if (err) {
|
||||||
return cfg[i].pin;
|
return cfg[i].pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gpio_pin_configure(port, cfg[i].pin, GPIO_DIR_OUT);
|
err = gpio_pin_configure(port, cfg[i].pin, GPIO_OUTPUT);
|
||||||
if (err) {
|
if (err) {
|
||||||
return cfg[i].pin;
|
return cfg[i].pin;
|
||||||
}
|
}
|
||||||
|
@ -214,13 +214,12 @@ static void chip_reset(struct device *gpio,
|
||||||
|
|
||||||
static void reset_pin_wait_low(struct device *port, u32_t pin)
|
static void reset_pin_wait_low(struct device *port, u32_t pin)
|
||||||
{
|
{
|
||||||
int err;
|
int val;
|
||||||
u32_t val;
|
|
||||||
|
|
||||||
/* Wait until the pin is pulled low */
|
/* Wait until the pin is pulled low */
|
||||||
do {
|
do {
|
||||||
err = gpio_pin_read(port, pin, &val);
|
val = gpio_pin_get(port, pin);
|
||||||
} while (err == 0 && val != 0);
|
} while (val > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reset_pin_configure(struct device *p0, struct device *p1)
|
static int reset_pin_configure(struct device *p0, struct device *p1)
|
||||||
|
@ -260,9 +259,7 @@ static int reset_pin_configure(struct device *p0, struct device *p1)
|
||||||
|
|
||||||
__ASSERT_NO_MSG(port != NULL);
|
__ASSERT_NO_MSG(port != NULL);
|
||||||
|
|
||||||
err = gpio_pin_configure(port, pin,
|
err = gpio_pin_configure(port, pin, GPIO_INPUT | GPIO_PULL_DOWN);
|
||||||
GPIO_DIR_IN | GPIO_INT | GPIO_PUD_PULL_DOWN |
|
|
||||||
GPIO_INT_ACTIVE_HIGH | GPIO_INT_EDGE);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +271,7 @@ static int reset_pin_configure(struct device *p0, struct device *p1)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gpio_pin_enable_callback(port, pin);
|
err = gpio_pin_interrupt_configure(port, pin, GPIO_INT_EDGE_RISING);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,7 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 20 (GPIO_PUD_PULL_UP |
|
gpios = <&gpio0 20 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
GPIO_INT_ACTIVE_LOW)>;
|
|
||||||
label = "Button";
|
label = "Button";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,19 +27,19 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 17 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 0";
|
label = "Green LED 0";
|
||||||
};
|
};
|
||||||
led1: led_1 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 18 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 19 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 2";
|
label = "Green LED 2";
|
||||||
};
|
};
|
||||||
led3: led_3 {
|
led3: led_3 {
|
||||||
gpios = <&gpio0 20 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
|
||||||
label = "Green LED 3";
|
label = "Green LED 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -54,19 +54,19 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 13 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 0";
|
label = "Push button switch 0";
|
||||||
};
|
};
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
gpios = <&gpio0 14 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 1";
|
label = "Push button switch 1";
|
||||||
};
|
};
|
||||||
button2: button_2 {
|
button2: button_2 {
|
||||||
gpios = <&gpio0 15 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 15 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 2";
|
label = "Push button switch 2";
|
||||||
};
|
};
|
||||||
button3: button_3 {
|
button3: button_3 {
|
||||||
gpios = <&gpio0 16 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 16 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button switch 3";
|
label = "Push button switch 3";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,8 +27,7 @@ static int pwr_ctrl_init(struct device *dev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio_pin_configure(gpio, cfg->pin, GPIO_DIR_OUT);
|
gpio_pin_configure(gpio, cfg->pin, GPIO_OUTPUT_HIGH);
|
||||||
gpio_pin_write(gpio, cfg->pin, 1);
|
|
||||||
|
|
||||||
k_sleep(K_MSEC(1)); /* Wait for the rail to come up and stabilize */
|
k_sleep(K_MSEC(1)); /* Wait for the rail to come up and stabilize */
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
/* gpio flags need validation */
|
/* gpio flags need validation */
|
||||||
gpios = <&gpio0 11 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Button";
|
label = "Button";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
compatible = "st,hts221";
|
compatible = "st,hts221";
|
||||||
reg = <0x5f>;
|
reg = <0x5f>;
|
||||||
label = "HTS221";
|
label = "HTS221";
|
||||||
drdy-gpios = <&gpio0 24 GPIO_INT_ACTIVE_HIGH>;
|
drdy-gpios = <&gpio0 24 0>;
|
||||||
};
|
};
|
||||||
|
|
||||||
ccs811: ccs811@5a {
|
ccs811: ccs811@5a {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 7 0>;
|
gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
|
||||||
label = "LED";
|
label = "LED";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
/* gpio flags need validation */
|
/* gpio flags need validation */
|
||||||
gpios = <&gpio0 6 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Button";
|
label = "Button";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
/* gpio flags need validation */
|
/* gpio flags need validation */
|
||||||
gpios = <&gpio0 17 GPIO_INT_ACTIVE_LOW>;
|
gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
|
||||||
label = "Button";
|
label = "Button";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,15 +27,8 @@ int bt_hci_transport_setup(struct device *h4)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pull the pin low before configuring it as output, to ensure that
|
/* Configure pin as output and initialize it to low. */
|
||||||
* it is driven to the correct level as soon as it is configured.
|
err = gpio_pin_configure(port, RESET_PIN, GPIO_OUTPUT_LOW);
|
||||||
*/
|
|
||||||
err = gpio_pin_write(port, RESET_PIN, 0);
|
|
||||||
if (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gpio_pin_configure(port, RESET_PIN, GPIO_DIR_OUT);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +38,7 @@ int bt_hci_transport_setup(struct device *h4)
|
||||||
* that it won't send any data until the H4 device
|
* that it won't send any data until the H4 device
|
||||||
* is setup and ready to receive.
|
* is setup and ready to receive.
|
||||||
*/
|
*/
|
||||||
err = gpio_pin_write(port, RESET_PIN, 1);
|
err = gpio_pin_set(port, RESET_PIN, 1);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +56,7 @@ int bt_hci_transport_setup(struct device *h4)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We are ready, let the nRF52840 run to main */
|
/* We are ready, let the nRF52840 run to main */
|
||||||
err = gpio_pin_write(port, RESET_PIN, 0);
|
err = gpio_pin_set(port, RESET_PIN, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,21 +18,21 @@
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0: led_0 {
|
led0: led_0 {
|
||||||
gpios = <&gpio0 2 GPIO_INT_ACTIVE_HIGH>;
|
gpios = <&gpio0 2 0>;
|
||||||
label = "Green LED 0";
|
|
||||||
};
|
|
||||||
led1: led_1 {
|
|
||||||
gpios = <&gpio0 3 GPIO_INT_ACTIVE_HIGH>;
|
|
||||||
label = "Green LED 1";
|
label = "Green LED 1";
|
||||||
};
|
};
|
||||||
led2: led_2 {
|
led1: led_1 {
|
||||||
gpios = <&gpio0 4 GPIO_INT_ACTIVE_HIGH>;
|
gpios = <&gpio0 3 0>;
|
||||||
label = "Green LED 2";
|
label = "Green LED 2";
|
||||||
};
|
};
|
||||||
led3: led_3 {
|
led2: led_2 {
|
||||||
gpios = <&gpio0 5 GPIO_INT_ACTIVE_HIGH>;
|
gpios = <&gpio0 4 0>;
|
||||||
label = "Green LED 3";
|
label = "Green LED 3";
|
||||||
};
|
};
|
||||||
|
led3: led_3 {
|
||||||
|
gpios = <&gpio0 5 0>;
|
||||||
|
label = "Green LED 4";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pwmleds {
|
pwmleds {
|
||||||
|
@ -45,19 +45,19 @@
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button_0 {
|
||||||
gpios = <&gpio0 8 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Switch 1";
|
label = "Switch 1";
|
||||||
};
|
};
|
||||||
button1: button_1 {
|
button1: button_1 {
|
||||||
gpios = <&gpio0 9 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Switch 2";
|
label = "Switch 2";
|
||||||
};
|
};
|
||||||
button2: button_2 {
|
button2: button_2 {
|
||||||
gpios = <&gpio0 6 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button 1";
|
label = "Push button 1";
|
||||||
};
|
};
|
||||||
button3: button_3 {
|
button3: button_3 {
|
||||||
gpios = <&gpio0 7 GPIO_PUD_PULL_UP>;
|
gpios = <&gpio0 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||||
label = "Push button 2";
|
label = "Push button 2";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "gpio_utils.h"
|
#include "gpio_utils.h"
|
||||||
|
|
||||||
struct gpio_nrfx_data {
|
struct gpio_nrfx_data {
|
||||||
|
struct gpio_driver_data general;
|
||||||
sys_slist_t callbacks;
|
sys_slist_t callbacks;
|
||||||
|
|
||||||
/* Mask holding information about which pins have been configured to
|
/* Mask holding information about which pins have been configured to
|
||||||
|
@ -23,10 +24,9 @@ struct gpio_nrfx_data {
|
||||||
*/
|
*/
|
||||||
u32_t int_en;
|
u32_t int_en;
|
||||||
|
|
||||||
u32_t active_level;
|
u32_t int_active_level;
|
||||||
u32_t trig_edge;
|
u32_t trig_edge;
|
||||||
u32_t double_edge;
|
u32_t double_edge;
|
||||||
u32_t inverted;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gpio_nrfx_cfg {
|
struct gpio_nrfx_cfg {
|
||||||
|
@ -34,6 +34,9 @@ struct gpio_nrfx_cfg {
|
||||||
u8_t port_num;
|
u8_t port_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int gpio_nrfx_pin_interrupt_configure(struct device *port, u32_t pin,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
static inline struct gpio_nrfx_data *get_port_data(struct device *port)
|
static inline struct gpio_nrfx_data *get_port_data(struct device *port)
|
||||||
{
|
{
|
||||||
return port->driver_data;
|
return port->driver_data;
|
||||||
|
@ -81,7 +84,7 @@ static void gpiote_channel_free(u32_t abs_pin)
|
||||||
static inline u32_t sense_for_pin(const struct gpio_nrfx_data *data,
|
static inline u32_t sense_for_pin(const struct gpio_nrfx_data *data,
|
||||||
u32_t pin)
|
u32_t pin)
|
||||||
{
|
{
|
||||||
if ((BIT(pin) & (data->active_level ^ data->inverted)) != 0) {
|
if ((BIT(pin) & data->int_active_level) != 0U) {
|
||||||
return NRF_GPIO_PIN_SENSE_HIGH;
|
return NRF_GPIO_PIN_SENSE_HIGH;
|
||||||
}
|
}
|
||||||
return NRF_GPIO_PIN_SENSE_LOW;
|
return NRF_GPIO_PIN_SENSE_LOW;
|
||||||
|
@ -107,8 +110,7 @@ static int gpiote_pin_int_cfg(struct device *port, u32_t pin)
|
||||||
|
|
||||||
if (data->double_edge & BIT(pin)) {
|
if (data->double_edge & BIT(pin)) {
|
||||||
pol = NRF_GPIOTE_POLARITY_TOGGLE;
|
pol = NRF_GPIOTE_POLARITY_TOGGLE;
|
||||||
} else if (((data->active_level & BIT(pin)) != 0U)
|
} else if ((data->int_active_level & BIT(pin)) != 0U) {
|
||||||
^ ((BIT(pin) & data->inverted) != 0)) {
|
|
||||||
pol = NRF_GPIOTE_POLARITY_LOTOHI;
|
pol = NRF_GPIOTE_POLARITY_LOTOHI;
|
||||||
} else {
|
} else {
|
||||||
pol = NRF_GPIOTE_POLARITY_HITOLO;
|
pol = NRF_GPIOTE_POLARITY_HITOLO;
|
||||||
|
@ -128,6 +130,7 @@ static int gpiote_pin_int_cfg(struct device *port, u32_t pin)
|
||||||
static int gpio_nrfx_config(struct device *port, int access_op,
|
static int gpio_nrfx_config(struct device *port, int access_op,
|
||||||
u32_t pin, int flags)
|
u32_t pin, int flags)
|
||||||
{
|
{
|
||||||
|
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
|
||||||
struct gpio_nrfx_data *data = get_port_data(port);
|
struct gpio_nrfx_data *data = get_port_data(port);
|
||||||
nrf_gpio_pin_pull_t pull;
|
nrf_gpio_pin_pull_t pull;
|
||||||
nrf_gpio_pin_drive_t drive;
|
nrf_gpio_pin_drive_t drive;
|
||||||
|
@ -136,14 +139,15 @@ static int gpio_nrfx_config(struct device *port, int access_op,
|
||||||
u8_t from_pin;
|
u8_t from_pin;
|
||||||
u8_t to_pin;
|
u8_t to_pin;
|
||||||
|
|
||||||
switch (flags & (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK)) {
|
switch (flags & (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK |
|
||||||
|
GPIO_OPEN_DRAIN)) {
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_DFLT_HIGH:
|
case GPIO_DS_DFLT_LOW | GPIO_DS_DFLT_HIGH:
|
||||||
drive = NRF_GPIO_PIN_S0S1;
|
drive = NRF_GPIO_PIN_S0S1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_DFLT_LOW | GPIO_DS_ALT_HIGH:
|
||||||
drive = NRF_GPIO_PIN_S0H1;
|
drive = NRF_GPIO_PIN_S0H1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_DISCONNECT_HIGH:
|
case GPIO_DS_DFLT_LOW | GPIO_OPEN_DRAIN:
|
||||||
drive = NRF_GPIO_PIN_S0D1;
|
drive = NRF_GPIO_PIN_S0D1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -153,14 +157,14 @@ static int gpio_nrfx_config(struct device *port, int access_op,
|
||||||
case GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH:
|
||||||
drive = NRF_GPIO_PIN_H0H1;
|
drive = NRF_GPIO_PIN_H0H1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_ALT_LOW | GPIO_DS_DISCONNECT_HIGH:
|
case GPIO_DS_ALT_LOW | GPIO_OPEN_DRAIN:
|
||||||
drive = NRF_GPIO_PIN_H0D1;
|
drive = NRF_GPIO_PIN_H0D1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GPIO_DS_DISCONNECT_LOW | GPIO_DS_DFLT_HIGH:
|
case GPIO_DS_DFLT_HIGH | GPIO_OPEN_SOURCE:
|
||||||
drive = NRF_GPIO_PIN_D0S1;
|
drive = NRF_GPIO_PIN_D0S1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_DISCONNECT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_ALT_HIGH | GPIO_OPEN_SOURCE:
|
||||||
drive = NRF_GPIO_PIN_D0H1;
|
drive = NRF_GPIO_PIN_D0H1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -168,19 +172,19 @@ static int gpio_nrfx_config(struct device *port, int access_op,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & GPIO_PUD_MASK) == GPIO_PUD_PULL_UP) {
|
if ((flags & GPIO_PULL_UP) != 0) {
|
||||||
pull = NRF_GPIO_PIN_PULLUP;
|
pull = NRF_GPIO_PIN_PULLUP;
|
||||||
} else if ((flags & GPIO_PUD_MASK) == GPIO_PUD_PULL_DOWN) {
|
} else if ((flags & GPIO_PULL_DOWN) != 0) {
|
||||||
pull = NRF_GPIO_PIN_PULLDOWN;
|
pull = NRF_GPIO_PIN_PULLDOWN;
|
||||||
} else {
|
} else {
|
||||||
pull = NRF_GPIO_PIN_NOPULL;
|
pull = NRF_GPIO_PIN_NOPULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = ((flags & GPIO_DIR_MASK) == GPIO_DIR_OUT)
|
dir = ((flags & GPIO_OUTPUT) != 0)
|
||||||
? NRF_GPIO_PIN_DIR_OUTPUT
|
? NRF_GPIO_PIN_DIR_OUTPUT
|
||||||
: NRF_GPIO_PIN_DIR_INPUT;
|
: NRF_GPIO_PIN_DIR_INPUT;
|
||||||
|
|
||||||
input = (dir == NRF_GPIO_PIN_DIR_INPUT)
|
input = ((flags & GPIO_INPUT) != 0)
|
||||||
? NRF_GPIO_PIN_INPUT_CONNECT
|
? NRF_GPIO_PIN_INPUT_CONNECT
|
||||||
: NRF_GPIO_PIN_INPUT_DISCONNECT;
|
: NRF_GPIO_PIN_INPUT_DISCONNECT;
|
||||||
|
|
||||||
|
@ -195,19 +199,22 @@ static int gpio_nrfx_config(struct device *port, int access_op,
|
||||||
for (u8_t curr_pin = from_pin; curr_pin <= to_pin; ++curr_pin) {
|
for (u8_t curr_pin = from_pin; curr_pin <= to_pin; ++curr_pin) {
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if ((flags & GPIO_OUTPUT) != 0) {
|
||||||
|
if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0) {
|
||||||
|
nrf_gpio_port_out_set(reg, BIT(curr_pin));
|
||||||
|
} else if ((flags & GPIO_OUTPUT_INIT_LOW) != 0) {
|
||||||
|
nrf_gpio_port_out_clear(reg, BIT(curr_pin));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nrf_gpio_cfg(NRF_GPIO_PIN_MAP(get_port_cfg(port)->port_num,
|
nrf_gpio_cfg(NRF_GPIO_PIN_MAP(get_port_cfg(port)->port_num,
|
||||||
curr_pin),
|
curr_pin),
|
||||||
dir, input, pull, drive, NRF_GPIO_PIN_NOSENSE);
|
dir, input, pull, drive, NRF_GPIO_PIN_NOSENSE);
|
||||||
|
|
||||||
WRITE_BIT(data->pin_int_en, curr_pin, flags & GPIO_INT);
|
WRITE_BIT(data->general.invert, curr_pin,
|
||||||
WRITE_BIT(data->trig_edge, curr_pin, flags & GPIO_INT_EDGE);
|
flags & GPIO_ACTIVE_LOW);
|
||||||
WRITE_BIT(data->double_edge, curr_pin,
|
|
||||||
flags & GPIO_INT_DOUBLE_EDGE);
|
|
||||||
WRITE_BIT(data->active_level, curr_pin,
|
|
||||||
flags & GPIO_INT_ACTIVE_HIGH);
|
|
||||||
WRITE_BIT(data->inverted, curr_pin, flags & GPIO_POL_INV);
|
|
||||||
|
|
||||||
res = gpiote_pin_int_cfg(port, curr_pin);
|
res = gpio_nrfx_pin_interrupt_configure(port, curr_pin, flags);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -223,9 +230,9 @@ static int gpio_nrfx_write(struct device *port, int access_op,
|
||||||
struct gpio_nrfx_data *data = get_port_data(port);
|
struct gpio_nrfx_data *data = get_port_data(port);
|
||||||
|
|
||||||
if (access_op == GPIO_ACCESS_BY_PORT) {
|
if (access_op == GPIO_ACCESS_BY_PORT) {
|
||||||
nrf_gpio_port_out_write(reg, value ^ data->inverted);
|
nrf_gpio_port_out_write(reg, value ^ data->general.invert);
|
||||||
} else {
|
} else {
|
||||||
if ((value > 0) ^ ((BIT(pin) & data->inverted) != 0)) {
|
if ((value > 0) ^ ((BIT(pin) & data->general.invert) != 0)) {
|
||||||
nrf_gpio_port_out_set(reg, BIT(pin));
|
nrf_gpio_port_out_set(reg, BIT(pin));
|
||||||
} else {
|
} else {
|
||||||
nrf_gpio_port_out_clear(reg, BIT(pin));
|
nrf_gpio_port_out_clear(reg, BIT(pin));
|
||||||
|
@ -244,7 +251,7 @@ static int gpio_nrfx_read(struct device *port, int access_op,
|
||||||
u32_t dir = nrf_gpio_port_dir_read(reg);
|
u32_t dir = nrf_gpio_port_dir_read(reg);
|
||||||
u32_t port_in = nrf_gpio_port_in_read(reg) & ~dir;
|
u32_t port_in = nrf_gpio_port_in_read(reg) & ~dir;
|
||||||
u32_t port_out = nrf_gpio_port_out_read(reg) & dir;
|
u32_t port_out = nrf_gpio_port_out_read(reg) & dir;
|
||||||
u32_t port_val = (port_in | port_out) ^ data->inverted;
|
u32_t port_val = (port_in | port_out) ^ data->general.invert;
|
||||||
|
|
||||||
if (access_op == GPIO_ACCESS_BY_PORT) {
|
if (access_op == GPIO_ACCESS_BY_PORT) {
|
||||||
*value = port_val;
|
*value = port_val;
|
||||||
|
@ -255,6 +262,91 @@ static int gpio_nrfx_read(struct device *port, int access_op,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int gpio_nrfx_port_get_raw(struct device *port, u32_t *value)
|
||||||
|
{
|
||||||
|
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
|
||||||
|
|
||||||
|
*value = nrf_gpio_port_in_read(reg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpio_nrfx_port_set_masked_raw(struct device *port, u32_t mask,
|
||||||
|
u32_t value)
|
||||||
|
{
|
||||||
|
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
|
||||||
|
u32_t value_tmp;
|
||||||
|
|
||||||
|
value_tmp = nrf_gpio_port_out_read(reg) & ~mask;
|
||||||
|
nrf_gpio_port_out_write(reg, value_tmp | (mask & value));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpio_nrfx_port_set_bits_raw(struct device *port, u32_t mask)
|
||||||
|
{
|
||||||
|
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
|
||||||
|
|
||||||
|
nrf_gpio_port_out_set(reg, mask);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpio_nrfx_port_clear_bits_raw(struct device *port, u32_t mask)
|
||||||
|
{
|
||||||
|
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
|
||||||
|
|
||||||
|
nrf_gpio_port_out_clear(reg, mask);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpio_nrfx_port_toggle_bits(struct device *port, u32_t mask)
|
||||||
|
{
|
||||||
|
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
|
||||||
|
u32_t value;
|
||||||
|
|
||||||
|
value = nrf_gpio_port_out_read(reg);
|
||||||
|
nrf_gpio_port_out_write(reg, value ^ mask);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpio_nrfx_pin_interrupt_configure(struct device *port,
|
||||||
|
unsigned int pin, unsigned int flags)
|
||||||
|
{
|
||||||
|
struct gpio_nrfx_data *data = get_port_data(port);
|
||||||
|
u32_t abs_pin = NRF_GPIO_PIN_MAP(get_port_cfg(port)->port_num, pin);
|
||||||
|
|
||||||
|
if (((flags & GPIO_INT_ENABLE) != 0) &&
|
||||||
|
((flags & GPIO_INT_EDGE) != 0) &&
|
||||||
|
(nrf_gpio_pin_dir_get(abs_pin) == NRF_GPIO_PIN_DIR_OUTPUT)) {
|
||||||
|
/*
|
||||||
|
* The pin's output value as specified in the GPIO will be
|
||||||
|
* ignored as long as the pin is controlled by GPIOTE.
|
||||||
|
* Pin with output enabled cannot be used as an edge interrupt
|
||||||
|
* source.
|
||||||
|
*/
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
WRITE_BIT(data->pin_int_en, pin, flags & GPIO_INT_ENABLE);
|
||||||
|
WRITE_BIT(data->int_en, pin, true);
|
||||||
|
WRITE_BIT(data->trig_edge, pin, flags & GPIO_INT_EDGE);
|
||||||
|
WRITE_BIT(data->double_edge, pin, (flags & GPIO_INT_LOW_0) &&
|
||||||
|
(flags & GPIO_INT_HIGH_1));
|
||||||
|
|
||||||
|
bool active_high = ((flags & GPIO_INT_HIGH_1) != 0);
|
||||||
|
|
||||||
|
if (((flags & GPIO_INT_LEVELS_LOGICAL) != 0) &&
|
||||||
|
((data->general.invert & BIT(pin)) != 0)) {
|
||||||
|
active_high = !active_high;
|
||||||
|
}
|
||||||
|
WRITE_BIT(data->int_active_level, pin, active_high);
|
||||||
|
|
||||||
|
return gpiote_pin_int_cfg(port, pin);
|
||||||
|
}
|
||||||
|
|
||||||
static int gpio_nrfx_manage_callback(struct device *port,
|
static int gpio_nrfx_manage_callback(struct device *port,
|
||||||
struct gpio_callback *callback,
|
struct gpio_callback *callback,
|
||||||
bool set)
|
bool set)
|
||||||
|
@ -311,6 +403,12 @@ static const struct gpio_driver_api gpio_nrfx_drv_api_funcs = {
|
||||||
.config = gpio_nrfx_config,
|
.config = gpio_nrfx_config,
|
||||||
.write = gpio_nrfx_write,
|
.write = gpio_nrfx_write,
|
||||||
.read = gpio_nrfx_read,
|
.read = gpio_nrfx_read,
|
||||||
|
.port_get_raw = gpio_nrfx_port_get_raw,
|
||||||
|
.port_set_masked_raw = gpio_nrfx_port_set_masked_raw,
|
||||||
|
.port_set_bits_raw = gpio_nrfx_port_set_bits_raw,
|
||||||
|
.port_clear_bits_raw = gpio_nrfx_port_clear_bits_raw,
|
||||||
|
.port_toggle_bits = gpio_nrfx_port_toggle_bits,
|
||||||
|
.pin_interrupt_configure = gpio_nrfx_pin_interrupt_configure,
|
||||||
.manage_callback = gpio_nrfx_manage_callback,
|
.manage_callback = gpio_nrfx_manage_callback,
|
||||||
.enable_callback = gpio_nrfx_pin_enable_callback,
|
.enable_callback = gpio_nrfx_pin_enable_callback,
|
||||||
.disable_callback = gpio_nrfx_pin_disable_callback
|
.disable_callback = gpio_nrfx_pin_disable_callback
|
||||||
|
@ -371,10 +469,9 @@ static u32_t check_level_trigger_pins(struct device *port)
|
||||||
u32_t level_pins = get_level_pins(port);
|
u32_t level_pins = get_level_pins(port);
|
||||||
u32_t port_in = nrf_gpio_port_in_read(cfg->port);
|
u32_t port_in = nrf_gpio_port_in_read(cfg->port);
|
||||||
|
|
||||||
/* Extract which pins after inversion, have logic level same as
|
/* Extract which pins have logic level same as interrupt trigger level.
|
||||||
* interrupt trigger level.
|
|
||||||
*/
|
*/
|
||||||
u32_t pin_states = ~(port_in ^ data->inverted ^ data->active_level);
|
u32_t pin_states = ~(port_in ^ data->int_active_level);
|
||||||
|
|
||||||
/* Discard pins that aren't configured for level. */
|
/* Discard pins that aren't configured for level. */
|
||||||
u32_t out = pin_states & level_pins;
|
u32_t out = pin_states & level_pins;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue