Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /* Enable USART clock */
  2. RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
  3. /* Connect PXx to USARTx_Tx */
  4. GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_7);
  5. /* Connect PXx to USARTx_Rx */
  6. GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_7);
  7. /* Configure USART Tx as alternate function push-pull */
  8. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  9. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  10. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  11. GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  12. GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  13. GPIO_Init(GPIOA, &GPIO_InitStructure);
  14. /* Configure USART Rx as alternate function push-pull */
  15. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  16. GPIO_Init(GPIOA, &GPIO_InitStructure);
  17. /* USART configuration */
  18. USART_InitStructure.USART_BaudRate = 9600;
  19. USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  20. USART_InitStructure.USART_StopBits = USART_StopBits_1;
  21. USART_InitStructure.USART_Parity = USART_Parity_No;
  22. USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  23. USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  24. USART_Init(USART2, &USART_InitStructure);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement