gpio: replace gpio pin write/read with set/get

This API will be deprecated in favor of the new API that clearly
specifies whether it works on logical or physical levels.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
diff --git a/boards/arm/96b_wistrio/pinmux.c b/boards/arm/96b_wistrio/pinmux.c
index c0248b3..65fc3d5 100644
--- a/boards/arm/96b_wistrio/pinmux.c
+++ b/boards/arm/96b_wistrio/pinmux.c
@@ -63,16 +63,16 @@
 	}
 
 	gpio_pin_configure(gpioa, 4, GPIO_DIR_OUT);
-	gpio_pin_write(gpioa, 4, 1);
+	gpio_pin_set(gpioa, 4, 1);
 
 	gpio_pin_configure(gpiob, 6, GPIO_DIR_OUT);
-	gpio_pin_write(gpiob, 6, 1);
+	gpio_pin_set(gpiob, 6, 1);
 
 	gpio_pin_configure(gpiob, 7, GPIO_DIR_OUT);
-	gpio_pin_write(gpiob, 7, 0);
+	gpio_pin_set(gpiob, 7, 0);
 
 	gpio_pin_configure(gpioh, 1, GPIO_DIR_OUT);
-	gpio_pin_write(gpioh, 1, 1);
+	gpio_pin_set(gpioh, 1, 1);
 
 	return 0;
 }
diff --git a/boards/arm/efm32gg_stk3701a/board.c b/boards/arm/efm32gg_stk3701a/board.c
index 0c1e2ac..3eeb317 100644
--- a/boards/arm/efm32gg_stk3701a/board.c
+++ b/boards/arm/efm32gg_stk3701a/board.c
@@ -25,7 +25,7 @@
 	}
 
 	gpio_pin_configure(cur_dev, BC_ENABLE_GPIO_PIN, GPIO_DIR_OUT);
-	gpio_pin_write(cur_dev, BC_ENABLE_GPIO_PIN, 1);
+	gpio_pin_set(cur_dev, BC_ENABLE_GPIO_PIN, 1);
 
 #ifdef CONFIG_ETH_GECKO
 	/* Enable the ethernet PHY power */
@@ -36,7 +36,7 @@
 	}
 
 	gpio_pin_configure(cur_dev, ETH_PWR_ENABLE_GPIO_PIN, GPIO_DIR_OUT);
-	gpio_pin_write(cur_dev, ETH_PWR_ENABLE_GPIO_PIN, 1);
+	gpio_pin_set(cur_dev, ETH_PWR_ENABLE_GPIO_PIN, 1);
 
 	/* Configure ethernet reference clock */
 	cur_dev = device_get_binding(ETH_REF_CLK_GPIO_NAME);
@@ -46,7 +46,7 @@
 	}
 
 	gpio_pin_configure(cur_dev, ETH_REF_CLK_GPIO_PIN, GPIO_DIR_OUT);
-	gpio_pin_write(cur_dev, ETH_REF_CLK_GPIO_PIN, 0);
+	gpio_pin_set(cur_dev, ETH_REF_CLK_GPIO_PIN, 0);
 
 	/* enable CMU_CLK2 as RMII reference clock */
 	CMU->CTRL      |= CMU_CTRL_CLKOUTSEL2_HFXO;
@@ -62,7 +62,7 @@
 	}
 
 	gpio_pin_configure(cur_dev, ETH_RESET_GPIO_PIN, GPIO_DIR_OUT);
-	gpio_pin_write(cur_dev, ETH_RESET_GPIO_PIN, 1);
+	gpio_pin_set(cur_dev, ETH_RESET_GPIO_PIN, 1);
 #endif /* CONFIG_ETH_GECKO */
 
 	return 0;
diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c
index c2c53ef..db9920b 100644
--- a/drivers/bluetooth/hci/spi.c
+++ b/drivers/bluetooth/hci/spi.c
@@ -225,13 +225,13 @@
 
 static bool irq_pin_high(void)
 {
-	u32_t pin_state;
+	int pin_state;
 
-	gpio_pin_read(irq_dev, GPIO_IRQ_PIN, &pin_state);
+	pin_state = gpio_pin_get(irq_dev, GPIO_IRQ_PIN);
 
 	BT_DBG("IRQ Pin: %d", pin_state);
 
-	return pin_state;
+	return pin_state > 0;
 }
 
 static void init_irq_high_loop(void)
