summaryrefslogtreecommitdiffstats
path: root/radiator-plc/stm32/app/led.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/led.c
parentdafd8cf2fdcdd637cc06f760d318cf8391b1a294 (diff)
downloadheating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.gz
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.bz2
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.zip
everything, mostly, working
Diffstat (limited to 'radiator-plc/stm32/app/led.c')
-rw-r--r--radiator-plc/stm32/app/led.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/radiator-plc/stm32/app/led.c b/radiator-plc/stm32/app/led.c
new file mode 100644
index 0000000..390ed2e
--- /dev/null
+++ b/radiator-plc/stm32/app/led.c
@@ -0,0 +1,53 @@
+#include "project.h"
+
+#define LED0 GPIO3
+#define LED0_PORT GPIOC
+
+#define LED1 GPIO2
+#define LED1_PORT GPIOC
+
+static int led = 0;
+
+void
+led_init (void)
+{
+ MAP_OUTPUT_PP (LED0);
+ MAP_OUTPUT_PP (LED1);
+
+ SET (LED0);
+ SET (LED1);
+}
+
+void led1_set (void)
+{
+ CLEAR (LED1);
+}
+
+void led1_clear (void)
+{
+ SET (LED1);
+}
+
+
+
+void
+led_tick (void)
+{
+ static unsigned i;
+
+ i++;
+
+ if (i < 1000) return;
+
+ i = 0;
+
+ led ^= 1;
+
+ if (!led)
+ CLEAR (LED0);
+
+ if (led)
+ SET (LED0);
+
+}
+