资源简介
W8782 WIFI模块驱动代码,STM32F407,注意!具体是否适合自己的开发板要自己移植,本人用的是老衲五木大佬的LOT-
代码片段和文件信息
#define DEBUG
#include “debug.h“
#include “drivers.h“
#include “stdio.h“
#include “api.h“
#include “lwip/stats.h“
#include “lwip/sockets.h“
#include “lwip/api.h“
#include “lwip/tcp.h“
#include “lwip/arch/sys_arch.h“
#include “lwip/memp.h“
#include
#if SYS_MONITOR == 0
bool monitor_enable = 0;
#else
bool monitor_enable = 1;
#endif
int dbg_level = 1;
int cpu_used = 0;
void monitor_switch()
{
monitor_enable = !monitor_enable;
if(monitor_enable)
p_dbg(“打开monitor“);
else
p_dbg(“关闭monitor“);
}
void send_test_pkg(int cmd const void *data int size)
{
static uint8_t g_seq = 0;
uint8_t *pkg;
uint8_t *p_data = (uint8_t*)data;
int i;
uint8_t sum = 0;
if ((size > 1024) || (size && (p_data == 0)))
{
return ;
}
pkg = (uint8_t*)mem_malloc2(size + 7);
if (pkg == 0)
{
p_err(“send_pkg mem_malloc err size:%d\n“ size + 7);
return ;
}
pkg[0] = 0xaa;
pkg[1] = (uint8_t)cmd;
pkg[2] = (uint8_t)((size + 7) % 256);
pkg[3] = (uint8_t)((size + 7) / 256);
pkg[4] = (uint8_t)g_seq++;
sum ^= pkg[1];
sum ^= pkg[2];
sum ^= pkg[3];
sum ^= pkg[4];
for (i = 0; i < size; i++)
{
pkg[i + 5] = p_data[i];
sum ^= p_data[i];
}
pkg[i + 5] = sum;
pkg[i + 6] = 0x55;
uart1_send(pkg i + 7);
mem_free2(pkg);
}
#pragma section = “monitor_item_table“
char *p_globle_buff = 0;
#define GLOBLE_TEST_BUFF_SIZE 2048
typedef enum
{
STAT_TYPE_SYS = 1 STAT_TYPE_TASK STAT_TYPE_WIFI STAT_TYPE_SOCKET STAT_TYPE_MAX_VALUE
} STAT_TYPE;
DECLARE_MONITOR_ITEM(“monitor item example“ monitor_send_cnt);
char *err = “test_buff err“;
#define CHECK_AND_ADD_BUFF { \
tmp[127] = 0;\
cnt += strlen(tmp);\
if(cnt > (GLOBLE_TEST_BUFF_SIZE - 64)){\
p_err(“%s l:%d len:%d tmp_len:%d “ err __LINE__ cnt strlen(tmp));\
goto end;\
}\
strcat(p_globle_buff tmp);\
}
#define CHECK_AND_ADD_LINE { \
sprintf(tmp “\r\n“); \
tmp[127] = 0;\
cnt += strlen(tmp);\
if(cnt > (GLOBLE_TEST_BUFF_SIZE - 64)){\
p_err(“%s l:%d len:%d tmp_len:%d “ err __LINE__ cnt strlen(tmp));\
goto end;\
}\
strcat(p_globle_buff tmp);\
}
extern const uint32_t monitor_item_table$$base;
extern const uint32_t monitor_item_table$$Limit;
extern char STACK$$base[];
#define STACK_SIZE 0X200
uint32_t get_msp_size()
{
return (uint32_t)STACK_SIZE;
}
uint32_t get_msp_free()
{
int i;
uint32_t *stack_base = (uint32_t*)STACK$$base;
uint32_t stack_size = STACK_SIZE;
stack_size = stack_size / 4;
for (i = 0; i < stack_size; i++)
{
if (stack_base[i])
break;
}
return i *4;
}
void send_sys_stat_data()
{
char *tmp;
int cnt = 0 i;
uint32_t start end;
tmp = (char*)mem_malloc2(128);
if (!tmp)
return ;
INC_MONITOR_ITEM_VALUE(monitor_send_cnt);
send_test_pkg(STAT_TYPE_SYS 0 0);
memset(p_globle_buff 0 GLOBLE_TEST_BUFF_SIZE);
#ifdef OS_UCOS
#ifdef UCOS_V3
cpu_used = OSStatTaskCPUUsage/100;
snprintf(tmp 127 “C
相关资源
- 基于IAR的STM32F407程序模板
- gnuplot5.0.5 windows安装包 亲测可用
- 2019年电赛h题电磁曲线炮,stm32f407控制
- Gambit和Tecplot相关学习资料
- stm32f407开发板实现485串口modbus协议通
- opus编解码移植stm32f407
- STM32F407,18电赛A题,非接触式电流检
- STM32F407编码器
- 正点原子STM32F407探索者PCB图+原理图
- STM32F407 USB Device HID Full Speed 例程
- SigmaPlot中文教程
- STM32F407信号发生器整体代码.zip
- HoloToolKit-Unity2017.1.1
- Obi 5 --Obi Rope/Obi Cloth/Obi Fluid/Obi SoftB
- FloTHERM软件基础与应用李波编著-第二
- OPENPILOT CC3D等飞控资料
- omniglot数据集
- Tecplot360EX2015R1中文特别版32位附安装教
- pandas+matplotlib练习数据
- stm32f407驱动ws2818全彩灯7灯
- 基于stm32f407飞控+stm32f103遥控sxy飞行器
- STM32F407参考手册
- 基于STM32F407--OLED--两线IIC显示
- STM32F407智能家居
- 基于stm32f407实现的modbus/tcp
- STM32F407上实现Modbus协议,包括多种C
- Unity - Obi cloth布料模拟插件
- 基于STM32F407的web服务器,可进行设备
- 各种版本的ISOPLOT
- STM32F407+USB_HS
评论
共有 条评论