aboutsummaryrefslogtreecommitdiff
path: root/self-test/uart-test.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2015-10-29 15:42:29 -0400
committerPaul Selkirk <paul@psgd.org>2015-10-29 15:42:29 -0400
commit9278e9bafd96105b64f9946eb94f5618f01649d3 (patch)
tree2aca37b1edebc9eb717456179f85927929c98cbb /self-test/uart-test.c
parentfb73e2d75b4e99a29c28bbbaf754222010c273b7 (diff)
add libhal tests, some cleanup (some mess-making)
Diffstat (limited to 'self-test/uart-test.c')
-rw-r--r--self-test/uart-test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/self-test/uart-test.c b/self-test/uart-test.c
new file mode 100644
index 0000000..8fe7795
--- /dev/null
+++ b/self-test/uart-test.c
@@ -0,0 +1,34 @@
+/*
+ * Test code that just sends the letters 'a' to 'z' over and
+ * over again using USART2.
+ *
+ * Toggles the BLUE LED slowly and the RED LED for every
+ * character sent.
+ */
+#include "stm32f4xx_hal.h"
+#include "stm-init.h"
+#include "stm-led.h"
+#include "stm-uart.h"
+
+#define DELAY() HAL_Delay(100)
+
+int
+main()
+{
+ uint8_t c = 'a';
+
+ stm_init();
+
+ while (1)
+ {
+ HAL_GPIO_TogglePin(LED_PORT, LED_RED);
+
+ uart_send_char(c);
+ DELAY();
+
+ if (c++ == 'z') {
+ c = 'a';
+ HAL_GPIO_TogglePin(LED_PORT, LED_BLUE);
+ }
+ }
+}