@@ -394,7 +394,7 @@
 static int bt_spi_send(struct net_buf *buf)
 {
 	u8_t header[5] = { SPI_WRITE, 0x00,  0x00,  0x00,  0x00 };
-	u32_t pending;
+	int pending;
 	int ret;
 
 	BT_DBG("");
@@ -407,8 +407,8 @@
 
 	/* Allow time for the read thread to handle interrupt */
 	while (true) {
-		gpio_pin_read(irq_dev, GPIO_IRQ_PIN, &pending);
-		if (!pending) {
+		pending = gpio_pin_get(irq_dev, GPIO_IRQ_PIN);
+		if (pending <= 0) {
 			break;
 		}
 		k_sleep(K_MSEC(1));
diff --git a/drivers/gpio/gpio_shell.c b/drivers/gpio/gpio_shell.c
index e1fa551..81310c4 100644
--- a/drivers/gpio/gpio_shell.c
+++ b/drivers/gpio/gpio_shell.c
@@ -85,7 +85,6 @@
 {
 	struct device *dev;
 	u8_t index = 0U;
-	u32_t value = 0U;
 	int rc;
 
 	if (argc == args_no.get && isdigit((unsigned char)argv[args_indx.index][0])) {
@@ -101,11 +100,11 @@
 		index = (u8_t)atoi(argv[2]);
 		shell_print(shell, "Reading %s pin %d",
 			     argv[args_indx.port], index);
-		rc = gpio_pin_read(dev, index, &value);
-		if (rc == 0) {
-			shell_print(shell, "Value %d", value);
+		rc = gpio_pin_get(dev, index);
+		if (rc >= 0) {
+			shell_print(shell, "Value %d", rc);
 		} else {
-			shell_error(shell, "Error reading value");
+			shell_error(shell, "Error %d reading value", rc);
 			return -EIO;
 		}
 	}
@@ -135,7 +134,7 @@
 		index = (u8_t)atoi(argv[2]);
 		shell_print(shell, "Writing to %s pin %d",
 			    argv[args_indx.port], index);
-		gpio_pin_write(dev, index, value);
+		gpio_pin_set(dev, index, value);
 	}
 
 	return 0;
diff --git a/drivers/i2c/i2c_gpio.c b/drivers/i2c/i2c_gpio.c
index 5ff62ee..01c6dea 100644
--- a/drivers/i2c/i2c_gpio.c
+++ b/drivers/i2c/i2c_gpio.c
@@ -45,23 +45,23 @@
 {
 	struct i2c_gpio_context *context = io_context;
 
-	gpio_pin_write(context->gpio, context->scl_pin, state);
+	gpio_pin_set(context->gpio, context->scl_pin, state);
 }
 
 static void i2c_gpio_set_sda(void *io_context, int state)
 {
 	struct i2c_gpio_context *context = io_context;
 
-	gpio_pin_write(context->gpio, context->sda_pin, state);
+	gpio_pin_set(context->gpio, context->sda_pin, state);
 }
 
 static int i2c_gpio_get_sda(void *io_context)
 {
 	struct i2c_gpio_context *context = io_context;
-	u32_t state = 1U; /* Default high as that would be a NACK */
+	int rc = gpio_pin_get(context->gpio, context->sda_pin);
 
-	gpio_pin_read(context->gpio, context->sda_pin, &state);
-	return state;
+	/* Default high as that would be a NACK */
+	return rc != 0;
 }
 
 static const struct i2c_bitbang_io io_fns = {
diff --git a/drivers/wifi/eswifi/eswifi_bus_spi.c b/drivers/wifi/eswifi/eswifi_bus_spi.c
index fa30394..5c3a9f7 100644
--- a/drivers/wifi/eswifi/eswifi_bus_spi.c
+++ b/drivers/wifi/eswifi/eswifi_bus_spi.c
@@ -35,11 +35,7 @@
 
 static bool eswifi_spi_cmddata_ready(struct eswifi_spi_data *spi)
 {
-	int value;
-
-	gpio_pin_read(spi->dr.dev, spi->dr.pin, &value);
-
-	return value ? true : false;
+	return gpio_pin_get(spi->dr.dev, spi->dr.pin) > 0;
 }
 
 static int eswifi_spi_wait_cmddata_ready(struct eswifi_spi_data *spi)
diff --git a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h
index 04fff2c..4553dcb 100644
--- a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h
+++ b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h
@@ -85,69 +85,69 @@
 		vega_debug_portc = device_get_binding(DT_ALIAS_GPIO_C_LABEL); \
 		vega_debug_portd = device_get_binding(DT_ALIAS_GPIO_D_LABEL); \
 		\
-		gpio_pin_write(DEBUG0_PORT, DEBUG0_PIN, 1); \
-		gpio_pin_write(DEBUG0_PORT, DEBUG0_PIN, 0); \
+		gpio_pin_set(DEBUG0_PORT, DEBUG0_PIN, 1); \
+		gpio_pin_set(DEBUG0_PORT, DEBUG0_PIN, 0); \
 	} while (0)
 
-#define DEBUG_CPU_SLEEP(flag) gpio_pin_write(DEBUG0_PORT, DEBUG0_PIN, flag)
+#define DEBUG_CPU_SLEEP(flag) gpio_pin_set(DEBUG0_PORT, DEBUG0_PIN, flag)
 
-#define DEBUG_TICKER_ISR(flag) gpio_pin_write(DEBUG1_PORT, DEBUG1_PIN, flag)
+#define DEBUG_TICKER_ISR(flag) gpio_pin_set(DEBUG1_PORT, DEBUG1_PIN, flag)
 
-#define DEBUG_TICKER_TASK(flag) gpio_pin_write(DEBUG1_PORT, DEBUG1_PIN, flag)
+#define DEBUG_TICKER_TASK(flag) gpio_pin_set(DEBUG1_PORT, DEBUG1_PIN, flag)
 
-#define DEBUG_TICKER_JOB(flag) gpio_pin_write(DEBUG2_PORT, DEBUG2_PIN, flag)
+#define DEBUG_TICKER_JOB(flag) gpio_pin_set(DEBUG2_PORT, DEBUG2_PIN, flag)
 
-#define DEBUG_RADIO_ISR(flag) gpio_pin_write(DEBUG7_PORT, DEBUG7_PIN, flag)
+#define DEBUG_RADIO_ISR(flag) gpio_pin_set(DEBUG7_PORT, DEBUG7_PIN, flag)
 
-#define DEBUG_RADIO_XTAL(flag) gpio_pin_write(DEBUG8_PORT, DEBUG8_PIN, flag)
+#define DEBUG_RADIO_XTAL(flag) gpio_pin_set(DEBUG8_PORT, DEBUG8_PIN, flag)
 
-#define DEBUG_RADIO_ACTIVE(flag) gpio_pin_write(DEBUG9_PORT, DEBUG9_PIN, flag)
+#define DEBUG_RADIO_ACTIVE(flag) gpio_pin_set(DEBUG9_PORT, DEBUG9_PIN, flag)
 
 #define DEBUG_RADIO_CLOSE(flag) \
 	do { \
 		if (!flag) { \
-			gpio_pin_write(DEBUG3_PORT, DEBUG3_PIN, flag); \
-			gpio_pin_write(DEBUG4_PORT, DEBUG4_PIN, flag); \
-			gpio_pin_write(DEBUG5_PORT, DEBUG5_PIN, flag); \
-			gpio_pin_write(DEBUG6_PORT, DEBUG6_PIN, flag); \
+			gpio_pin_set(DEBUG3_PORT, DEBUG3_PIN, flag); \
+			gpio_pin_set(DEBUG4_PORT, DEBUG4_PIN, flag); \
+			gpio_pin_set(DEBUG5_PORT, DEBUG5_PIN, flag); \
+			gpio_pin_set(DEBUG6_PORT, DEBUG6_PIN, flag); \
 		} \
 	} while (0)
 
 #define DEBUG_RADIO_PREPARE_A(flag) \
-		gpio_pin_write(DEBUG3_PORT, DEBUG3_PIN, flag)
+		gpio_pin_set(DEBUG3_PORT, DEBUG3_PIN, flag)
 
 #define DEBUG_RADIO_START_A(flag) \
-		gpio_pin_write(DEBUG3_PORT, DEBUG3_PIN, flag)
+		gpio_pin_set(DEBUG3_PORT, DEBUG3_PIN, flag)
 
 #define DEBUG_RADIO_CLOSE_A(flag) \
-		gpio_pin_write(DEBUG3_PORT, DEBUG3_PIN, flag)
+		gpio_pin_set(DEBUG3_PORT, DEBUG3_PIN, flag)
 
 #define DEBUG_RADIO_PREPARE_S(flag) \
-		gpio_pin_write(DEBUG4_PORT, DEBUG4_PIN, flag)
+		gpio_pin_set(DEBUG4_PORT, DEBUG4_PIN, flag)
 
 #define DEBUG_RADIO_START_S(flag) \
-		gpio_pin_write(DEBUG4_PORT, DEBUG4_PIN, flag)
+		gpio_pin_set(DEBUG4_PORT, DEBUG4_PIN, flag)
 
 #define DEBUG_RADIO_CLOSE_S(flag) \
-		gpio_pin_write(DEBUG4_PORT, DEBUG4_PIN, flag)
+		gpio_pin_set(DEBUG4_PORT, DEBUG4_PIN, flag)
 
 #define DEBUG_RADIO_PREPARE_O(flag) \
-		gpio_pin_write(DEBUG5_PORT, DEBUG5_PIN, flag)
+		gpio_pin_set(DEBUG5_PORT, DEBUG5_PIN, flag)
 
 #define DEBUG_RADIO_START_O(flag) \
-		gpio_pin_write(DEBUG5_PORT, DEBUG5_PIN, flag)
+		gpio_pin_set(DEBUG5_PORT, DEBUG5_PIN, flag)
 
 #define DEBUG_RADIO_CLOSE_O(flag) \
-		gpio_pin_write(DEBUG5_PORT, DEBUG5_PIN, flag)
+		gpio_pin_set(DEBUG5_PORT, DEBUG5_PIN, flag)
 
 #define DEBUG_RADIO_PREPARE_M(flag) \
-		gpio_pin_write(DEBUG6_PORT, DEBUG6_PIN, flag)
+		gpio_pin_set(DEBUG6_PORT, DEBUG6_PIN, flag)
 
 #define DEBUG_RADIO_START_M(flag) \
-		gpio_pin_write(DEBUG6_PORT, DEBUG6_PIN, flag)
+		gpio_pin_set(DEBUG6_PORT, DEBUG6_PIN, flag)
 
 #define DEBUG_RADIO_CLOSE_M(flag) \
-		gpio_pin_write(DEBUG6_PORT, DEBUG6_PIN, flag)
+		gpio_pin_set(DEBUG6_PORT, DEBUG6_PIN, flag)
 
 #else