aboutsummaryrefslogtreecommitdiff
path: root/uart-test.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2015-10-26 15:18:58 -0400
committerPaul Selkirk <paul@psgd.org>2015-10-26 15:18:58 -0400
commit26f12903dab2fafeaaefb02349763618ce96d070 (patch)
treeb37cceea7014770ea2ae039928e57b6f02c0aaa2 /uart-test.c
Based on user/ft/stm32-dev-bridge, without the project-specific build
directories (and duplicated code).
Diffstat (limited to 'uart-test.c')
-rw-r--r--uart-test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/uart-test.c b/uart-test.c
new file mode 100644
index 0000000..0f8926a
--- /dev/null
+++ b/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);
+
+ HAL_UART_Transmit(&huart2, (uint8_t *) &c, 1, 0x1);
+ DELAY();
+
+ if (c++ == 'z') {
+ c = 'a';
+ HAL_GPIO_TogglePin(LED_PORT, LED_BLUE);
+ }
+ }
+}