summaryrefslogtreecommitdiffstats
path: root/radiator-plc/stm32/app/inputs.c
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
committerfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
commit9d87c925a9eaa4fc256be3173c14a20d1469472d (patch)
tree50d63f87a47a0eac3f5b8058850184bcd4e6ee95 /radiator-plc/stm32/app/inputs.c
parentdafd8cf2fdcdd637cc06f760d318cf8391b1a294 (diff)
downloadheating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.gz
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.bz2
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.zip
everything, mostly, working
Diffstat (limited to 'radiator-plc/stm32/app/inputs.c')
-rw-r--r--radiator-plc/stm32/app/inputs.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/radiator-plc/stm32/app/inputs.c b/radiator-plc/stm32/app/inputs.c
new file mode 100644
index 0000000..825a3fe
--- /dev/null
+++ b/radiator-plc/stm32/app/inputs.c
@@ -0,0 +1,26 @@
+#include "project.h"
+
+#define N_INPUTS 14
+
+static const uint32_t input_bank[N_INPUTS] = { GPIOC, GPIOC, GPIOB, GPIOA, GPIOA, GPIOC, GPIOD, GPIOD, 0, 0, GPIOD, GPIOD, GPIOD, GPIOD};
+static const uint32_t input[N_INPUTS] = { GPIO7, GPIO6, GPIO15, GPIO1, GPIO0, GPIO4, GPIO15, GPIO14, 0, 0, GPIO13, GPIO12, GPIO11, GPIO10};
+
+int input_get (unsigned r)
+{
+ if (r >= N_INPUTS) return 0;
+
+ if (!input[r]) return 0;
+
+ return !gpio_get (input_bank[r], input[r]);
+}
+
+
+void inputs_init (void)
+{
+ unsigned r;
+
+ for (r = 0; r < N_INPUTS; ++r)
+ if (input[r])
+ gpio_set_mode (input_bank[r], GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, input[r]);
+
+}