main.c 643 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*!
  2. \file main.c
  3. \brief USART printf
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #include "gd32f3x0.h"
  10. #include <stdio.h>
  11. #include "gd32f3x0_eval.h"
  12. /*!
  13. \brief main function
  14. \param[in] none
  15. \param[out] none
  16. \retval none
  17. */
  18. int main(void)
  19. {
  20. gd_eval_com_init(EVAL_COM1);
  21. printf("a usart transmit test example!");
  22. while (1);
  23. }
  24. /* retarget the C library printf function to the USART */
  25. int fputc(int ch, FILE *f)
  26. {
  27. usart_data_transmit(EVAL_COM1, (uint8_t) ch);
  28. while(RESET == usart_flag_get(EVAL_COM1, USART_FLAG_TBE));
  29. return ch;
  30. }