diff options
author | Fredrik Thulin <fredrik@thulin.net> | 2015-01-15 17:04:03 +0100 |
---|---|---|
committer | Fredrik Thulin <fredrik@thulin.net> | 2015-01-15 17:04:03 +0100 |
commit | 39cac7918987fc603dc54886e107af026583592e (patch) | |
tree | acb95e5cebc2f410840659cc7e6d1a74331e3985 /src/uart-test/main.c | |
parent | 3347165e2927ec73014eafdfc0c650904a4b67d4 (diff) |
init
Diffstat (limited to 'src/uart-test/main.c')
-rw-r--r-- | src/uart-test/main.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/uart-test/main.c b/src/uart-test/main.c new file mode 100644 index 0000000..77c17f4 --- /dev/null +++ b/src/uart-test/main.c @@ -0,0 +1,32 @@ +/* + * Test code that just sends the letters 'a' to 'z' over and + * over again using USART1. + * + * Toggles the BLUE LED slowly and the YELLOW LED for every + * character sent. + */ +#include "stm_init.h" + +#define DELAY() HAL_Delay(250) + +int +main() +{ + uint8_t c = 'a'; + uint32_t i = 0; + + stm_init(); + + while (1) + { + HAL_GPIO_TogglePin(LED_PORT, LED_YELLOW); + + HAL_UART_Transmit(&huart1, (uint8_t *) &c, 1, 0xff); + DELAY(); + + if (c++ == 'z') { + c = 'a'; + HAL_GPIO_TogglePin(LED_PORT, LED_BLUE); + } + } +} |