summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@lamia.panaceas.james.local>2015-07-16 08:47:30 +0100
committerroot <root@lamia.panaceas.james.local>2015-07-16 08:47:30 +0100
commit809b705559a51cac8cd301dbbe7e133e8607fbf6 (patch)
tree9f90b6f2b060171a94077b2972945fb5a9f39a66
parent191be59e5fed6aba0158f9495df8b99894c13c17 (diff)
downloadstm32_ade-809b705559a51cac8cd301dbbe7e133e8607fbf6.tar.gz
stm32_ade-809b705559a51cac8cd301dbbe7e133e8607fbf6.tar.bz2
stm32_ade-809b705559a51cac8cd301dbbe7e133e8607fbf6.zip
change led code, and print something out
-rw-r--r--app/led.c28
-rw-r--r--app/led.h3
-rw-r--r--app/main.c23
-rw-r--r--app/project.h1
-rw-r--r--app/prototypes.h1
5 files changed, 39 insertions, 17 deletions
diff --git a/app/led.c b/app/led.c
index 64c4660..6e8fa65 100644
--- a/app/led.c
+++ b/app/led.c
@@ -7,42 +7,42 @@ void
led_init (void)
{
gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
- GPIO_CNF_OUTPUT_PUSHPULL, GPIO8);
+ GPIO_CNF_OUTPUT_PUSHPULL, LED0);
gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
- GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
+ GPIO_CNF_OUTPUT_PUSHPULL, LED1);
}
void
led_clear (void)
{
- gpio_set (GPIOB, GPIO8);
- gpio_set (GPIOB, GPIO9);
+ gpio_set (GPIOB, LED0);
+ gpio_set (GPIOB, LED1);
}
void
-led_set (uint32_t v)
+led_flash (uint32_t v)
{
gpio_clear (GPIOB, v);
led = 200;
}
+void led_set(uint32_t v)
+{
+v&= LED_MASK;
+gpio_clear(GPIOB,v);
+v^=LED_MASK;
+gpio_set(GPIOB,v);
+}
+
+
void
led_tick (void)
{
- static int c;
-
if (led)
{
led--;
if (!led)
led_clear ();
}
- else
- {
- led_set (c ? GPIO8 : GPIO9);
- c ^= 1;
- }
-
-
}
diff --git a/app/led.h b/app/led.h
new file mode 100644
index 0000000..7575958
--- /dev/null
+++ b/app/led.h
@@ -0,0 +1,3 @@
+#define LED0 GPIO8
+#define LED1 GPIO9
+#define LED_MASK (LED0|LED1)
diff --git a/app/main.c b/app/main.c
index 84edc6f..41aa657 100644
--- a/app/main.c
+++ b/app/main.c
@@ -9,15 +9,15 @@ kbd_dispatch (void)
if (ring_read_byte (&rx1_ring, &c))
return;
- printf("KEY> %c\r\n",c);
+ printf ("KEY> %c\r\n", c);
}
int
main (void)
{
-// rcc_clock_setup_in_hsi_out_48mhz ();
- //nvic_set_priority_grouping(NVIC_PriorityGroup_4);
+ char buf[128];
+ int c;
/*set up pll */
rcc_clock_setup_in_hse_8mhz_out_72mhz ();
@@ -49,9 +49,26 @@ main (void)
for (;;)
{
+
if (!ring_empty (&rx1_ring))
kbd_dispatch ();
+ delay_ms (1000);
+
+ printf ("Counter is %x\n", c);
+
+ sprintf (buf, "%8x", c++);
+ lcd_write (buf, 0, 1);
+
+ led_set (c & 1 ? LED0 : LED1);
+
+
+
+
+
+
+
+
}
return 0;
diff --git a/app/project.h b/app/project.h
index 89184aa..b698423 100644
--- a/app/project.h
+++ b/app/project.h
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <errno.h>
+#include "led.h"
#include "i2c.h"
#include "ring.h"
diff --git a/app/prototypes.h b/app/prototypes.h
index 2e0163c..2b91b5d 100644
--- a/app/prototypes.h
+++ b/app/prototypes.h
@@ -32,6 +32,7 @@ extern void lcd_shutdown(void);
/* led.c */
extern void led_init(void);
extern void led_clear(void);
+extern void led_flash(uint32_t v);
extern void led_set(uint32_t v);
extern void led_tick(void);
/* main.c */