Guest User

TM_Usart

a guest
May 14th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include "stm32f4xx.h"
  2. #include "stm32f4xx_rcc.h"
  3. #include "stm32f4xx_gpio.h"
  4. #include "stm32f4xx_usart.h"
  5. #include "misc.h"
  6. //TM Libraries included here
  7. #include "defines.h"
  8. #include "attributes.h"
  9. #include "tm_stm32f4_gpio.h"
  10. #include "tm_stm32f4_usart.h"
  11.  
  12. int main(void) {
  13. uint8_t c;
  14.  
  15. /* Initialize system */
  16. SystemInit();
  17.  
  18. /* Initialize USART1 at 9600 baud, TX: PB6, RX: PB7 */
  19. TM_USART_Init(USART1, TM_USART_PinsPack_2, 9600);
  20.  
  21. /* Put string to USART */
  22. TM_USART_Puts(USART1, "Hello world\n\r");
  23. while (1) {
  24. /* Get character from internal buffer */
  25. c = TM_USART_Getc(USART1);
  26. if (c) {
  27. /* If anything received, put it back to terminal */
  28. TM_USART_Putc(USART1, c);
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment