summaryrefslogtreecommitdiff
path: root/app/boards/arm/nrfmicro/pinmux.c
diff options
context:
space:
mode:
authorNick <nick.win999@gmail.com>2020-09-07 12:22:18 -0500
committerNick <nick.win999@gmail.com>2020-09-07 12:22:18 -0500
commitfa40558f73ae0b7f693d93ec931aecf9d52167a1 (patch)
tree3ab362de33ea29d2489d8a4414f88044b4e7137c /app/boards/arm/nrfmicro/pinmux.c
parentbc282a0a4f1af4f6f78a0dd63e5b022eb76a603c (diff)
parent61b249666b13f7f356c0e77ee5eb500d672d7dce (diff)
Merge commit '61b249666b13f7f356c0e77ee5eb500d672d7dce' into boards/dz60rgb
Diffstat (limited to 'app/boards/arm/nrfmicro/pinmux.c')
-rw-r--r--app/boards/arm/nrfmicro/pinmux.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c
new file mode 100644
index 0000000..3792b59
--- /dev/null
+++ b/app/boards/arm/nrfmicro/pinmux.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2020 Okke Formsma, joric
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <kernel.h>
+#include <device.h>
+#include <init.h>
+#include <drivers/gpio.h>
+#include <sys/sys_io.h>
+#include <devicetree.h>
+
+static int pinmux_nrfmicro_init(struct device *port)
+{
+ ARG_UNUSED(port);
+
+ struct device *p1 = device_get_binding("GPIO_1");
+
+#if CONFIG_BOARD_NRFMICRO_13
+ struct device *p0 = device_get_binding("GPIO_0");
+ // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1)
+ gpio_pin_configure(p1, 9, GPIO_OUTPUT);
+ gpio_pin_set(p1, 9, 0);
+
+#if CONFIG_BOARD_NRFMICRO_CHARGER
+ gpio_pin_configure(p0, 5, GPIO_OUTPUT);
+ gpio_pin_set(p0, 5, 0);
+#else
+ gpio_pin_configure(p0, 5, GPIO_INPUT);
+#endif
+
+#else
+ // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1)
+ gpio_pin_configure(p1, 9, GPIO_OUTPUT);
+ gpio_pin_set(p1, 9, 1);
+#endif
+ return 0;
+}
+
+SYS_INIT(pinmux_nrfmicro_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);