Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main()
- {
- GPIOInitialize();
- UART_Initialize();
- USART_puts("AT\r");
- USART_puts("AT+CREG?\r");
- USART_puts("AT+CGATT=1\r"); //GPRS ok
- USART_puts("AT+CIPSHUT\r");
- USART_puts("AT+CSTT=\"airtelgprs.com\"\r");
- USART_puts("AT+CIICR\r");
- USART_puts("AT+CIPSTART=\"TCP\",\"www.google.com\",\"80\"\r");
- }
- void USART1_IRQHandler()
- {
- if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //it checks receive complete interrupt(USART_IT_RXNE) on USARTx
- {
- rx_web = USART_ReceiveData(USART1);
- if(rx_web == 0x0A || rx_web == 0x0D)
- {
- count++;
- if(count==4)
- {end_flag=1;}
- }
- else if(rx_index < LINEMAX)
- {
- rx_buf_web[rx_index++]=rx_web;
- }
- }
- }
- void UART_Initialize(void)
- {
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
- USART_InitStructure.USART_BaudRate = 9600;
- USART_InitStructure.USART_WordLength = USART_WordLength_8b;
- USART_InitStructure.USART_StopBits = USART_StopBits_1;
- USART_InitStructure.USART_Parity = USART_Parity_No;
- USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
- USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
- USART_Init(USART1, &USART_InitStructure); // USART configuration
- USART_Init(USART2, &USART_InitStructure); // USART configuration
- USART_Cmd(USART1, ENABLE); // Enable USART
- USART_Cmd(USART2, ENABLE); // Enable USART
- }
- void GPIOInitialize(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); //Enable clock for GPIOB
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- GPIO_Init(GPIOD, &GPIO_InitStructure);
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1);//Connect PB6 to USART1_Tx
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);//Connect PB7 to USART1_Rx
- GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2);//connect PA5 to USART2_Tx
- GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2);//Connect PA6 to USART2_Rx
- }
Add Comment
Please, Sign In to add comment