aboutsummaryrefslogblamecommitdiff
path: root/src/uart-test/main.c
blob: 77c17f4d16faed3b4befe0f0209b1c7a9bb37fd2 (plain) (tree)































                                                            
/*
 * 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);
    }
  }
}