diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym index 00c68cd..6bffbb8 100644 Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_sym differ diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm index 61cd495..aa2bdf7 100644 Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm and b/si4/soft_gsm_main.si4project/soft_gsm_main.sip_xm differ diff --git a/si4/soft_gsm_main.si4project/soft_gsm_main.siwork b/si4/soft_gsm_main.si4project/soft_gsm_main.siwork index aa5eb16..7b1667e 100644 Binary files a/si4/soft_gsm_main.si4project/soft_gsm_main.siwork and b/si4/soft_gsm_main.si4project/soft_gsm_main.siwork differ diff --git a/source/app/app_common.c b/source/app/app_common.c index 63f02d1..6e83d53 100644 --- a/source/app/app_common.c +++ b/source/app/app_common.c @@ -63,6 +63,8 @@ void Lu_register_init() G.slaver_info[4].bytes = 2; G.slaver_info[4].buf = (U8*)&G.rfid; G.slaver_info[4].mask = 0; + + G.modbusstmp = 0; #if 0 for(i = 0; i < PAPER_BOX_NUM; i++) { diff --git a/source/app/app_common.h b/source/app/app_common.h index 6a08c67..943c5c9 100644 --- a/source/app/app_common.h +++ b/source/app/app_common.h @@ -162,11 +162,13 @@ typedef struct typedef struct printer_maintenance_global { U16 reserved; - U32 total_weight; + S32 total_weight; U16 rfid; MD_SLAVER_INFO slaver_info[MD_SLAVER_INFO_MAX]; + vU32 modbusstmp; + #if 1 TS_PaperCalib paperCalibs[PAPER_BOX_NUM]; U16 currentSensorVal[PAPER_BOX_NUM]; //当前纸张传感输出 diff --git a/source/app/app_task_485.c b/source/app/app_task_485.c index 85be23e..3669af2 100644 --- a/source/app/app_task_485.c +++ b/source/app/app_task_485.c @@ -47,11 +47,11 @@ void L3_task_485_handle(TS_485 *s) //L0_uart2_uc(s->pkglen); //Lc_delay_ms(70); L0_uart2_sendArray((U8*)&s->loopPkg,s->pkglen); - s->sendStamp = s_nos_tick.t_50ms; + s->sendStamp = s_nos_tick.t_5ms; L2_task_go(D_task_485_wait_modbus_ack); TTSS_Task_step(D_task_485_wait_modbus_ack) - if(s_nos_tick.t_50ms - s->sendStamp >= 2) + if(s_nos_tick.t_5ms - s->sendStamp >= 20) { if(s_uart2_rec.ok) { @@ -63,7 +63,8 @@ void L3_task_485_handle(TS_485 *s) if(s->pAckPkg->salver == G.slaver_info[0].slaver && s->pAckPkg->oper == MODBUS_OPER_READ) { G.total_weight = - s->pAckPkg->buf[1] >> 24 | s->pAckPkg->buf[2] >> 16 | s->pAckPkg->buf[3] >> 8 | s->pAckPkg->buf[4]; + (S32)(s->pAckPkg->buf[1]) << 24 | (S32)(s->pAckPkg->buf[2]) << 16 | (S32)(s->pAckPkg->buf[3]) << 8 + | (S32)(s->pAckPkg->buf[4]); } } } diff --git a/source/app/app_task_485_control.c b/source/app/app_task_485_control.c index d94a741..5566c54 100644 --- a/source/app/app_task_485_control.c +++ b/source/app/app_task_485_control.c @@ -24,6 +24,12 @@ void L3_task_485_control_handle(TS_485_control *s) L2_task_go(D_task_485_control_01); TTSS_Task_step(D_task_485_control_01) + //L0_uart0_ulhex(s->total_weight_pool); + //Lc_delay_ms(70);// 2000--7s + //L0_uart0_uc(' ');L0_uart0_uc(' ');L0_uart0_uc(' '); + //Lc_delay_ms(70);// 2000--7s + //L0_uart0_0d0a(); + //L0_uart0_ulhex(G.total_weight); if(s->total_weight_pool != G.total_weight) { G.slaver_info[1].mask = 1; @@ -35,7 +41,7 @@ void L3_task_485_control_handle(TS_485_control *s) { G.slaver_info[2].mask = 1; //G.slaver_info[4].mask = 1; - s->total_weight_pool = G.total_weight; + s->rfid_pool = G.rfid; } L2_task_go(D_task_485_control_01); diff --git a/source/app/app_task_485_control.h b/source/app/app_task_485_control.h index e035088..f4d1f29 100644 --- a/source/app/app_task_485_control.h +++ b/source/app/app_task_485_control.h @@ -9,7 +9,7 @@ typedef struct { TS_task task; S32 total_weight_pool; - S32 rfid_pool; + U16 rfid_pool; }TS_485_control; extern TS_485_control ts_485_control; diff --git a/source/app/main.c b/source/app/main.c index 7ea7390..043d263 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -118,6 +118,7 @@ void main(void) //----------------------------------------------- //系统主循环 //----------------------------------------------- + while(9) { if(1 == s_nos_tick.t1s_heatbeart) @@ -125,6 +126,10 @@ void main(void) s_nos_tick.t1s_heatbeart = 0; //L0_uart0_uc('.'); L0_uart0_sendArray("abcdefg", 7); + D_P03_REV(); + D_P04_REV(); + D_P05_REV(); + D_P06_REV(); } //串口3 RFID接收 L3_UARTcom3_exp_protocol(&s_uart3_rec); diff --git a/source/ctask/task.h b/source/ctask/task.h index 0e15c8a..4a53928 100644 --- a/source/ctask/task.h +++ b/source/ctask/task.h @@ -68,7 +68,7 @@ typedef struct _ts_task /// Delay_cycle适用于 时间短的,其一次循环取决于主循环的时间,和Tdelay比,Cdelay长时间计时误差大 #define L2_task_switch_default_idelay(); \ case D_task_Tdelay:\ - if (s_nos_tick.t_50ms >= s->task.n)\ + if (s_nos_tick.t_5ms >= s->task.n)\ {\ L2_task_delay_over();\ }\ @@ -172,7 +172,7 @@ typedef struct _ts_task //>>L2_task_delay一定要放在L2_task_go之后 #define L1_task_Tdelay(delay_n) s->task.sh_next = s->task.sh;\ s->task.sh = D_task_Tdelay;\ - s->task.n = delay_n + s_nos_tick.t_50ms; + s->task.n = delay_n + s_nos_tick.t_5ms; //>>L2_task_delay一定要放在L2_task_go之后 @@ -223,7 +223,7 @@ extern void L1_task_init(TS_task *s); { \ s->task.sh_next = next;\ s->task.sh = D_task_Tdelay;\ - s->task.n = (delay_n) + s_nos_tick.t_50ms; \ + s->task.n = (delay_n) + s_nos_tick.t_5ms; \ } \ else \ { \ diff --git a/source/ctask/tick.c b/source/ctask/tick.c index 973e547..82d0acf 100644 --- a/source/ctask/tick.c +++ b/source/ctask/tick.c @@ -30,12 +30,12 @@ void L1_tick_init(void) s_nos_tick.t1s_heatbeart= 0; s_nos_tick.flag_50ms = 0; - s_nos_tick.t_50ms = 0; + s_nos_tick.t_5ms = 0; + //s_nos_tick.t_50ms = 0; s_nos_tick.t_100ms = 0; s_nos_tick.t_1s = 0; s_nos_tick.flag_1s = 0; s_nos_tick.t_n = 0; - } #if 0 @@ -70,15 +70,16 @@ void L1_tick_tick (void) #else void L1_tick_tick (void) { - /// 65535*65535 /3600/24/365=139nian/s=1.39nian/10ms - ///�൱��1.39���t_10ms ��������ڵ�ع����ϵͳ���?��ȫ�������� - // 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000��/�� + /// 65535*65535 /3600/24/365=139nian/s=1.39nian/10ms + ///相当于1.39年后t_10ms 溢出,对于电池供电的系统而言 完全可以满足 + // 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000秒/年 s_nos_tick.tp_count++; - s_nos_tick.t_50ms ++;//D_led_D1_REV(); 20160522 ��֤ - if(s_nos_tick.t_50ms % D_TIMER0_1S_COUNT == 0) + //s_nos_tick.t_50ms ++;//D_led_D1_REV(); 20160522验证 + s_nos_tick.t_5ms ++; + if(s_nos_tick.t_5ms % D_TIMER0_1S_COUNT == 0) { - // 65535*65535/24/60/60/356/10 =12.7�� - s_nos_tick.t_1s ++;//// 65535*65535/24/60/60/356/10 =12.7�� + // 65535*65535/24/60/60/356/10 =12.7年 + s_nos_tick.t_1s ++; s_nos_tick.flag_1s2 = 1; s_nos_tick.t1s_heatbeart = 1; } diff --git a/source/ctask/tick.h b/source/ctask/tick.h index 1051aa3..4c66eab 100644 --- a/source/ctask/tick.h +++ b/source/ctask/tick.h @@ -20,8 +20,9 @@ struct _s_nos_tick_ vU8 flag_50ms; vU32 sys_clock; vU32 t_n; // noos系统定时器最小技术单元 - vU32 t_50ms; // noos 系统定时器10m技术 + //vU32 t_50ms; // noos 系统定时器10m技术 vU32 t_100ms; + vU32 t_5ms; vU32 t_1s; vU8 flag_1s; vU8 flag_1s2; @@ -55,7 +56,7 @@ extern struct _s_nos_tick_ s_nos_tick; #define D_Tdelay_10min (D_Tdelay_1s*60 * 10) #define D_Tdelay_1h (D_Tdelay_1min*60) #define D_Tdelay_1day (D_Tdelay_1h*24) -#define D_TIMER0_1S_COUNT 20 +#define D_TIMER0_1S_COUNT 200 //#define D_10mS 1//D_TIMER0_10MS_COUNT //#define D_100mS (D_10mS*10) //#define D_1S (D_10mS*100) diff --git a/source/msp/UART2.c b/source/msp/UART2.c index f5d5f92..6965ea2 100644 --- a/source/msp/UART2.c +++ b/source/msp/UART2.c @@ -56,6 +56,7 @@ msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面 ********************************************************************************/ #include "uart2.h" #include "../bsp/bsp_485.h" +#include "../app/app_common.h" struct _s_uart2_send_buf_ s_uart2_send_shop; struct _s_uart2_send_buf_ s_uart2_send_depot; @@ -165,6 +166,7 @@ void INTERRUPT_uart2(void) D_SERVE_uart2// using 2 /// output: 对应的结构体变量中携带 缓存buf和协议ok的标志 //s_uart2_rec.reg = L0_uart2_get(); //s_uart2_rec.ok = 1; + G.modbusstmp = s_nos_tick.t_5ms; (*Lp0_uart2_fun)(L0_uart2_get()); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -194,44 +196,40 @@ void INTERRUPT_uart2(void) D_SERVE_uart2// using 2 D_uart2_ES_INT_OPEN(); } -#if 0 - -void L0_uart2_0d0a(void) -{ - s_uart2_send_depot.max = 2; - s_uart2_send_depot.buf[0] = 0x0d; - s_uart2_send_depot.buf[1] = 0x0a; - s_uart2_send_depot.p = s_uart2_send_depot.buf; - L0_uart2_sendbuf(); -} - // L0_uart2_uc(cguHex2Char[D_uc_low(s->sec)][0]); -void L0_uart2_uchex(U8 ww) -{ - s_uart2_send_depot.max = 2; - s_uart2_send_depot.buf[0] = cguHex2Char[D_uc_low(ww)][1]; - s_uart2_send_depot.buf[1] = cguHex2Char[D_uc_high(ww)][1]; - s_uart2_send_depot.p = s_uart2_send_depot.buf; - L0_uart2_sendbuf(); -} -void L0_uart2_ulhex(vU32 ww) +void timer0_isrHanddle (void) interrupt 1 { - U_U32 ultemp; - ultemp.dWord = ww; - L0_uart2_uchex(ultemp.BYTE4.byte0); - L0_uart2_uchex(ultemp.BYTE4.byte1); - L0_uart2_uchex(ultemp.BYTE4.byte2); - L0_uart2_uchex(ultemp.BYTE4.byte3); -} + NOP(); + TF0 = 0; + + //modbus协议处理 + if(s_uart2_rec.head == 1 && G.modbusstmp - s_nos_tick.t_5ms >= 1) //收到一条协议 + { + s_uart2_rec.head = 0; + crc16_irq(s_uart2_rec.crc,s_uart2_rec.buf,s_uart2_rec.num - 2); + if(s_uart2_rec.crc[0] == s_uart2_rec.buf[s_uart2_rec.num-2] && s_uart2_rec.crc[1] == s_uart2_rec.buf[s_uart2_rec.num-1]) + { + if(s_uart2_rec.ok == 0) + { + s_uart2_rec.ok = 1; + } + //D_P32_REV(); + } + } -void L0_uart2_sendstr(U8 *str) -{ - //L0_uart2_sendbuf(str,strlen(str)); - s_uart2_send_depot.max = strlen(str); - s_uart2_send_depot.p = str; - L0_uart2_sendbuf(); -} + //tick处理 +#if 0 + /// 65535*65535 /3600/24/365=139nian/s=1.39nian/10ms + ///相当于1.39年后t_10ms 溢出,对于电池供电的系统而言 完全可以满足 + // 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000秒/年 + s_nos_tick.t_10ms ++;//D_led_D1_REV(); 20160522 验证 +#else + L1_tick_tick(); ///系统中的1sflag 和以10ms为颗粒的延时使用 为tdelay服务 #endif + NOP(); +} + + diff --git a/source/msp/time.c b/source/msp/time.c index 06c682d..b3b34f6 100644 --- a/source/msp/time.c +++ b/source/msp/time.c @@ -5,17 +5,26 @@ /*************************初始化定时器0*****************************/ void L0_timer0_Init(void) //50毫秒@11.0592MHz { +#if 0 //50ms@11.0592MHz AUXR &= 0x7F; //定时器时钟12T模式 TMOD &= 0xF0; //设置定时器模式 TL0 = 0x00; //设置定时初值 TH0 = 0x4C; //设置定时初值 TF0 = 0; //清除TF0标志 TR0 = 1; //定时器0开始计时 - +#else //5ms@11.0592MHz + AUXR &= 0x7F; //定时器时钟12T模式 + TMOD &= 0xF0; //设置定时器模式 + TL0 = 0x00; //设置定时初值 + TH0 = 0xEE; //设置定时初值 + TF0 = 0; //清除TF0标志 + TR0 = 1; //定时器0开始计时 +#endif ET0 = 1; //add by cc } - + /********************** Timer0中断函数************************/ +#if 0 //该函数移入uart2.c void timer0 (void) interrupt 1 { NOP(); NOP(); NOP(); @@ -24,6 +33,7 @@ void timer0 (void) interrupt 1 /// BITN_1(DR_who_wakeup, DRB_who_wakeup_timer0); NOP(); NOP(); NOP(); } +#endif /******************************END*********************************/ diff --git a/source/tpc/tpc_modbus.c b/source/tpc/tpc_modbus.c index 2010364..b12e680 100644 --- a/source/tpc/tpc_modbus.c +++ b/source/tpc/tpc_modbus.c @@ -81,7 +81,7 @@ U8 L3_pack_modbus_10(TS_PH4_modbus *pmodbus ,U8 slaverId, U16 reg, U16 num, U8 b } crc16(pmodbus->crc,&pmodbus->salver,2 + bufsize + bytes); pmodbus->buf[bufsize + bytes] = pmodbus->crc[0]; - pmodbus->buf[bufsize + bytes] = pmodbus->crc[1]; + pmodbus->buf[bufsize + bytes + 1] = pmodbus->crc[1]; return bufsize + bytes + 2 + 2; }