Advertisement
Guest User

Receiver

a guest
Sep 24th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. int main(void) {
  2.     uint8_t c;
  3.  
  4.     /* Initialize system */
  5.     SystemInit();
  6.  
  7.     /* Initialize USART1 at 9600 baud, TX: PB6, RX: PB7 */
  8.     TM_USART_Init(USART1, TM_USART_PinsPack_2, 9600);
  9.  
  10.     /* Put string to USART */
  11.     //TM_USART_Puts(USART1, "Hello world\n\r");
  12.     GPIO_InitTypeDef GPIO_InitDef;
  13.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
  14.     GPIO_InitDef.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14;
  15.     GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;
  16.     GPIO_InitDef.GPIO_OType = GPIO_OType_PP;
  17.     GPIO_InitDef.GPIO_PuPd = GPIO_PuPd_NOPULL;
  18.     GPIO_InitDef.GPIO_Speed = GPIO_Speed_100MHz;
  19.     //Initialize pins
  20.     GPIO_Init(GPIOG, &GPIO_InitDef);
  21.  
  22.     while (1) {
  23.         /* Get character from internal buffer */
  24.         c = TM_USART_Getc(USART1);
  25.         if (c) {
  26.             /* If anything received, put it back to terminal */
  27.             GPIO_SetBits(GPIOG, GPIO_Pin_13 | GPIO_Pin_14);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement