#include "wifi_gpio_conf.h" #include "wifi9113.h" /*******************wifi UART通讯配置*********************/ void Configuration_WIFI_Usart1 ( void ) { #if (WIFI_Uart1_def || UART1_SD_def) GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; //使能USART1/GPIO 时钟可配置 Wifi_RCC_GPIO_CONFIG(); Wifi_RCC_UART_CONFIG(); /* * USART1_TX -> PA9 , USART1_RX -> PA10 */ GPIO_InitStructure.GPIO_Pin = Wifi_Tx; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init ( Wifi_GPIO, &GPIO_InitStructure ); GPIO_InitStructure.GPIO_Pin = Wifi_Rx; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init ( Wifi_GPIO, &GPIO_InitStructure ); USART_InitStructure.USART_BaudRate = Wifi_UART_BAUD; 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 ( Wifi_UART, &USART_InitStructure ); USART_ITConfig ( Wifi_UART, USART_IT_RXNE, ENABLE ); USART_ITConfig ( Wifi_UART, USART_IT_TXE, DISABLE ); USART_Cmd ( Wifi_UART, ENABLE ); #endif } //系统中断管理 void NVIC_Configuration_WIFI_USART1 ( void ) { #if WIFI_Uart1_def NVIC_InitTypeDef NVIC_InitStructure; /* Configure the NVIC Preemption Priority Bits */ NVIC_PriorityGroupConfig ( Wifi_NVIC_Group ); /* Enable the USARTy Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = Wifi_NVIC_Interrupt; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = Wifi_NVIC_Pre; NVIC_InitStructure.NVIC_IRQChannelSubPriority = Wifi_NVIC_Sub; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init ( &NVIC_InitStructure ); #endif } /*******************wifi硬复位配置*********************/ void Configuration_ResetWifi ( void ) { #if WIFI_Uart1_def GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd ( Reset_IORCC, ENABLE ); GPIO_InitStructure.GPIO_Pin = Reset_Pin; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init ( Reset_PORT, &GPIO_InitStructure ); #endif } void WifiHardReset ( void ) { #if WIFI_Uart1_def GPIO_ResetBits ( Reset_PORT, Reset_Pin ); GPIO_SetBits ( Reset_PORT, Reset_Pin ); WifiProcessStep = WIFI_STEP_CHECK; WifiTimeReset = 0; #endif } void WifiSoftReset ( void ) { strcpy ( bAtSentBuff, CONNECT_RESET ); AtSent ( bAtSentBuff, strlen ( bAtSentBuff ) ); } /*******************wifi信号灯*********************/ void Configuration_WifiLed ( void ) { #if WIFI_Uart1_def GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd ( WifiLed_IORCC, ENABLE ); GPIO_InitStructure.GPIO_Pin = WifiLed_Pin; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init ( WifiLed_PORT, &GPIO_InitStructure ); #endif }