summaryrefslogtreecommitdiffstats
path: root/app/led.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/led.c')
-rw-r--r--app/led.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/led.c b/app/led.c
new file mode 100644
index 0000000..64c4660
--- /dev/null
+++ b/app/led.c
@@ -0,0 +1,48 @@
+#include "project.h"
+
+
+static int led = 0;
+
+void
+led_init (void)
+{
+ gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO8);
+ gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
+}
+
+
+void
+led_clear (void)
+{
+ gpio_set (GPIOB, GPIO8);
+ gpio_set (GPIOB, GPIO9);
+}
+
+void
+led_set (uint32_t v)
+{
+ gpio_clear (GPIOB, v);
+ led = 200;
+}
+
+void
+led_tick (void)
+{
+ static int c;
+
+ if (led)
+ {
+ led--;
+ if (!led)
+ led_clear ();
+ }
+ else
+ {
+ led_set (c ? GPIO8 : GPIO9);
+ c ^= 1;
+ }
+
+
+}