Skip to content

Commit 7c9482e

Browse files
committed
boards: nrf52840_pca10090: Convert to use the new GPIO API
Update the code configuring pins that control the routing of certain lines on the board, to take advantage of the introduced possibility of configuring a pin as output with specified initial state. Additionally, use `gpio_pin_get_raw` instead of `gpio_pin_get` for checking the reset pin state, to save a few bytes in flash. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 37da54e commit 7c9482e

File tree

1 file changed

+9
-13
lines changed
  • boards/arm/nrf52840_pca10090

1 file changed

+9
-13
lines changed

boards/arm/nrf52840_pca10090/board.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,16 @@ static int pins_configure(struct device *port, const struct pin_config cfg[],
176176
{
177177
int err;
178178

179-
/* Write to the pins before configuring them as output,
180-
* to make sure we are driving them to the correct level
181-
* right after they are configured.
182-
*/
183179
for (size_t i = 0; i < pins; i++) {
184-
/* The swiches on the board are active low, so we need
185-
* to negate the IS_ENABLED() value from the tables.
180+
/* A given pin controlling the switch needs to be driven
181+
* to the low state to activate the routing indicated by
182+
* the corresponding IS_ENABLED() macro in the table,
183+
* so configure the pin as output with the proper initial
184+
* state.
186185
*/
187-
err = gpio_pin_set(port, cfg[i].pin, !cfg[i].val);
188-
if (err) {
189-
return cfg[i].pin;
190-
}
191-
192-
err = gpio_pin_configure(port, cfg[i].pin, GPIO_OUTPUT);
186+
u32_t flag = (cfg[i].val ? GPIO_OUTPUT_LOW
187+
: GPIO_OUTPUT_HIGH);
188+
err = gpio_pin_configure(port, cfg[i].pin, flag);
193189
if (err) {
194190
return cfg[i].pin;
195191
}
@@ -218,7 +214,7 @@ static void reset_pin_wait_low(struct device *port, u32_t pin)
218214

219215
/* Wait until the pin is pulled low */
220216
do {
221-
val = gpio_pin_get(port, pin);
217+
val = gpio_pin_get_raw(port, pin);
222218
} while (val > 0);
223219
}
224220

0 commit comments

Comments
 (0)