diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/inc/wifi.h b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/inc/wifi.h index 44f018f..642a83b 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/inc/wifi.h +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/inc/wifi.h @@ -7,6 +7,7 @@ void wifi_init(); void wifi_sendSingleByte(unsigned char cmd); -void wifi_sendData(); +void wifi_sendData(char * cmd); +void wifi_sendCmd(char * cmd); #endif diff --git a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c index 04be4c5..36b63eb 100644 --- a/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c +++ b/libs/STM32_USB-FS-Device_Lib_V4.0.0/Libraries/STM32F10x_StdPeriph_Driver/src/wifi.c @@ -33,6 +33,18 @@ void wifi_sendSingleByte(unsigned char cmd) { while((USART3->SR & 0x40) == 0); } -void wifi_sendData() { +void wifi_sendData(char * cmd) { + unsigned short pointer = 0; + while(*(cmd + pointer)) { + wifi_sendSingleByte((unsigned char)*(cmd + pointer)); + pointer++; + } + + wifi_sendSingleByte(0x0D); + wifi_sendSingleByte(0x0A); } +void wifi_sendCmd(char * cmd) { + wifi_sendData("AT+"); + wifi_sendData(cmd); +} diff --git a/src/main.c b/src/main.c index 4f46d6a..bfd7099 100644 --- a/src/main.c +++ b/src/main.c @@ -4,7 +4,7 @@ #include "mpu6050.h" #include "motor.h" #include "uart.h" - +#include "wifi.h" #include "key.h" #define Kp 100.0f //比例增益支配率(常量) @@ -111,6 +111,11 @@ int main() { uart_init(72, 115200); MPU_init(); + + wifi_init(); + + wifi_sendCmd("CWMODE=2"); + SixAxis sourceData;