summaryrefslogtreecommitdiff
path: root/src/uart-test/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/uart-test/src/main.c')
-rw-r--r--src/uart-test/src/main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/uart-test/src/main.c b/src/uart-test/src/main.c
new file mode 100644
index 0000000..b7058a6
--- /dev/null
+++ b/src/uart-test/src/main.c
@@ -0,0 +1,31 @@
+/*
+ * 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 "stm_init.h"
+
+#define DELAY() HAL_Delay(100)
+
+int
+main()
+{
+ uint8_t c = 'a';
+
+ stm_init();
+
+ while (1)
+ {
+ HAL_GPIO_TogglePin(LED_PORT, LED_RED);
+
+ HAL_UART_Transmit(&huart2, (uint8_t *) &c, 1, 0x1);
+ DELAY();
+
+ if (c++ == 'z') {
+ c = 'a';
+ HAL_GPIO_TogglePin(LED_PORT, LED_BLUE);
+ }
+ }
+}