parent
887c05a289
commit
38950c78c1
|
@ -4,7 +4,9 @@
|
||||||
"provalctrl.h": "c",
|
"provalctrl.h": "c",
|
||||||
"timer.h": "c",
|
"timer.h": "c",
|
||||||
"mf5803.h": "c",
|
"mf5803.h": "c",
|
||||||
"eeprom.h": "c"
|
"eeprom.h": "c",
|
||||||
|
"ch395.h": "c",
|
||||||
|
"modbus.h": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||||
|
|
|
@ -350,9 +350,11 @@ void ch395_hardware_init(void)
|
||||||
|
|
||||||
g_ch395q_sta.ch395_error(ch395_cmd_init()); /* 初始化ch395q命令 */
|
g_ch395q_sta.ch395_error(ch395_cmd_init()); /* 初始化ch395q命令 */
|
||||||
ch395_socket_r_s_buf_modify();
|
ch395_socket_r_s_buf_modify();
|
||||||
// ch395_set_tcpmss(536);
|
|
||||||
// ch395_set_start_para(FUN_PARA_FLAG_TCP_SERVER | SOCK_CTRL_FLAG_SOCKET_CLOSE);
|
|
||||||
|
|
||||||
|
#if MULTI_CONNECT_ENABLE
|
||||||
|
ch395_set_tcpmss(536);
|
||||||
|
ch395_set_start_para(FUN_PARA_FLAG_TCP_SERVER | SOCK_CTRL_FLAG_SOCKET_CLOSE);
|
||||||
|
#endif
|
||||||
// do
|
// do
|
||||||
// {
|
// {
|
||||||
g_ch395q_sta.phy_status = ch395_cmd_get_phy_status(); /* 获取PHY状态 */
|
g_ch395q_sta.phy_status = ch395_cmd_get_phy_status(); /* 获取PHY状态 */
|
||||||
|
@ -402,7 +404,10 @@ void ch395_socket_interrupt(uint8_t sockindex)
|
||||||
rx_len = g_ch395q_sta.socket[sockindex].config.recv.size;
|
rx_len = g_ch395q_sta.socket[sockindex].config.recv.size;
|
||||||
ch395_get_recv_data(sockindex, rx_len, g_ch395q_sta.socket[sockindex].config.recv.buf); /* 读取数据 */
|
ch395_get_recv_data(sockindex, rx_len, g_ch395q_sta.socket[sockindex].config.recv.buf); /* 读取数据 */
|
||||||
g_ch395q_sta.socket[sockindex].config.recv.buf[rx_len] = '\0';
|
g_ch395q_sta.socket[sockindex].config.recv.buf[rx_len] = '\0';
|
||||||
|
|
||||||
|
multi_connect_socket_index = sockindex;
|
||||||
modbus_process_tcp();
|
modbus_process_tcp();
|
||||||
|
|
||||||
//printf("%s", g_ch395q_sta.socket[sockindex].config.recv.buf);
|
//printf("%s", g_ch395q_sta.socket[sockindex].config.recv.buf);
|
||||||
g_ch395q_sta.socket[sockindex].config.recv.recv_flag |= 0x04;
|
g_ch395q_sta.socket[sockindex].config.recv.recv_flag |= 0x04;
|
||||||
}
|
}
|
||||||
|
@ -544,12 +549,33 @@ void ch395_interrupt_handler(void)
|
||||||
* @retval 无
|
* @retval 无
|
||||||
*/
|
*/
|
||||||
int reconnect_times = 0;
|
int reconnect_times = 0;
|
||||||
|
uint8_t tcp_breath_cnt = 0,connect_cnt = 0;;
|
||||||
void ch395q_handler(void)
|
void ch395q_handler(void)
|
||||||
{
|
{
|
||||||
|
if(breathe_flag == 1)
|
||||||
|
{
|
||||||
|
breathe_flag = 0;
|
||||||
|
|
||||||
|
tcp_breath_cnt++;
|
||||||
|
connect_cnt++;
|
||||||
|
if(tcp_breath_cnt > 60)
|
||||||
|
{
|
||||||
|
tcp_breath_cnt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ch395_int_pin_wire == 0)
|
if (ch395_int_pin_wire == 0)
|
||||||
{
|
{
|
||||||
|
connect_cnt = 0;
|
||||||
ch395_interrupt_handler(); /* 中断处理函数 */
|
ch395_interrupt_handler(); /* 中断处理函数 */
|
||||||
|
tcp_breath_cnt = 0;
|
||||||
}
|
}
|
||||||
|
if(connect_cnt == 10)
|
||||||
|
{
|
||||||
|
//ch395_tcp_disconnect(0);
|
||||||
|
}
|
||||||
|
else if(connect_cnt > 10)
|
||||||
|
connect_cnt = 11;
|
||||||
|
|
||||||
if(reconnect_flag == 1)
|
if(reconnect_flag == 1)
|
||||||
{
|
{
|
||||||
|
@ -567,15 +593,14 @@ void ch395q_handler(void)
|
||||||
//socket_watch[1]:0x01->listen, 0x04->established
|
//socket_watch[1]:0x01->listen, 0x04->established
|
||||||
uint8_t socket_watch[8][2];
|
uint8_t socket_watch[8][2];
|
||||||
uint8_t rec_test_flag = 0;
|
uint8_t rec_test_flag = 0;
|
||||||
|
uint8_t open_flag[8] = {0};
|
||||||
|
uint8_t listen_flag = 0;
|
||||||
void ch395_reconnection(void)
|
void ch395_reconnection(void)
|
||||||
{
|
{
|
||||||
if (rec_test_flag == 1)
|
if(rec_test_flag == 1)
|
||||||
{
|
{
|
||||||
rec_test_flag = 0;
|
rec_test_flag = 0;
|
||||||
|
ch395_close_socket(1);
|
||||||
//ch395_tcp_disconnect(0);
|
|
||||||
|
|
||||||
ch395_close_socket(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t socket_index = CH395Q_SOCKET_0 ; socket_index <= CH395Q_SOCKET_7 ; socket_index ++ )
|
for (uint8_t socket_index = CH395Q_SOCKET_0 ; socket_index <= CH395Q_SOCKET_7 ; socket_index ++ )
|
||||||
|
@ -595,13 +620,36 @@ void ch395_reconnection(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if MULTI_CONNECT_ENABLE
|
||||||
ch395_cmd_get_socket_status(socket_index, socket_watch[socket_index]);
|
ch395_cmd_get_socket_status(socket_index, socket_watch[socket_index]);
|
||||||
if(socket_watch[CH395Q_SOCKET_0][0] != 0x05)
|
|
||||||
|
if(socket_index == CH395Q_SOCKET_0)
|
||||||
|
{
|
||||||
|
if( (socket_watch[socket_index][0] != 0x05)||(open_flag[socket_index] != CH395_ERR_OPEN) )
|
||||||
{
|
{
|
||||||
//客户端断连后会关闭socket,因此在这里重新打开
|
//客户端断连后会关闭socket,因此在这里重新打开
|
||||||
ch395_open_socket(CH395Q_SOCKET_0);
|
open_flag[socket_index] = ch395_open_socket(socket_index);
|
||||||
ch395_tcp_listen(CH395Q_SOCKET_0);
|
|
||||||
|
}else if(socket_watch[socket_index][1] != 0x01)
|
||||||
|
{
|
||||||
|
listen_flag = ch395_tcp_listen(socket_index);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ch395_cmd_get_socket_status(socket_index, socket_watch[socket_index]);
|
||||||
|
if( (socket_watch[CH395Q_SOCKET_0][0] != 0x05)||(open_flag != CH395_ERR_OPEN) )
|
||||||
|
{
|
||||||
|
//客户端断连后会关闭socket,因此在这里重新打开
|
||||||
|
open_flag = ch395_open_socket(CH395Q_SOCKET_0);
|
||||||
|
}
|
||||||
|
else if((socket_watch[CH395Q_SOCKET_0][1] != 0x04)||(listen_flag != CH395_ERR_MEM))
|
||||||
|
{
|
||||||
|
listen_flag = ch395_tcp_listen(CH395Q_SOCKET_0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (g_ch395q_sta.phy_status != PHY_DISCONN && g_ch395q_sta.socket[socket_index].config.socket_enable == CH395Q_DISABLE)
|
if (g_ch395q_sta.phy_status != PHY_DISCONN && g_ch395q_sta.socket[socket_index].config.socket_enable == CH395Q_DISABLE)
|
||||||
{
|
{
|
||||||
|
@ -690,7 +738,8 @@ uint16_t ch395_port = 8080;
|
||||||
/* 远程IP地址设置 */
|
/* 远程IP地址设置 */
|
||||||
//uint8_t ch395_des_ipaddr[4] = {192,168,1,111};
|
//uint8_t ch395_des_ipaddr[4] = {192,168,1,111};
|
||||||
static uint8_t socket0_send_buf[255];
|
static uint8_t socket0_send_buf[255];
|
||||||
static uint8_t socket0_recv_buf[255];
|
static uint8_t socket0_recv_buf[8][1024];
|
||||||
|
//static uint8_t socket0_recv_buf[1024];
|
||||||
ch395_socket cha95_sockct_sta[8];
|
ch395_socket cha95_sockct_sta[8];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -725,9 +774,27 @@ void ch395_init(void)
|
||||||
cha95_sockct_sta[0].proto = CH395Q_SOCKET_TCP_SERVER; /* 设置协议 */
|
cha95_sockct_sta[0].proto = CH395Q_SOCKET_TCP_SERVER; /* 设置协议 */
|
||||||
cha95_sockct_sta[0].send.buf = socket0_send_buf; /* 发送数据 */
|
cha95_sockct_sta[0].send.buf = socket0_send_buf; /* 发送数据 */
|
||||||
cha95_sockct_sta[0].send.size = sizeof(socket0_send_buf); /* 发送数据大小 */
|
cha95_sockct_sta[0].send.size = sizeof(socket0_send_buf); /* 发送数据大小 */
|
||||||
cha95_sockct_sta[0].recv.buf = socket0_recv_buf; /* 接收数据缓冲区 */
|
cha95_sockct_sta[0].recv.buf = socket0_recv_buf[0]; /* 接收数据缓冲区 */
|
||||||
cha95_sockct_sta[0].recv.size = sizeof(socket0_recv_buf); /* 接收数据大小 */
|
cha95_sockct_sta[0].recv.size = sizeof(socket0_recv_buf[0]); /* 接收数据大小 */
|
||||||
ch395q_socket_config(&cha95_sockct_sta[0]); /* 配置socket参数 */
|
ch395q_socket_config(&cha95_sockct_sta[0]);
|
||||||
|
|
||||||
|
#if MULTI_CONNECT_ENABLE
|
||||||
|
/* 配置socket参数 */
|
||||||
|
for (uint8_t i = 1; i <= 7; i++)
|
||||||
|
{
|
||||||
|
ch395_set_socket_prot_type(i, PROTO_TYPE_TCP);
|
||||||
|
ch395_set_socket_sourport(i, ch395_port);
|
||||||
|
cha95_sockct_sta[i].sour_port = ch395_port; /* 源端口 */
|
||||||
|
cha95_sockct_sta[i].proto = CH395Q_SOCKET_TCP_SERVER;
|
||||||
|
cha95_sockct_sta[i].socket_enable = CH395Q_ENABLE;
|
||||||
|
cha95_sockct_sta[i].socket_index = i;
|
||||||
|
cha95_sockct_sta[i].recv.buf = socket0_recv_buf[i];
|
||||||
|
cha95_sockct_sta[i].recv.size = sizeof(socket0_recv_buf[i]);
|
||||||
|
//ch395q_socket_config(&cha95_sockct_sta[i]);
|
||||||
|
memcpy(&g_ch395q_sta.socket[i].config, &cha95_sockct_sta[i], sizeof(ch395_socket));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
101
CH395Q/ch395.h
101
CH395Q/ch395.h
|
@ -10,98 +10,99 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
|
#define MULTI_CONNECT_ENABLE 1
|
||||||
|
|
||||||
/******************************************************************************************/
|
/******************************************************************************************/
|
||||||
/* 引脚 定义 */
|
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
#define CH395_SCS_GPIO_PORT GPIOB
|
#define CH395_SCS_GPIO_PORT GPIOB
|
||||||
#define CH395_SCS_GPIO_PIN GPIO_PIN_12
|
#define CH395_SCS_GPIO_PIN GPIO_PIN_12
|
||||||
#define CH395_SCS_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOC_CLK_ENABLE(); }while(0) /* PB口时钟使能 */
|
#define CH395_SCS_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOC_CLK_ENABLE(); }while(0) /* PB<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
#define CH395_INT_GPIO_PORT GPIOD
|
#define CH395_INT_GPIO_PORT GPIOD
|
||||||
#define CH395_INT_GPIO_PIN GPIO_PIN_8
|
#define CH395_INT_GPIO_PIN GPIO_PIN_8
|
||||||
#define CH395_INT_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOD_CLK_ENABLE(); }while(0) /* PB口时钟使能 */
|
#define CH395_INT_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOD_CLK_ENABLE(); }while(0) /* PB<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
#define CH395_RST_GPIO_PORT GPIOD
|
#define CH395_RST_GPIO_PORT GPIOD
|
||||||
#define CH395_RST_GPIO_PIN GPIO_PIN_9
|
#define CH395_RST_GPIO_PIN GPIO_PIN_9
|
||||||
#define CH395_RST_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOD_CLK_ENABLE(); }while(0) /* PB口时钟使能 */
|
#define CH395_RST_GPIO_CLK_ENABLE() do{ __HAL_RCC_GPIOD_CLK_ENABLE(); }while(0) /* PB<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
/******************************************************************************************/
|
/******************************************************************************************/
|
||||||
#define ch395_scs_low HAL_GPIO_WritePin(CH395_SCS_GPIO_PORT, CH395_SCS_GPIO_PIN, GPIO_PIN_RESET) /* SPI片选引脚输出低电平 */
|
#define ch395_scs_low HAL_GPIO_WritePin(CH395_SCS_GPIO_PORT, CH395_SCS_GPIO_PIN, GPIO_PIN_RESET) /* SPIƬѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ƽ */
|
||||||
#define ch395_scs_hign HAL_GPIO_WritePin(CH395_SCS_GPIO_PORT, CH395_SCS_GPIO_PIN, GPIO_PIN_SET) /* SPI片选引脚输出高电平 */
|
#define ch395_scs_hign HAL_GPIO_WritePin(CH395_SCS_GPIO_PORT, CH395_SCS_GPIO_PIN, GPIO_PIN_SET) /* SPIƬѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ */
|
||||||
#define ch395_sdo_pin HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14) /* 获取CH395的SPI数据输出引脚电平 */
|
#define ch395_sdo_pin HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14) /* <EFBFBD><EFBFBD>ȡCH395<EFBFBD><EFBFBD>SPI<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>ƽ */
|
||||||
#define ch395_int_pin_wire HAL_GPIO_ReadPin(CH395_INT_GPIO_PORT,CH395_INT_GPIO_PIN) /* 假定CH395的INT#引脚,如果未连接那么也可以通过查询兼做中断输出的SDO引脚状态实现 */
|
#define ch395_int_pin_wire HAL_GPIO_ReadPin(CH395_INT_GPIO_PORT,CH395_INT_GPIO_PIN) /* <EFBFBD>ٶ<EFBFBD>CH395<EFBFBD><EFBFBD>INT#<23><><EFBFBD><EFBFBD>,<2C><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ôҲ<C3B4><D2B2><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SDO<44><4F><EFBFBD><EFBFBD>״̬ʵ<CCAC><CAB5> */
|
||||||
|
|
||||||
|
|
||||||
typedef struct ch395q_socket_t
|
typedef struct ch395q_socket_t
|
||||||
{
|
{
|
||||||
uint8_t socket_enable; /* Socket使能 */
|
uint8_t socket_enable; /* Socketʹ<EFBFBD><EFBFBD> */
|
||||||
uint8_t socket_index; /* Socket标号 */
|
uint8_t socket_index; /* Socket<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
uint8_t proto; /* Socket协议 */
|
uint8_t proto; /* SocketЭ<EFBFBD><EFBFBD> */
|
||||||
uint8_t des_ip[4]; /* 目的IP地址 */
|
uint8_t des_ip[4]; /* Ŀ<EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>ַ */
|
||||||
uint16_t des_port; /* 目的端口 */
|
uint16_t des_port; /* Ŀ<EFBFBD>Ķ˿<EFBFBD> */
|
||||||
uint16_t sour_port; /* 源端口 */
|
uint16_t sour_port; /* Դ<EFBFBD>˿<EFBFBD> */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t *buf; /* 缓冲空间 */
|
uint8_t *buf; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD> */
|
||||||
uint32_t size; /* 缓冲空间大小 */
|
uint32_t size; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD>С */
|
||||||
} send; /* 发送缓冲 */
|
} send; /* <EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t recv_flag; /* 接收数据标志位 */
|
uint8_t recv_flag; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD>־λ */
|
||||||
uint8_t *buf; /* 缓冲空间 */
|
uint8_t *buf; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD> */
|
||||||
uint32_t size; /* 缓冲空间大小 */
|
uint32_t size; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD>С */
|
||||||
} recv; /* 接收缓冲 */ /* 接收缓冲 */
|
} recv; /* <EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD> */ /* <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD> */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t ip[4]; /* IP地址 */
|
uint8_t ip[4]; /* IP<EFBFBD><EFBFBD>ַ */
|
||||||
uint8_t gwip[4]; /* 网关IP地址 */
|
uint8_t gwip[4]; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>ַ */
|
||||||
uint8_t mask[4]; /* 子网掩码 */
|
uint8_t mask[4]; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
uint8_t dns1[4]; /* DNS服务器1地址 */
|
uint8_t dns1[4]; /* DNS<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ַ */
|
||||||
uint8_t dns2[4]; /* DNS服务器2地址 */
|
uint8_t dns2[4]; /* DNS<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ַ */
|
||||||
} net_info; /* 网络信息 */
|
} net_info; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t ipaddr[4]; /* IP地址 32bit*/
|
uint8_t ipaddr[4]; /* IP<EFBFBD><EFBFBD>ַ 32bit*/
|
||||||
uint8_t gwipaddr[4]; /* 网关地址 32bit*/
|
uint8_t gwipaddr[4]; /* <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ַ 32bit*/
|
||||||
uint8_t maskaddr[4]; /* 子网掩码 32bit*/
|
uint8_t maskaddr[4]; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 32bit*/
|
||||||
uint8_t macaddr[6]; /* MAC地址 48bit*/
|
uint8_t macaddr[6]; /* MAC<EFBFBD><EFBFBD>ַ 48bit*/
|
||||||
} net_config; /* 网络配置信息 */
|
} net_config; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ */
|
||||||
|
|
||||||
} ch395_socket;
|
} ch395_socket;
|
||||||
|
|
||||||
/* DHCP״̬ */
|
/* DHCP״̬ */
|
||||||
enum DHCP
|
enum DHCP
|
||||||
{
|
{
|
||||||
DHCP_UP = 0, /* DHCP获取成功状态 */
|
DHCP_UP = 0, /* DHCP<EFBFBD><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD>״̬ */
|
||||||
DHCP_DOWN, /* DHCP获取失败状态 */
|
DHCP_DOWN, /* DHCP<EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>״̬ */
|
||||||
DHCP_STA, /* DHCP开启状态 */
|
DHCP_STA, /* DHCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ch395q_t
|
struct ch395q_t
|
||||||
{
|
{
|
||||||
uint8_t version; /* 版本信息 */
|
uint8_t version; /* <EFBFBD>汾<EFBFBD><EFBFBD>Ϣ */
|
||||||
uint8_t phy_status; /* PHY״̬ */
|
uint8_t phy_status; /* PHY״̬ */
|
||||||
uint8_t dhcp_status; /* DHCP״̬ */
|
uint8_t dhcp_status; /* DHCP״̬ */
|
||||||
uint8_t ipinf_buf[20]; /* 获取IP信息 */
|
uint8_t ipinf_buf[20]; /* <EFBFBD><EFBFBD>ȡIP<EFBFBD><EFBFBD>Ϣ */
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
ch395_socket config; /* 配置信息 */
|
ch395_socket config; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ */
|
||||||
} socket[8]; /* Socket״̬ */
|
} socket[8]; /* Socket״̬ */
|
||||||
|
|
||||||
void (*ch395_error)(uint8_t i); /* ch395q错误检测函数 */
|
void (*ch395_error)(uint8_t i); /* ch395q<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⺯<EFBFBD><EFBFBD> */
|
||||||
void (*ch395_phy_cb)(uint8_t phy_status); /* ch395q phy状态回调函数 */
|
void (*ch395_phy_cb)(uint8_t phy_status); /* ch395q phy״̬<EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
void (*ch395_reconnection)(void); /* ch395q 重新连接函数 */
|
void (*ch395_reconnection)(void); /* ch395q <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ch395q_t g_ch395q_sta;
|
extern struct ch395q_t g_ch395q_sta;
|
||||||
|
|
||||||
/* CH395Q模块Socket标号定义 */
|
/* CH395Qģ<EFBFBD><EFBFBD>Socket<EFBFBD><EFBFBD>Ŷ<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
#define CH395Q_SOCKET_0 0 /* Socket 0 */
|
#define CH395Q_SOCKET_0 0 /* Socket 0 */
|
||||||
#define CH395Q_SOCKET_1 1 /* Socket 1 */
|
#define CH395Q_SOCKET_1 1 /* Socket 1 */
|
||||||
#define CH395Q_SOCKET_2 2 /* Socket 2 */
|
#define CH395Q_SOCKET_2 2 /* Socket 2 */
|
||||||
|
@ -111,18 +112,18 @@ extern struct ch395q_t g_ch395q_sta;
|
||||||
#define CH395Q_SOCKET_6 6 /* Socket 6 */
|
#define CH395Q_SOCKET_6 6 /* Socket 6 */
|
||||||
#define CH395Q_SOCKET_7 7 /* Socket 7 */
|
#define CH395Q_SOCKET_7 7 /* Socket 7 */
|
||||||
|
|
||||||
/* 使能定义 */
|
/* ʹ<EFBFBD>ܶ<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
#define CH395Q_DISABLE 1 /* 禁用 */
|
#define CH395Q_DISABLE 1 /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
#define CH395Q_ENABLE 2 /* 使能 */
|
#define CH395Q_ENABLE 2 /* ʹ<EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
/* CH395Q模块Socket协议类型定义 */
|
/* CH395Qģ<EFBFBD><EFBFBD>SocketЭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
#define CH395Q_SOCKET_UDP 0 /* UDP */
|
#define CH395Q_SOCKET_UDP 0 /* UDP */
|
||||||
#define CH395Q_SOCKET_TCP_CLIENT 1 /* TCP客户端 */
|
#define CH395Q_SOCKET_TCP_CLIENT 1 /* TCP<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD> */
|
||||||
#define CH395Q_SOCKET_TCP_SERVER 2 /* TCP服务器 */
|
#define CH395Q_SOCKET_TCP_SERVER 2 /* TCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
#define CH395Q_SOCKET_MAC_RAW 3 /* MAC_RAW */
|
#define CH395Q_SOCKET_MAC_RAW 3 /* MAC_RAW */
|
||||||
|
|
||||||
#define DEF_KEEP_LIVE_IDLE (15*1000) /* 空闲时间 */
|
#define DEF_KEEP_LIVE_IDLE (15*1000) /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD> */
|
||||||
#define DEF_KEEP_LIVE_PERIOD (15*1000) /* 间隔为15秒,发送一次KEEPLIVE数据包 */
|
#define DEF_KEEP_LIVE_PERIOD (15*1000) /* <EFBFBD><EFBFBD><EFBFBD>Ϊ15<EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>KEEPLIVE<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD> */
|
||||||
#define DEF_KEEP_LIVE_CNT 200
|
#define DEF_KEEP_LIVE_CNT 200
|
||||||
|
|
||||||
uint8_t ch395_read_data(void ) ;
|
uint8_t ch395_read_data(void ) ;
|
||||||
|
|
|
@ -545,7 +545,8 @@ uint8_t ch395_open_socket(uint8_t sockindex)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
HAL_Delay(5); /* 延时查询,建议2MS以上 */
|
delay_us(3000);
|
||||||
|
//HAL_Delay(5); /* 延时查询,建议2MS以上 */
|
||||||
s = ch395_get_cmd_status(); /* 不能过于频繁查询 */
|
s = ch395_get_cmd_status(); /* 不能过于频繁查询 */
|
||||||
|
|
||||||
if (s != CH395_ERR_BUSY)
|
if (s != CH395_ERR_BUSY)
|
||||||
|
@ -577,7 +578,8 @@ uint8_t ch395_close_socket(uint8_t sockindex)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
HAL_Delay(5); /* 延时查询,建议2MS以上 */
|
delay_us(3000);
|
||||||
|
//HAL_Delay(5); /* 延时查询,建议2MS以上 */
|
||||||
s = ch395_get_cmd_status(); /* 不能过于频繁查询 */
|
s = ch395_get_cmd_status(); /* 不能过于频繁查询 */
|
||||||
|
|
||||||
if (s != CH395_ERR_BUSY)
|
if (s != CH395_ERR_BUSY)
|
||||||
|
@ -641,7 +643,8 @@ uint8_t ch395_tcp_listen(uint8_t sockindex)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
HAL_Delay(5); /* 延时查询,建议2MS以上 */
|
delay_us(3000);
|
||||||
|
//HAL_Delay(5); /* 延时查询,建议2MS以上 */
|
||||||
s = ch395_get_cmd_status(); /* 不能过于频繁查询 */
|
s = ch395_get_cmd_status(); /* 不能过于频繁查询 */
|
||||||
|
|
||||||
if (s != CH395_ERR_BUSY)
|
if (s != CH395_ERR_BUSY)
|
||||||
|
|
272854
MDK-ARM/JLinkLog.txt
272854
MDK-ARM/JLinkLog.txt
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -230,6 +230,36 @@
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>rec_test_flag</ItemText>
|
<ItemText>rec_test_flag</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>16</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>open_flag</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>17</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>listen_flag</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>18</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>tcp_breath_cnt</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>19</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>g_ch395q_sta,0x0A</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>20</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>connect_cnt</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>21</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>sock_int_socket</ItemText>
|
||||||
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
|
|
Binary file not shown.
|
@ -1,9 +1,9 @@
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<pre>
|
<pre>
|
||||||
<h1><EFBFBD>Vision Build Log</h1>
|
<h1>µVision Build Log</h1>
|
||||||
<h2>Tool Versions:</h2>
|
<h2>Tool Versions:</h2>
|
||||||
IDE-Version: <EFBFBD><EFBFBD>Vision V5.39.0.0
|
IDE-Version: ¦ÌVision V5.39.0.0
|
||||||
Copyright (C) 2023 ARM Ltd and ARM Germany GmbH. All rights reserved.
|
Copyright (C) 2023 ARM Ltd and ARM Germany GmbH. All rights reserved.
|
||||||
License Information: 1111 admin, 111, LIC=CZLZX-HG49K-CXUU6-DWQ8R-YUSX2-8I4LW
|
License Information: 1111 admin, 111, LIC=CZLZX-HG49K-CXUU6-DWQ8R-YUSX2-8I4LW
|
||||||
|
|
||||||
|
@ -27,9 +27,39 @@ Project File Date: 04/09/2025
|
||||||
<h2>Output:</h2>
|
<h2>Output:</h2>
|
||||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Users\admin\Desktop\wujunchao\99_General softwares\Keil_v5\ARM\ARM Compiler_5_06\Bin'
|
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Users\admin\Desktop\wujunchao\99_General softwares\Keil_v5\ARM\ARM Compiler_5_06\Bin'
|
||||||
Build target 'VOQC'
|
Build target 'VOQC'
|
||||||
|
compiling main.c...
|
||||||
|
compiling gpio.c...
|
||||||
|
compiling adc.c...
|
||||||
|
compiling dma.c...
|
||||||
|
compiling i2c.c...
|
||||||
|
compiling spi.c...
|
||||||
|
compiling tim.c...
|
||||||
|
compiling usart.c...
|
||||||
|
compiling stm32f4xx_it.c...
|
||||||
|
compiling stm32f4xx_hal_msp.c...
|
||||||
|
compiling ads1256.c...
|
||||||
|
compiling ads1220.c...
|
||||||
|
compiling dac7311.c...
|
||||||
|
compiling eeprom.c...
|
||||||
|
compiling ms5803.c...
|
||||||
|
compiling ds18b20.c...
|
||||||
|
compiling hc595.c...
|
||||||
|
compiling hc165.c...
|
||||||
|
compiling mf5803.c...
|
||||||
|
compiling ch395.c...
|
||||||
|
compiling ch395cmd.c...
|
||||||
|
compiling modbus.c...
|
||||||
|
compiling modbus_rtu.c...
|
||||||
|
compiling modbus_tcp.c...
|
||||||
|
compiling adcs.c...
|
||||||
compiling gpios.c...
|
compiling gpios.c...
|
||||||
|
compiling timer.c...
|
||||||
|
compiling uarts.c...
|
||||||
|
compiling provalctrl.c...
|
||||||
|
compiling encoder.c...
|
||||||
|
compiling flash.c...
|
||||||
linking...
|
linking...
|
||||||
Program Size: Code=41082 RO-data=514 RW-data=548 ZI-data=8564
|
Program Size: Code=41998 RO-data=514 RW-data=568 ZI-data=16496
|
||||||
FromELF: creating hex file...
|
FromELF: creating hex file...
|
||||||
"VOQC\VOQC.axf" - 0 Error(s), 0 Warning(s).
|
"VOQC\VOQC.axf" - 0 Error(s), 0 Warning(s).
|
||||||
|
|
||||||
|
@ -54,7 +84,7 @@ Package Vendor: Keil
|
||||||
<h2>Collection of Component Files used:</h2>
|
<h2>Collection of Component Files used:</h2>
|
||||||
|
|
||||||
* Component: ARM::CMSIS:CORE@5.6.0
|
* Component: ARM::CMSIS:CORE@5.6.0
|
||||||
Build Time Elapsed: 00:00:10
|
Build Time Elapsed: 00:01:57
|
||||||
</pre>
|
</pre>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -234,14 +234,14 @@ void mf5803_loop()
|
||||||
{
|
{
|
||||||
SENSOR_SELECT(1);
|
SENSOR_SELECT(1);
|
||||||
|
|
||||||
for( uint8_t i = 3; i < 6; i++ ) //均值滤波
|
for( uint8_t i = 0; i < 6; i++ ) //均值滤波
|
||||||
{
|
{
|
||||||
sums = 0;
|
sums = 0;
|
||||||
for( uint8_t j = 0; j < FLT_SIZE; j++ )
|
for( uint8_t j = 0; j < FLT_SIZE; j++ )
|
||||||
{
|
{
|
||||||
sums += p_flt_window[i][j];
|
sums += p_flt_window[i][j];
|
||||||
}
|
}
|
||||||
InputReg[ 2 + i ] = sums/FLT_SIZE; //InputReg[13]~InputReg[18]
|
InputReg[ 13 + i ] = sums/FLT_SIZE; //InputReg[13]~InputReg[18]
|
||||||
|
|
||||||
temp_5803 = p1[3];
|
temp_5803 = p1[3];
|
||||||
temp_5803 = temp_5803 << 8;
|
temp_5803 = temp_5803 << 8;
|
||||||
|
@ -254,16 +254,11 @@ void mf5803_loop()
|
||||||
{
|
{
|
||||||
temp_5803 = (temp_5803 - 308) / 256.0;
|
temp_5803 = (temp_5803 - 308) / 256.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (-50 <= temp_5803)&&(temp_5803 <= 100) )
|
|
||||||
{
|
|
||||||
InputReg[i + 13] = temp_5803*100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(NSS_Select > 6) //记录完6路气压后进入此处,每6*10ms
|
if(NSS_Select > 6) //记录完6路气压后进入此处,每6*10ms
|
||||||
{
|
{
|
||||||
NSS_Select = 4;
|
NSS_Select = 1;
|
||||||
|
|
||||||
flt_cnt++;
|
flt_cnt++;
|
||||||
if(flt_cnt > (FLT_SIZE - 1) ) //滑动窗口长度FLT_SIZE,循环记录
|
if(flt_cnt > (FLT_SIZE - 1) ) //滑动窗口长度FLT_SIZE,循环记录
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "uarts.h"
|
#include "uarts.h"
|
||||||
#include "ch395.h"
|
#include "ch395.h"
|
||||||
|
|
||||||
|
extern uint8_t multi_connect_socket_index;
|
||||||
|
|
||||||
/*--------------------------------- 宏定义 -----------------------------------*/
|
/*--------------------------------- 宏定义 -----------------------------------*/
|
||||||
//功能码
|
//功能码
|
||||||
#define ReadCoilState 0x01 //读取线圈状态
|
#define ReadCoilState 0x01 //读取线圈状态
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue