Skip to content

Commit ead6f72

Browse files
fix: Moved vcc-gpios to specific board.c
1 parent 0e30027 commit ead6f72

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

boards/nordic/promicro_uf2/board.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@
66

77
#include <zephyr/init.h>
88
#include <hal/nrf_gpio.h>
9+
#include <zephyr/devicetree.h>
10+
11+
#define ZEPHYR_USER_NODE DT_PATH(zephyr_user)
12+
13+
#define VCC_GPIO_PIN DT_GPIO_PIN(ZEPHYR_USER_NODE, vcc_gpios)
14+
#define VCC_GPIO_PORT DT_GPIO_LABEL(ZEPHYR_USER_NODE, vcc_gpios)
15+
16+
#define VCC_GPIO_PORT_NUM DT_PROP(DT_GPIO_CTLR(ZEPHYR_USER_NODE, vcc_gpios), port)
917

1018
static int board_promicro_init(void)
1119
{
12-
/* using p0.31 for sensor power
20+
/* using vcc-gpios for sensor power defined in promicro_uf2.dts
1321
*/
14-
nrf_gpio_cfg(NRF_GPIO_PIN_MAP(0, 31), NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_D0H1, NRF_GPIO_PIN_NOSENSE);
15-
nrf_gpio_pin_set(NRF_GPIO_PIN_MAP(0, 31));
22+
nrf_gpio_cfg(NRF_GPIO_PIN_MAP(VCC_GPIO_PORT_NUM, VCC_GPIO_PIN), NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_D0H1, NRF_GPIO_PIN_NOSENSE);
23+
nrf_gpio_pin_set(NRF_GPIO_PIN_MAP(VCC_GPIO_PORT_NUM, VCC_GPIO_PIN));
1624
return 0;
1725
}
1826

1927
SYS_INIT(board_promicro_init, PRE_KERNEL_1,
20-
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
28+
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

boards/nordic/promicro_uf2/promicro_uf2.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
int0-gpios = <&gpio0 17 0>;
117117
led-gpios = <&gpio0 15 GPIO_OPEN_SOURCE>;
118118
// clk-gpios = <&gpio0 20 GPIO_OPEN_DRAIN>; // Uncomment and set to correct pin if using an external clock (crystal oscillator)
119-
// vcc-gpios = <&gpio0 31 GPIO_OPEN_SOURCE>; // Uncomment to use GPIO as VCC
119+
vcc-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
120120
};
121121

122122
};

src/system/power.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ static const struct gpio_dt_spec ldo_en = GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, ldo
6868
#else
6969
#pragma message "LDO enable GPIO does not exist"
7070
#endif
71-
#if DT_NODE_HAS_PROP(ZEPHYR_USER_NODE, vcc_gpios)
72-
static const struct gpio_dt_spec pwr = GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, vcc_gpios);
73-
#else
74-
#pragma message "VCC GPIO does not exist"
75-
#endif
7671

7772
#define ADAFRUIT_BOOTLOADER CONFIG_BUILD_OUTPUT_UF2
7873

0 commit comments

Comments
 (0)