[原创] 【MXCHIP Open1081】wifi发送第一个数据

ljj3166   2014-11-19 19:17 楼主
先刨个坑 等视频上传好了再来填坑,吼吼 使用mx1081的AD模块,采集AD值,然后送wifi发送 使用UDP,简单快速明了,关键是人比较懒 虽然实现了,但是还有很多地方不是很明白 上代码,简单注释了一下main函数回复可见,哇咔咔 #include "stdio.h" #include "ctype.h" #include "MX1081_IO.H" #include "stm32f2xx.h" #include "platform.h" #include "mxchipWNET.h" #define ADC1_DR_Address ((u32)0x4001204C) void ADC1_CH1_DMA_Config(void); float AD_value_1; vu16 ADC_ConvertedValue[2]; #define LowPowerMode #define AP_NAME "Ljj@Home" #define AP_PASSWORD "xxxxxxxx" //我家的密码,就不告诉你,吼吼 #define APP_INFO "mxchipWNet Demo: Wi-Fi Link" network_InitTypeDef_st wNetConfig; net_para_st para; /* ======================================== User provide callback functions ======================================== */ void system_version(char *str, int len) { snprintf( str, len, "%s", APP_INFO); } void userWatchDog(void) { } void WifiStatusHandler(int event) { switch (event) { case MXCHIP_WIFI_UP: printf("Station up \r\n"); break; case MXCHIP_WIFI_DOWN: printf("Station down \r\n"); break; case MXCHIP_UAP_UP: printf("uAP up \r\n"); getNetPara(¶, Soft_AP); printf("Soft AP mode: IP address: %s \r\n", para.ip); printf("Soft AP mode: NetMask address: %s \r\n", para.mask); printf("Soft AP mode: MAC address: %s \r\n", para.mac); break; case MXCHIP_UAP_DOWN: printf("uAP down \r\n"); break; default: break; } return; } void ApListCallback(UwtPara_str *pApList) { int i; printf("Find %d APs: \r\n", pApList->ApNum); for (i=0;iApNum;i++) printf(" SSID: %s, Signal: %d%%\r\n", pApList->ApList.ssid, pApList->ApList.ApPower); } void NetCallback(net_para_st *pnet) { printf("Station mode: IP address: %s \r\n", pnet->ip); printf("Station mode: NetMask address: %s \r\n", pnet->mask); printf("Station mode: Gateway address: %s \r\n", pnet->gate); printf("Station mode: DNS server address: %s \r\n", pnet->dns); printf("Station mode: MAC address: %s \r\n", pnet->mac); } void stationModeStart(void) { int ret; memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_st)); wNetConfig.wifi_mode = Station; strcpy((char*)wNetConfig.wifi_ssid, AP_NAME); strcpy((char*)wNetConfig.wifi_key, AP_PASSWORD); wNetConfig.dhcpMode = DHCP_Client; ret = StartNetwork(&wNetConfig); printf("connect to %s....., return %d\r\n", wNetConfig.wifi_ssid, ret); } void softAPModeStart(void) { int ret; memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_st)); wNetConfig.wifi_mode = Soft_AP; strcpy((char*)wNetConfig.wifi_ssid, "Soft AP test"); strcpy((char*)wNetConfig.wifi_key, ""); strcpy((char*)wNetConfig.local_ip_addr, "192.168.0.1"); strcpy((char*)wNetConfig.net_mask, "255.255.255.0"); strcpy((char*)wNetConfig.address_pool_start, "192.168.0.10"); strcpy((char*)wNetConfig.address_pool_end, "192.168.0.177"); wNetConfig.dhcpMode = DHCP_Server; ret = StartNetwork(&wNetConfig); printf("Setup soft AP: %s, return %d\r\n", wNetConfig.wifi_ssid, ret); } vs32 tick = 0; vs32 button_irq = 0; void RptConfigmodeRslt(network_InitTypeDef_st *nwkpara) { if(nwkpara == NULL){ printf("Configuration failed\r\n"); } else{ printf("Configuration is successful, SSID:%s, Key:%s\r\n", \ nwkpara->wifi_ssid,\ nwkpara->wifi_key); } } char* itostr(char *str, int i) { sprintf(str, "%d", i); return str; } i
游客,如果您要查看本帖隐藏内容请回复
void Button_irq_handler(void *arg) { printf("Start scanning by user...\r\n"); mxchipStartScan(); } void ADC1_CH1_DMA_Config(void) //stm32的AD配置,DMA模式 { ADC_InitTypeDef ADC_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; DMA_InitTypeDef DMA_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); // DMA_DeInit(DMA2_Stream0); /* DMA2 Stream0 channe0 configuration **************************************/ DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_Address; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADC_ConvertedValue; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_BufferSize = 2; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA2_Stream0, &DMA_InitStructure); DMA_Cmd(DMA2_Stream0, ENABLE); /* Configure ADC1 Channe6 pin as analog input ******************************/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOA, &GPIO_InitStructure); /* ADC Common Init **********************************************************/ ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles; ADC_CommonInit(&ADC_CommonInitStructure); /* ADC1 Init ****************************************************************/ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfConversion = 2; ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 regular channe6 configuration *************************************/ ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 1, ADC_SampleTime_3Cycles); // ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 2, ADC_SampleTime_3Cycles); /* Enable DMA request after last transfer (Single-ADC mode) */ ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE); /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); } 本帖最后由 ljj3166 于 2014-11-19 19:24 编辑
So TM what......?

回复评论 (13)

宇宙惯例,沙发自留
顺道消灭〇回复
So TM what......?
点赞  2014-11-19 19:23
支持,顶一下。
点赞  2014-11-19 20:32
看下回复可见~~
水不撩不知深浅 人不拼怎知输赢
点赞  2014-11-19 21:24
对wifi还有好多未开发区域啊
点赞  2014-11-20 18:02
封装起来也就算了 说明给的详细点也成啊 同感
点赞  2014-11-20 18:05
wifi封装成库,理解起来感觉吃力,楼主不错的分享
点赞  2014-11-23 20:37
好的  学习下
点赞  2014-11-24 15:33
,看看
点赞  2014-11-26 22:49
zzzz
点赞  2014-12-14 09:55
回复为了看内容
点赞  2014-12-14 09:55
楼主能测试一下UDP 1秒内能传送的最大数据量吗?可不可以考虑把OV的图像快速传送到上位机,实现视频传送
点赞  2014-12-26 16:00
引用: tak_shing 发表于 2014-12-26 16:00
楼主能测试一下UDP 1秒内能传送的最大数据量吗?可不可以考虑把OV的图像快速传送到上位机,实现视频传送
这个倒没具体测试过,不过图像应该问题不大,实时性就可能稍微差点
So TM what......?
点赞  2014-12-26 20:37
资源很好啊
点赞  2015-5-13 21:50
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复