aboutsummaryrefslogtreecommitdiffstats
path: root/src/initial_pins.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-03-17 20:41:52 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-03-17 20:56:25 -0400
commit4a35f927fc1d7b8c3b34f32c1c889fb433752dcc (patch)
treee775cbf7f216996cd2056c6568c5fbc5eac1f3fb /src/initial_pins.c
parent0af89e4766e5a25abb9d5d9667e2f187c4cec7c1 (diff)
downloadkutter-4a35f927fc1d7b8c3b34f32c1c889fb433752dcc.tar.gz
kutter-4a35f927fc1d7b8c3b34f32c1c889fb433752dcc.tar.xz
kutter-4a35f927fc1d7b8c3b34f32c1c889fb433752dcc.zip
initial_pins: Add ability to configure output pins at mcu startup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/initial_pins.c')
-rw-r--r--src/initial_pins.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/initial_pins.c b/src/initial_pins.c
new file mode 100644
index 00000000..cd478508
--- /dev/null
+++ b/src/initial_pins.c
@@ -0,0 +1,25 @@
+// Support setting gpio pins at mcu start
+//
+// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include "autoconf.h" // CONFIG_INITIAL_PINS
+#include "board/gpio.h" // gpio_out_setup
+#include "board/pgm.h" // READP
+#include "ctr.h" // DECL_CTR
+#include "initial_pins.h" // initial_pins
+#include "sched.h" // DECL_INIT
+
+DECL_CTR("DECL_INITIAL_PINS " __stringify(CONFIG_INITIAL_PINS));
+
+void
+initial_pins_setup(void)
+{
+ int i;
+ for (i=0; i<initial_pins_size; i++) {
+ const struct initial_pin_s *ip = &initial_pins[i];
+ gpio_out_setup(READP(ip->pin), READP(ip->flags) & IP_OUT_HIGH);
+ }
+}
+DECL_INIT(initial_pins_setup);