summaryrefslogtreecommitdiff
path: root/src/uart-test/src/main.c
blob: b7058a658c8cd6e2b4c22a029ff2eeaf3916d385 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
    }
  }
}