diff --git a/keilp/cc_as_stc02_ps5ws.uvprojx b/keilp/cc_as_stc02_ps5ws.uvprojx
index 57f3e1d..3d0d2ce 100644
--- a/keilp/cc_as_stc02_ps5ws.uvprojx
+++ b/keilp/cc_as_stc02_ps5ws.uvprojx
@@ -10,6 +10,7 @@
STC8F2K16S2
0x0
MCS-51
+ 0
AT80C31X2
@@ -176,12 +177,14 @@
0
0
0
+ 0
0
0
0
0
0
0
+ 0
0
0
0
@@ -251,6 +254,16 @@
0x0
0x0
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
@@ -327,16 +340,6 @@
1
..\source\app\main.c
-
- task_adc.c
- 1
- ..\source\app\task_adc.c
-
-
- task_debug.c
- 1
- ..\source\app\task_debug.c
-
task_register.c
1
@@ -353,19 +356,34 @@
..\source\app\app_config.c
- task_encrypt.c
+ task_w600.c
1
- ..\source\app\task_encrypt.c
+ ..\source\app\task_w600.c
- cpu
+ bsp
- STARTUP.A51
- 2
- ..\source\cpu\STARTUP.A51
+ bsp_config.c
+ 1
+ ..\source\bsp\bsp_config.c
+
+
+ chipid.c
+ 1
+ ..\source\bsp\chipid.c
+
+
+ rs485.c
+ 1
+ ..\source\bsp\rs485.c
+
+
+ w600.c
+ 1
+ ..\source\bsp\w600.c
@@ -377,11 +395,6 @@
1
..\source\msp\time.c
-
- UART0.C
- 1
- ..\source\msp\UART0.C
-
eeprom.c
1
@@ -393,34 +406,24 @@
..\source\msp\uart_x.c
- UART2.C
+ uart0.c
1
- ..\source\msp\UART2.C
+ ..\source\msp\uart0.c
+
+
+ uart2.c
+ 1
+ ..\source\msp\uart2.c
- bsp
+ cpu
- bsp_config.c
- 1
- ..\source\bsp\bsp_config.c
-
-
- chipid.c
- 1
- ..\source\bsp\chipid.c
-
-
- cs1232.c
- 1
- ..\source\bsp\cs1232.c
-
-
- rs485.c
- 1
- ..\source\bsp\rs485.c
+ STARTUP.A51
+ 2
+ ..\source\cpu\STARTUP.A51
@@ -452,6 +455,11 @@
1
..\source\tpc\ccmodbus.c
+
+ at0d0a.c
+ 1
+ ..\source\tpc\at0d0a.c
+
diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xc b/si4/ps5ws.si4project/soft_ps5ws.sip_xc
index 84739e8..40b5d68 100644
Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xc and b/si4/ps5ws.si4project/soft_ps5ws.sip_xc differ
diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xf b/si4/ps5ws.si4project/soft_ps5ws.sip_xf
index b99922a..4edd684 100644
Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xf and b/si4/ps5ws.si4project/soft_ps5ws.sip_xf differ
diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xm b/si4/ps5ws.si4project/soft_ps5ws.sip_xm
index 552e261..e66a576 100644
Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xm and b/si4/ps5ws.si4project/soft_ps5ws.sip_xm differ
diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xr b/si4/ps5ws.si4project/soft_ps5ws.sip_xr
index 94f09a5..c56b8be 100644
Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xr and b/si4/ps5ws.si4project/soft_ps5ws.sip_xr differ
diff --git a/si4/ps5ws.si4project/soft_ps5ws.siproj b/si4/ps5ws.si4project/soft_ps5ws.siproj
index 68ed112..0f459ad 100644
Binary files a/si4/ps5ws.si4project/soft_ps5ws.siproj and b/si4/ps5ws.si4project/soft_ps5ws.siproj differ
diff --git a/source/app/app_config.c b/source/app/app_config.c
index 7b12a8d..8f495a9 100644
--- a/source/app/app_config.c
+++ b/source/app/app_config.c
@@ -9,18 +9,18 @@ GlobalRegister R;
void L3_param_init(void)
{
- //station模式状态
- G.st_status = 0; //0:none 1:wifi_ok 2:tcp_connect_ok
+ //station模式状态
+ G.st_status = 0; //0:none 1:wifi_ok 2:tcp_connect_ok
//station模式sid
- Lc_strcpy(G.st_sid,"ccsens");
+ Lc_strcpy(G.st_sid,"ccsens");
//station模式pwd
- Lc_strcpy(G.st_pwd,"ccsens123");
+ Lc_strcpy(G.st_pwd,"ccsens123");
//ap模式状态
- G.ap_status = 0;//0: none 1: ap_ok 2:tcp_server_ok
+ G.ap_status = 0;//0: none 1: ap_ok 2:tcp_server_ok
//ap模式sid
- Lc_strcpy(G.ap_sid,"cc_pen_ap");
+ Lc_strcpy(G.ap_sid,"cc_pen_ap");
//ap模式pwd
- Lc_strcpy(G.ap_pwd,"ccsens123");
+ Lc_strcpy(G.ap_pwd,"ccsens123");
}
diff --git a/source/app/app_config.h b/source/app/app_config.h
index 02af46d..40d18ef 100644
--- a/source/app/app_config.h
+++ b/source/app/app_config.h
@@ -70,8 +70,10 @@ extern GlobalRegister R;
//STEP 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Global Variables CONFIG
typedef struct global_param
{
- //station模式状态
- U8 st_status; //0:none 1:wifi_ok 2:tcp_connect_ok
+ //调试模式
+ U8 debug;
+ //station模式状态
+ U8 st_status; //0:none 1:wifi_ok 2:tcp_connect_ok
//station模式sid
U8 st_sid[32];
//station模式pwd
diff --git a/source/app/main.c b/source/app/main.c
index 1ec6f84..d6266af 100644
--- a/source/app/main.c
+++ b/source/app/main.c
@@ -60,18 +60,6 @@ stc5ac32s
驱动: cam 参数设置及中断
-
-
-
-
-
-
-
-
-
-
-
-
************************************************/
//===============================================
//寄存器头文件
@@ -82,28 +70,35 @@ stc5ac32s
void L0_main_init(void)
{
Lc_delay_ms(200);
- L0_board_config();
- L0_uart0_buf_init();//串口初始化
- L0_uart2_buf_init();//串口初始化
- //L0_uart3_buf_init();//串口初始化
- EA = 1;
+ //板卡初始化
+ L0_board_config();
+ //串口0初始化
+ L0_uart0_buf_init();
+ //串口2初始化
+ L0_uart2_buf_init();
+ //串口3初始化
+ //L0_uart3_buf_init();
//Lc_delay_ms(100);
L1_tick_init();
+
+ //开启全局中断
+ EA = 1;
+
+ //系统时钟初始化
L0_timer0_Init();
+
+ //G初始化
L3_param_init();
+ //R初始化
L3_reg_init();
+ //485初始化
L2_485_init();
-
- L0_ADS1213_INIT();
-
-// L3_task_adc_init(0);
-// L3_task_adc_init(1);
-// L3_task_adc_init(2);
-// L3_task_adc_init(3);
- L3_task_debug_init();
- L3_task_show_init();
+
+ //寄存器监听任务初始化
L3_task_reglisten_init();
- L0_uart0_sendArray("v2.7",4);
+
+ //w600任务初始化
+ L3_task_gm35_flow_init(W600_ST);
}
//===============================================
@@ -113,42 +108,24 @@ void main(void)
{
//初始化
L0_main_init();
- //验证加密信息
- //L3_encrypt_handler();
- //主循环
- //L0_timer1_restart();
+
+ //打印版本信息
+ L0_uart0_sendArray("v1.0",4);
+
while(1)
{
if(1 == s_nos_tick.t1s_heatbeart)
{
s_nos_tick.t1s_heatbeart = 0;
- //LED0 ^= 1;
-
+ //LED0 ^= 1;
}
-
-
-
-
- //L1_ADS1213_main();
-
- //单路采集滤波
- //L3_task_adc_handler(0);
- //L3_task_adc_handler(1);
- //L3_task_adc_handler(2);
- //L3_task_adc_handler(3);
-
- //显示
- //L3_task_adc_filter_show(&ts_adc_blur_show);
-
+ L2_task_gm35_flow_handle(&s_task_gm35_flow);
//寄存器值监控
//L3_task_reglisten_handle(&s_task_reglisten);
//输出,响应485协议
- L3_task_modbus_handler(&s_uart0_rec);
- L3_task_modbus_handler2(&s_uart2_rec);
-
- //调试输出
- //L3_task_debug(&_s_task_debug);
+ //L3_task_modbus_handler(&s_uart0_rec);
+ //L3_task_modbus_handler2(&s_uart2_rec);
}
}
//end main
diff --git a/source/app/main.h b/source/app/main.h
index d73f749..05cba94 100644
--- a/source/app/main.h
+++ b/source/app/main.h
@@ -53,8 +53,7 @@
#include "../app/task_debug.h"
#include "../app/task_register.h"
#include "../app/task_encrypt.h"
-
-
+#include "../app/task_w600.h"
//////////////////////////////////////////////////////////////////
diff --git a/source/app/task_modbus.c b/source/app/task_modbus.c
index 69f2d28..da89416 100644
--- a/source/app/task_modbus.c
+++ b/source/app/task_modbus.c
@@ -205,13 +205,13 @@ void L3_task_modbus_handler(TP_Handler_X *ph4)
}
void L3_task_modbus_handler2(TP_Handler_X *ph4)
{
- if(s_uart2_rec.ok)
- {
- TS_PH4_modbus *ts_modbus = (TS_PH4_modbus *)ph4->buf;
- //LED0 ^= 1;
- s_uart2_rec.ok=0;
- L0_uart0_sendArray(s_uart2_rec.buf, s_uart2_rec.num);
- }
+ if(s_uart2_rec.ok)
+ {
+ TS_PH4_modbus *ts_modbus = (TS_PH4_modbus *)ph4->buf;
+ //LED0 ^= 1;
+ s_uart2_rec.ok=0;
+ L0_uart0_sendArray(s_uart2_rec.buf, s_uart2_rec.num);
+ }
if(s_uart2_rec.yes)
{
s_uart2_rec.yes=0;
diff --git a/source/app/task_w600.c b/source/app/task_w600.c
new file mode 100644
index 0000000..2a91834
--- /dev/null
+++ b/source/app/task_w600.c
@@ -0,0 +1,273 @@
+////////////////////////////////////////////////////////////////////////////
+///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
+///-------------------------------------------------------------------------
+/// @file bsp_test.c.c
+/// @brief bsp @ driver config
+///-------------------------------------------------------------------------
+/// @version 1.0
+/// @author CC
+/// @date 20180331
+/// @note cc_AS_stc02
+//////////////////////////////////////////////////////////////////////////////
+
+#include "task_w600.h"
+
+#include "app_config.h"
+#include "../msp/uart0.h"
+#include "../msp/uart2.h"
+#include "../tpc/at0d0a.h"
+
+struct _s_task_gm35_gprs_ s_task_gm35_flow;
+
+#define LEN_GPRS_TCP_PKG 18
+
+U8 ins_cipsend[30] = "AT+CIPSEND=000\r\n";
+
+U8 * _cipsend_hex(U8 len)
+{
+ U8 pos = Lc_strlen("AT+CIPSEND=");
+ ins_cipsend[pos++] = len % 1000 / 100 + '0';
+ ins_cipsend[pos++] = len % 100 / 10 + '0';
+ ins_cipsend[pos++] = len % 10 / 1 + '0';
+
+ return ins_cipsend;
+}
+
+void L3_gm35_send_str(U8 *str)
+{
+ L0_uart2_sendstr(str);
+ if(G.debug)
+ {
+ L0_uart0_sendstr(str);
+ }
+}
+
+//将数据放入gm35待发送缓冲区
+void L3_gm35_send_data(U8 *buf , U8 len)
+{
+ L3_gm35_send_str(_cipsend_hex(len));
+ L0_uart2_sendArray(buf,len);
+ if(G.debug)
+ {
+ L0_uart0_sendArray(buf,len);
+ }
+}
+
+void L3_gm35_rcv_data(U8* buf,U8 num)
+{
+ if(G.debug)
+ {
+ L0_uart0_sendstr("ATRCV=");
+ L0_uart0_uchex(num);
+ L0_uart0_sendArray(buf,num);
+ }
+}
+
+
+void L3_uart2_exp_protocol(TS_Handle_0d0a *p)
+{
+ if (1 == p->ok )
+ {
+ U8 *pPara = p->buf + 1;
+ s_task_gm35_flow.gprs_last_recv_stmp = s_nos_tick.t_1s;
+ if(Lc_strStartsWith(pPara,"OK"))
+ {
+ s_task_gm35_flow.ins_ok = 1;
+ }
+
+ p->ok = 0;
+ }
+}
+
+
+//------------------------------------------------------ gm35 tasks --------------------------------
+void L3_task_gm35_flow_init(U8 mode)
+{
+ L1_task_init(&s_task_gm35_flow.task);
+ L3_task_s_go(s_task_gm35_flow,D_task_init);
+ s_task_gm35_flow.mode = mode;
+
+#if 0
+ g_at_send_status.send_lock = 0;
+ g_at_send_status.module_ok = 0;
+ g_at_send_status.sim_ok = 0;
+ g_at_send_status.net_ok = 0;
+ g_at_send_status.gprs_ok = 0;
+ g_at_send_status.conn_ok = 0;
+
+ g_at_send_status.ins_stmp = 0; //每次发送指令时设置
+
+ g_at_send_status.heart_stmp = 0; //连接成功时设置
+ g_at_send_status.data_stmp = 0;
+ g_at_send_status.sign_flag = 0;
+ g_at_send_status.ack_flag = 0;
+
+ g_at_send_status.gprs_last_recv_stmp = 0; //接收到指令时设置
+ g_at_send_status.tcp_last_recv_stmp = 0; //连接成功和接收到数据时设置
+ g_at_send_status.tcp_close_stmp = 0; //重新上电和检测到断开时设置
+ g_at_send_status.gm35_reboot_times = 0; //连接成功时清0
+#endif
+}
+
+
+//------------------------ GM35 Flow Handle -----------------------------------
+
+#define TTSS_TASK_GM35_FLOW_ATEQV 0x01
+#define TTSS_TASK_GM35_FLOW_ATEQV_WAIT 0x02
+#define TTSS_TASK_GM35_FLOW_ST 0x03
+#define TTSS_TASK_GM35_FLOW_ST_WAIT 0x04
+#define TTSS_TASK_GM35_FLOW_ST_WIFI 0x05
+#define TTSS_TASK_GM35_FLOW_ST_WIFI_WAIT 0x06
+#define TTSS_TASK_GM35_FLOW_ST_CIPMUX0 0x07
+#define TTSS_TASK_GM35_FLOW_ST_CIPMUX0_WAIT 0x08
+#define TTSS_TASK_GM35_FLOW_ST_TCP 0x09
+#define TTSS_TASK_GM35_FLOW_ST_TCP_WAIT 0x0A
+#define TTSS_TASK_GM35_FLOW_ST_CIPMODE1 0x0B
+#define TTSS_TASK_GM35_FLOW_ST_CIPMODE1_WAIT 0x0C
+#define TTSS_TASK_GM35_FLOW_ST_CIPSEND 0x0D
+#define TTSS_TASK_GM35_FLOW_ST_CIPSEND_WAIT 0x0E
+#define TTSS_TASK_GM35_FLOW_ST_DATA 0x0F
+
+#define TTSS_TASK_GM35_FLOW_AP 0x20
+#define TTSS_TASK_GM35_FLOW_AP_WAIT 0x21
+
+
+#define INS_TIMEOUT 2
+#define GM35_SEND_DATA_INTERVAL 300
+#define GM35_SEND_HEART_INTERVAL 60
+#define GM35_SEND_CIPSTATUS_INTERVAL 5
+
+void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s)
+{
+ TTSS_Task_init()
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV,D_Tdelay_10s);//上电等待10s
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ATEQV)
+ L3_gm35_send_str(AT_INS_ATE0);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV_WAIT,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ATEQV_WAIT)
+ if(1 == s->ins_ok)
+ {
+ if(s->mode == W600_ST)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST,0);
+ }
+ else if(s->mode == W600_AP)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_AP,0);
+ }
+ }
+ else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ATEQV,0);
+ }
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST)
+ L3_gm35_send_str(AT_INS_ST);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_WAIT,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_WAIT)
+ if(1 == s->ins_ok)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_WIFI,0);
+ }
+ else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST,0);
+ }
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_WIFI)
+ L3_gm35_send_str(AT_INS_ST_WIFI);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_WIFI_WAIT,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_WIFI_WAIT)
+ if(1 == s->ins_ok)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMUX0,0);
+ }
+ else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_WIFI,0);
+ }
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMUX0)
+ L3_gm35_send_str(AT_INS_ST_CIPMUX0);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMUX0_WAIT,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMUX0_WAIT)
+ if(1 == s->ins_ok)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_TCP,0);
+ }
+ else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMUX0,0);
+ }
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_TCP)
+ L3_gm35_send_str(AT_INS_ST_TCP);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_TCP_WAIT,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_TCP_WAIT)
+ if(1 == s->ins_ok)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE1,0);
+ }
+ else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_TCP,0);
+ }
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMODE1)
+ L3_gm35_send_str(AT_INS_ST_CIPMODE1);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE1_WAIT,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPMODE1_WAIT)
+ if(1 == s->ins_ok)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPSEND,0);
+ }
+ else if(s_nos_tick.t_1s - s->ins_stmp > INS_TIMEOUT)
+ {
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_CIPMODE1,0);
+ }
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_CIPSEND)
+ L3_gm35_send_str(AT_INS_ST_CIPSEND);
+ s->ins_ok = 0;
+ s->ins_stmp = s_nos_tick.t_1s;
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_DATA,D_Tdelay_300ms);
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_ST_DATA)
+ L0_uart0_uc('A');
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_DATA,D_Tdelay_5s);
+
+
+
+
+
+
+
+
+ TTSS_Task_step(TTSS_TASK_GM35_FLOW_AP)
+ L0_uart0_uc('C');
+ L0_uart2_sendstr("abcdefg");
+ L2_task_go_Tdelay(TTSS_TASK_GM35_FLOW_ST_WAIT,D_Tdelay_10s);
+
+ TTSS_Task_end();
+}
+
+
diff --git a/source/app/task_w600.h b/source/app/task_w600.h
new file mode 100644
index 0000000..5a0e593
--- /dev/null
+++ b/source/app/task_w600.h
@@ -0,0 +1,99 @@
+////////////////////////////////////////////////////////////////////////////
+///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
+///-------------------------------------------------------------------------
+/// @file bsp_gc6133.c.h
+/// @brief bsp @ driver config
+///-------------------------------------------------------------------------
+/// @version 1.0
+/// @author CC
+/// @date 20180331
+/// @note cc_AS_stc02
+
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef _app_task_w600_H
+#define _app_task_w600_H
+
+#include "../bsp/bsp_config.h"
+#include "../bsp/w600.h"
+#include "../ctask/task.h"
+
+////<<<<<<<<<<<<<<<<<<< GM35模块 AT操作指令 <<<<<<<<<<<<<<<<<<<<<<<<
+#define AT_INS_ATE0 "ATE0\r\n" //模块查询+关闭回显
+#define AT_INS_ST "AT+CWMODE=1\r\n" //进入station模式
+#define AT_INS_ST_WIFI "AT+CWJAP_DEF=\"ccsens\",\"ccsens123\"\r\n" //网络查询指令
+#define AT_INS_ST_CIPMUX0 "AT+CIPMUX=0\r\n" //GPRS操作指令
+#define AT_INS_ST_TCP "AT+CIPSTART=\"TCP\",\"192.168.0.79\",4001\r\n" //连接服务器
+#define AT_INS_ST_CIPMODE1 "AT+CIPMODE=1\r\n" //发送数据
+#define AT_INS_ST_CIPSEND "AT+CIPSEND\r\n" //主动关闭连接
+#define AT_INS_ST_CIPMODE0 "AT+CIPMODE=0\r\n" //查询连接状态
+
+////<<<<<<<<<<<<<<<<<<<_s_task_test_<<<<<<<<<<<<<<<<<<<<<<<<
+enum _s_w600_mode
+{
+ W600_ST,W600_AP
+};
+struct _s_task_gm35_gprs_
+{
+ TS_task task;
+
+ vU8 ins_ok;
+ vU8 mode;
+
+ vU8 send_lock;
+ vU8 module_ok;
+ vU8 sim_ok;
+ vU8 net_ok;
+ vU8 gprs_ok;
+ vU8 conn_ok;
+ vU8 status_query_ok;
+ vU32 ins_stmp; //指令时间戳
+ vU32 gprs_last_recv_stmp; //上次接收指令时间戳
+ vU32 tcp_last_recv_stmp; //上次接收数据时间戳
+ vU32 tcp_conn_stmp; //断开连接时间戳
+ vU32 tcp_close_stmp; //断开连接时间戳
+
+ vU32 heart_stmp; //连接成功后,等待发送时间
+ vU32 data_stmp;//数据发送时间记录
+
+ vU8 sign_flag; //发送登录数据标志
+ vU8 ack_flag;//下行数据ack
+ vU8 gm35_reboot_times; //gm35重启次数
+};
+
+#define STATUS_GM35_INIT 0
+#define STATUS_GM35_MODULE_OK 1
+#define STATUS_GM35_SIM_OK 2
+#define STATUS_GM35_NET_OK 3
+#define STATUS_GM35_GPRS_OK 4
+#define STATUS_GM35_TCP_OK 5
+#define BUF_SIZE 5
+#define BUF_MAX 32 //注意缓冲区的长度
+
+extern struct _s_task_gm35_gprs_ s_task_gm35_flow;
+
+extern void L3_task_gm35_flow_init(U8 mode);
+extern void L2_task_gm35_flow_handle(struct _s_task_gm35_gprs_ *s);
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/bsp/bsp_config.h b/source/bsp/bsp_config.h
index 36c2f38..84c4f84 100644
--- a/source/bsp/bsp_config.h
+++ b/source/bsp/bsp_config.h
@@ -51,7 +51,7 @@
//STEP 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD SELECT
-#define TYPE_UASER_BOARD TYPE_BOARD_WEIGH_0B
+#define TYPE_UASER_BOARD TYPE_BOARD_TOUCH_PEN_0B
//STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD CONFIG
-#if(TYPE_UASER_BOARD == TYPE_BOARD_WEIGH_0B)
+#if(TYPE_UASER_BOARD == TYPE_BOARD_TOUCH_PEN_0B)
#include
#include "../cpu/stc_stc8hxx.h"
#include "../cpu/stc_macro.h"
@@ -108,7 +108,7 @@
//外设定义
- #define LED1 P27 //D4
+ #define LED1 P27 //D4
#define LED2 P26 //D4
#define LED3 P2 //D4
#define LED4 P55 //D4
diff --git a/source/bsp/bsp_config_const.h b/source/bsp/bsp_config_const.h
index a84149b..7002a7e 100644
--- a/source/bsp/bsp_config_const.h
+++ b/source/bsp/bsp_config_const.h
@@ -65,6 +65,7 @@
#define TYPE_BOARD_ADDA_MAIN_V02 0xa8 //ADDA
#define TYPE_BOARD_433_0A 0xa9 //433
#define TYPE_BOARD_WEIGH_0B 0xaa //称重
+#define TYPE_BOARD_TOUCH_PEN_0B 0xab //点读笔
//<<<<<<<<<<<<<<<<<<<<<<<<<<<.BORAD TYPE end
//>>>>>>>>>>>>>>>>>>>>>>MCU TYPE
diff --git a/source/bsp/w600.c b/source/bsp/w600.c
index 5632d71..72a8056 100644
--- a/source/bsp/w600.c
+++ b/source/bsp/w600.c
@@ -1,5 +1,16 @@
#include "w600.h"
-void L1_w600_init(U8 mode)
+
+void L2_w600_init()
{
- s->mode = mode;
+ L2_w600_enable();
+}
+
+void L2_w600_enable()
+{
+ //W600_ENABLE();
+}
+
+void L2_w600_disable()
+{
+ //W600_DISABLE();
}
\ No newline at end of file
diff --git a/source/bsp/w600.h b/source/bsp/w600.h
index e6aa257..d471a68 100644
--- a/source/bsp/w600.h
+++ b/source/bsp/w600.h
@@ -1,2 +1,15 @@
-#ifndef __W600_H__
-#define __W600_H__
+#ifndef BSP_GM35_H
+#define BSP_GM35_H
+
+#include "bsp_config.h"
+
+#define W600_VBAT_EN P67
+#define W600_DISABLE() W600_VBAT_EN = 0
+#define W600_ENABLE() W600_VBAT_EN = 1
+
+
+extern void L2_w600_init();
+extern void L2_w600_enable();
+extern void L2_w600_disable();
+
+#endif
\ No newline at end of file
diff --git a/source/clib/clib.c b/source/clib/clib.c
index 805329f..2ddf72f 100644
--- a/source/clib/clib.c
+++ b/source/clib/clib.c
@@ -14,145 +14,27 @@
#include "clib.h"
#include "../msp/uart0.h"
#include "../msp/time.h"
-U8* Lc_strcpy(U8* dst,const char* str)
-{
- U8 *p = dst;
- while(*dst++ = *str++);
- return p;
-}
-
-#if 0
-
-vU16 us2fun2[5]
-={
-1, //0
-10,// 1
-100,// 2
-1000,// 3
-10000// 4
-
-};
-
-
-vU32 ul2fun2[10]
-={
-1, //0
-10,// 1
-100,// 2
-1000,// 3
-10000,// 4
-100000,
-1000000,
-10000000,
-100000000,
-1000000000,//9
-};
-
-同样是转义字符,\n 的作用相当于“Enter”键,而想退回去就可以用“Backspace”键,也就是\b
-这里还有一个可能用到的转义字符是\r :使光标回退到本行开头
- \b 退格
- \n 换行 0x0A
- \f 走纸
- \t 水平制表
- \v 垂直制表
-
-\r 0x0d
-//如果追求内存紧张加上const INT32U ul2fun2[10]
-
-
-void Lc_float2str(float f,U8 *str,U8 point_num);
+U8 Lc_strStartsWith(U8 *s1,U8 *s2)
{
- S32 i = 0; U32 u32i = 0;
- U8 n = 0;U8 m = 0;U8 d = 0;
- switch(point_num)
- {
- case 0:
-
- break;
- case 1:
- f *= 10.;
-
- break;
- case 2:
- f *= 100.;
-
- break;
- case 3:
- f *= 1000.;
-
- break;
- default:
-
- break;
- };
- i = (S32)f;
-// Lc_float2str(1.23,&d,2)
-// Lc_float2str(0.23,&d,2)
-// Lc_float2str(23.4,&d,1)
-// Lc_float2str(-12345.236,&d,2)
- // 1,1.2 12.3 240 0.12
- if(i < 0)
- {
- str[n] = '-';
- n ++;
- i *= -1;
- }
- u32i = (U32)i;
- m = 4;
- if(u32i >= ul2fun2[m]) u32i = ul2fun2[m] - 1;
- for(m = 0;m > 4;m ++)
- {// 43210
- d = (u32i /ul2fun2[m])%10;
- if (d > 0)
- str[n] = d;
- n ++;
- }
-
- if (n == point_num)
+ while(*s1 && *s2)
+ {
+ if(*s1++ != *s2++)
{
- str[n] ='.';
- n ++;
+ return 0;
}
-
-
- str[n] = i%10
-
-}
-
-void L0_Delay_ms(unsigned int time)
-{
- unsigned int j;
- for(;time > 0;time --)
- {
- j = D_l0_delay_ms;
- while(j--)
- ;
- }
+ }
+ return (*s2 == 0);
}
-//22m 50ms --delay ms 100 j=150
-void L1_delay_test(void)
-{
- while(9)
- {
- L0_Delay_ms(100);
- P2 = !P2;
- }
-
-}void Lc_delay_us(unsigned int n)
+U8* Lc_strcpy(U8* dst,const char* str)
{
-// unsigned char j;
- for(;n > 0;n --)
- {
- //j = 2;
- // while(j--)
- // ;
- }65 300
+ U8 *p = dst;
+ while(*dst++ = *str++);
+ return p;
}
-#endif
void Lc_delay_us(vU16 i)
{
@@ -174,8 +56,6 @@ void Lc_delay_nop(U8 i)
}
-
-
// D_1ms_delay_para
///22m 300
/// 22M 100ns 5个100ns 20ns
@@ -196,14 +76,12 @@ void Lc_delay_ms(vU16 i)
}
}
-void Lc_buf_copy_uc(U8 *d,const U8 *s,U16 num)
+void Lc_buf_copy_uc(U8 *dst,U8 *src,U8 len)
{
- U16 i;
- for(i = 0; i < num; i ++)
+ while(len--)
{
- *(d+i) = *(s+i);
+ *dst++ = *src++;
}
-
}
vU8 Lc_U8_media3(vU8 a,vU8 b,vU8 c)
diff --git a/source/clib/clib.h b/source/clib/clib.h
index 3809441..6ace03c 100644
--- a/source/clib/clib.h
+++ b/source/clib/clib.h
@@ -88,8 +88,6 @@ extern void Lc_print_buf(char *dat4,...);
extern void L3_us_big(U16 *d);
extern void L3_ui_big(vU32 *d);
-extern void Lc_buf_copy_uc(U8 *d,const U8 *s,U16 num);
-
///void L2_line_algo_media(U8 *buf,vU16 len);
extern vU8 Lc_U8_media3(vU8 a,vU8 b,vU8 c);
extern vS32 Lc_S32_media3(vS32 a,vS32 b,vS32 c);
@@ -112,7 +110,8 @@ extern int Lc_strlen(char *str);
extern U32 Lc_vU32_avg(U32 *d, U8 n);
extern U32 Lc_vS32_media(U32 *d, U8 n);
extern int Lc_memset(U8 *buf,U8 c,U16 len);
-
+extern void Lc_buf_copy_uc(U8 *dst,U8 *src,U8 len);
+extern U8 Lc_strStartsWith(U8 *s1,U8 *s2);
#endif /* end __UART_H */
diff --git a/source/msp/UART2.C b/source/msp/UART2.C
index ed62c36..eb52ca7 100644
--- a/source/msp/UART2.C
+++ b/source/msp/UART2.C
@@ -57,44 +57,30 @@ msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面
#include "uart2.h"
#include "../app/app_config.h"
#include "../msp/time.h"
+#include "../tpc/at0d0a.h"
//#define _USE_485
static volatile Ts_uart_send_buf idata ts_uart_send_shop;
TP_Handler_X s_uart2_rec;
TS_PH4_modbus s_uart2_ack;
+struct _s_PC1_0D0A_ s_uart2_at;
void L0_uart2_init(void)
{
-//#if(MainFre_11M == D_sys_MainFre) //115200bps@11.0592MHz
-// S2CON = 0x50; //8位数据,可变波特率
-// AUXR |= 0x04; //定时器2时钟为Fosc,即1T
-// T2L = 0xE8; //设定定时初值
-// T2H = 0xFF; //设定定时初值
-// AUXR |= 0x10; //启动定时器2
-//
-//#elif (MainFre_22M == D_sys_MainFre) //115200bps@22.1184MHz
-// S2CON = 0x50; //8位数据,可变波特率
-// AUXR |= 0x04; //定时器2时钟为Fosc,即1T
-// T2L = 0xE0; //设定定时初值
-// T2H = 0xFE; //设定定时初值
-// AUXR |= 0x10; //启动定时器2
-//#endif
-// S2CON = 0x50; //8位数据,可变波特率
-// AUXR |= 0x04; //定时器时钟1T模式
-// T2L = 0xE0; //设置定时初始值
-// T2H = 0xFE; //设置定时初始值
-// AUXR |= 0x10; //定时器2开始计时
S2CON = 0x50; //8位数据,可变波特率
AUXR &= 0xFB; //定时器时钟12T模式
T2L = 0xFC; //设置定时初始值
T2H = 0xFF; //设置定时初始值
AUXR |= 0x10; //定时器2开始计时
-
}
void L0_uart2_buf_init(void)
{
+ s_uart2_at.head = 0;
+ s_uart2_at.ok = 0;
+ s_uart2_at.num = 0;
+
ts_uart[uNum2].p = &ts_uart_send_shop;
ts_uart[uNum2].p->now = 0;
ts_uart[uNum2].p->ok = D_ready;
@@ -130,9 +116,10 @@ void INTERRUPT_uart2(void) D_SERVE_uart2// using 2
{
//LED0 ^= 1;
L0_uart2_IntRIClear(); //清除接收中断标志
- ts_uart[uNum2].t->reg = L0_uartN_get(uNum2);
+ //ts_uart[uNum2].t->reg = L0_uartN_get(uNum2);
//ts_uart[uNum2].tp_handler(ts_uart[uNum2].t);
- L1_s2b_PH4(ts_uart[uNum2].t);
+ s_uart2_at.reg = L0_uartN_get(uNum2);
+ L1_s2b_0d0a(&s_uart2_at);
L0_timer3_restart();
}
if(L0_uart2_IntTI()) //如果是U0发送中断
diff --git a/source/tpc/0d0a.c b/source/tpc/0d0a.c
deleted file mode 100644
index da7a66f..0000000
--- a/source/tpc/0d0a.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "0d0a.h"
-#include "../clib/clib.h"
-
-//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-//L1_uart_2strbuf(&s_uart0_rec);s_uart0_rec.ok = 2
-/// 接收以od oa为结束的标准的assci码的协议 类似 send xx (回车换行)测试时注意以回车换行
-/// 为结束标志,也就是发送的数据后面 必须有回车换行 :0x0d 0x0a
-
-
-//对于连续的多条协议,比如:abcdefg\r\n12345\r\n,如果前一条处理不及时,可能会被后一条覆盖
-void L1_s2b_0d0a(struct _tp_handler_x *p) //reentrant
-{
- if(p->head == 0)
- {
- p->head = 1;
- p->num = 0;
- }
-
- if(p->num >= D_tp_handle_x_len)
- {
- p->num = 0;
- }
- p->cashe[1] = p->cashe[0];
- p->cashe[0] = p->reg;//
-
- p->buf[++p->num] = p->cashe[0];
- //p->buf[++p->num] = p->cashe[0];
-
- if ((p->num > 2) && (p->cashe[0] == 0x0a) && (p->cashe[1] == 0x0d))// 0d0a
- {
- if(1 != p->ok)
- {
- p->buf[0] = p->num - 2; //去掉0d0a
- if(p->sp2 != NULL) //备份缓冲区不为null
- {
- //byte_copy_uc(p->buf + 1,p->__buf,p->num-2); //经过调试,此处不要调用外部函数,入栈出栈会增加出错风险
- for(p->i=0;p->ibuf[0]+1;p->i++)
- {
- p->sp2[p->i] = p->buf[p->i];
- }
- }
- p->ok = 1;//收到 命令结束,必须有个地方清0,否则无法再次接受报文
- }
- p->head = 0;
- }
-}
-
diff --git a/source/tpc/0d0a.h b/source/tpc/0d0a.h
deleted file mode 100644
index ddf5a39..0000000
--- a/source/tpc/0d0a.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef TPC_0D0A_H
-#define TPC_0D0A_H
-
-#include "tpc_x.h"
-
-///-----------------------------------------------------------------------------------------
-//#define D_s_SSTR_0D0A_len 64 //str类的协议需要长度大一些,容易bug的地方,限制为接收64bytes的数据
-#if 0
-#define FLAG_NONE 0
-#define FLAG_DISCARD 1
-#define FLAG_CCID 2
-#define FLAG_CIP 3
-typedef struct _s_PC1_0D0A_
-{//8byte
- vU8 reg;
- // vU8 sub_num; //接收到的数目注意数据长度的范围
- vU8 head; //接收标志头标志
-
- vU8 cashe[4];
- //vU8 filter1;
- //vU8 filter2;
- vU8 num; //接收到的数据的计数, 随着数据接收而变化注意数据长度的范围
-
- vU8 ok; //接收协议ok标志
- vU8 max; //接收到的数目的最大值
- vU8 __buf[D_s_SSTR_0D0A_len+1];//buffer
- vU8 buf[D_s_SSTR_0D0A_len+1];//array的第一位是 长度 //协议缓冲
- // U8 pro[16]; ///解析协议用
-}TS_Handle_0d0a;
-#endif
-extern void L1_s2b_0d0a(struct _tp_handler_x *p); //reentrant;
-
-#endif
diff --git a/source/tpc/at0d0a.c b/source/tpc/at0d0a.c
new file mode 100644
index 0000000..ce0d80e
--- /dev/null
+++ b/source/tpc/at0d0a.c
@@ -0,0 +1,37 @@
+#include "at0d0a.h"
+#include "../clib/clib.h"
+
+void L1_s2b_0d0a(struct _s_PC1_0D0A_ *p)// reentrant
+{
+ if(p->head == 0)
+ {
+ p->head = 1;
+ p->num = 0;
+ }
+
+ if(p->num >= D_s_SSTR_0D0A_len)//128
+ {
+ p->num = 0;
+ }
+ p->cashe[1] = p->cashe[0];
+ p->cashe[0] = p->reg;//
+
+ p->__buf[p->num++] = p->reg;
+
+ if ((p->cashe[0] == 0x0a) && (p->cashe[1] == 0x0d))// 0d0a
+ {
+ if((p->num > 2) && (p->__buf[p->num-3] != ':')) //排除掉 +CIPSTATUS(a9):
+ {
+ if(1 != p->ok)
+ {
+ p->buf[0] = p->num - 2; //去掉0d0a
+ Lc_buf_copy_uc(p->buf + 1,p->__buf,p->num-2);
+ p->ok = 1;//收到 命令结束,必须有个地方清0,否则无法再次接受报文
+ }
+ }
+ p->head = 0;
+ }
+}
+
+
+
diff --git a/source/tpc/at0d0a.h b/source/tpc/at0d0a.h
new file mode 100644
index 0000000..55bbcbf
--- /dev/null
+++ b/source/tpc/at0d0a.h
@@ -0,0 +1,23 @@
+#ifndef TPC_AT0D0A_H
+#define TPC_AT0D0A_H
+
+#include "tpc_x.h"
+
+///-----------------------------------------------------------------------------------------
+#define D_s_SSTR_0D0A_len 128 //str类的协议需要长度大一些,容易bug的地方,限制为接收64bytes的数据
+typedef struct _s_PC1_0D0A_
+{//8byte
+ vU8 reg;
+ vU8 head; //接收标志头标志
+ vU8 cashe[4];
+ vU8 num; //接收到的数据的计数, 随着数据接收而变化注意数据长度的范围
+ vU8 ok; //接收协议ok标志
+ vU8 max; //接收到的数目的最大值
+ vU8 __buf[D_s_SSTR_0D0A_len+1];//buffer
+ vU8 buf[D_s_SSTR_0D0A_len+1];//array的第一位是 长度 //协议缓冲
+ vU8 setflag; //读取串口过程中设置标志
+}TS_Handle_0d0a;
+extern void L1_s2b_0d0a(struct _s_PC1_0D0A_ *p);// reentrant;
+
+
+#endif