diff --git a/.vscode/settings.json b/.vscode/settings.json index 2e93347..d5b773d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,6 +19,12 @@ "clib.h": "c", "uart0.h": "c", "stdio.h": "c", - "uart3.h": "c" + "uart3.h": "c", + "app_task_speech.h": "c", + "app_task_tcp_control.h": "c", + "task_key.h": "c", + "task_game.h": "c", + "app_config.h": "c", + "type_traits": "c" } } \ No newline at end of file diff --git a/keilp/cc_as_stc02_ps5ws.uvprojx b/keilp/cc_as_stc02_ps5ws.uvprojx index c57fb76..3c78ad0 100644 --- a/keilp/cc_as_stc02_ps5ws.uvprojx +++ b/keilp/cc_as_stc02_ps5ws.uvprojx @@ -408,6 +408,11 @@ 1 ..\source\app\app_task_speech.c + + task_game.c + 1 + ..\source\app\task_game.c + diff --git a/si4/keywords.txt b/si4/keywords.txt deleted file mode 100644 index d39a8c6..0000000 --- a/si4/keywords.txt +++ /dev/null @@ -1,152 +0,0 @@ -#define, Keyword -#elif, Directive -#else, Directive -#endif, Directive -#if, Directive -#ifdef, Directive -#ifndef, Directive -#include, Keyword -#pragma, Keyword -#undef, Keyword -(, Delimiter -), Delimiter -",", Delimiter -;, Delimiter -abstract, Keyword -__abstract, Keyword -alignas, Keyword -alignof, Keyword -asm, Keyword -__asm, Keyword -assert, Debug -Assert, Debug -async, Keyword -auto, Keyword -bool, Keyword -break, Control -case, Control -catch, Control -cdecl, Keyword -__cdecl, Keyword -char, Keyword -class, Control -coclass, Control -const, Keyword -constexpr, Keyword -const_cast, Keyword -continue, Control -cout, Keyword -decltype, Keyword -default, Control -__delegate, Keyword -delete, Control -do, Control -double, Keyword -DWORD, Keyword -dynamic_cast, Keyword -each, Control -else, Control -enum, Control -__event, Keyword -except, Control -__except, Control -exception, Keyword -explicit, Keyword -export, Keyword -extern, Keyword -FALSE, Boolean -false, Boolean -FAR, Keyword -far, Keyword -final, Keyword -__finally, Control -float, Keyword -for, Control -fortran, Keyword -for_each, Control -friend, Keyword -__gc, Keyword -goto, Control -HUGE, Keyword -huge, Keyword -if, Control -inline, Keyword -INT, Keyword -int, Keyword -int16_t, Keyword -int32_t, Keyword -int64_t, Keyword -int8_t, Keyword -interface, Control -LONG, Keyword -long, Keyword -mutable, Keyword -namespace, Control -near, Keyword -NEAR, Keyword -new, Control -noexcept, Keyword -NULL, Null Value -nullptr, Null Value -__nullptr, Null Value -operator, Keyword -override, Keyword -pascal, Keyword -PASCAL, Keyword -private, Keyword -__property, Keyword -protected, Keyword -public, Keyword -ref, Keyword -REGISTER, Keyword -register, Keyword -reinterpret_cast, Keyword -return, Control -sealed, Keyword -short, Keyword -SHORT, Keyword -signed, Keyword -sizeof, Keyword -static, Keyword -static_cast, Keyword -struct, Control -__super, Keyword -switch, Control -template, Control -this, Keyword -thread_local, Keyword -throw, Control -TRUE, Boolean -true, Boolean -try, Control -__try, Control -TTSS_step01, Highlight -TTSS_Task_end, Highlight -TTSS_Task_init, Highlight -TTSS_Task_step, Highlight -TTSS_step01, Highlight -TTSS_step02,Highlight -TTSS_step03,Highlight -TTSS_step04,Highlight -TTSS_step05,Highlight -TTSS_step06,Highlight -TTSS_step07,Highlight -TTSS_Task_step, Highlight -typedef, Control -typeid, Keyword -typename, Keyword -UINT, Keyword -union, Control -unsigned, Keyword -using, Keyword -virtual, Keyword -VOID, Keyword -void, Keyword -volatile, Keyword -wchar_t, Keyword -while, Control -WORD, Keyword -{, Delimiter -[, Delimiter -], Delimiter -}, Delimiter diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_sym b/si4/ps5ws.si4project/soft_ps5ws.sip_sym deleted file mode 100644 index 6d98ce2..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_sym and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xab b/si4/ps5ws.si4project/soft_ps5ws.sip_xab deleted file mode 100644 index b27a913..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xab and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xad b/si4/ps5ws.si4project/soft_ps5ws.sip_xad deleted file mode 100644 index 9f1ad26..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xad and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xc b/si4/ps5ws.si4project/soft_ps5ws.sip_xc deleted file mode 100644 index f652f17..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xc and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xf b/si4/ps5ws.si4project/soft_ps5ws.sip_xf deleted file mode 100644 index 3949cdd..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xf and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xm b/si4/ps5ws.si4project/soft_ps5ws.sip_xm deleted file mode 100644 index 8163cdb..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xm and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xr b/si4/ps5ws.si4project/soft_ps5ws.sip_xr deleted file mode 100644 index c5e630f..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xr and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xsb b/si4/ps5ws.si4project/soft_ps5ws.sip_xsb deleted file mode 100644 index 101383e..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xsb and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xsd b/si4/ps5ws.si4project/soft_ps5ws.sip_xsd deleted file mode 100644 index 3a5eac2..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xsd and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.siproj b/si4/ps5ws.si4project/soft_ps5ws.siproj deleted file mode 100644 index 71776e9..0000000 Binary files a/si4/ps5ws.si4project/soft_ps5ws.siproj and /dev/null differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.siproj_settings.xml b/si4/ps5ws.si4project/soft_ps5ws.siproj_settings.xml deleted file mode 100644 index 13b87cb..0000000 --- a/si4/ps5ws.si4project/soft_ps5ws.siproj_settings.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/source/app/app_config.c b/source/app/app_config.c index 9b00a90..0df36d2 100644 --- a/source/app/app_config.c +++ b/source/app/app_config.c @@ -109,9 +109,12 @@ void L3_reg_reset(void) R.pen_ele_sta = 0; R.question_sta = 0; R.spee_order = 0; - //R.oid3_order = 0; - //R.pack_order = 0; - //R.frame_order = 0; + + R.oid.type = 0; + R.oid.dat = 0; + + R.game.type = 0; + R.game.dat = 0; for(i=0;islaver发送逻辑控制 // L3_task_tcp_control_handle(&ts_tcp_control); #endif - } -//end main - - - - - - - - - - + } +} +//end main \ No newline at end of file diff --git a/source/app/main.h b/source/app/main.h index c6b704e..79d6f0b 100644 --- a/source/app/main.h +++ b/source/app/main.h @@ -64,6 +64,8 @@ #include "../app/app_task_tcp.h" #include "../app/app_task_tcp_control.h" #include "../app/app_task_speech.h" +#include "../app/task_game.h" + #include "../asp/asp_oid.h" #include "../ctask/tick.h" diff --git a/source/app/source.lnk b/source/app/source.lnk index 1f3f23c..e045044 100644 Binary files a/source/app/source.lnk and b/source/app/source.lnk differ diff --git a/source/app/task_game.c b/source/app/task_game.c new file mode 100644 index 0000000..6f77516 --- /dev/null +++ b/source/app/task_game.c @@ -0,0 +1,145 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 传控科技 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.c +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 +////////////////////////////////////////////////////////////////////////////// + +#include "task_game.h" +#include "../bsp/bsp_oid.h" +#include "app_task_speech.h" +#include "../app/app_config.h" +#include "../bsp/bsp_config.h" +#include "../msp/uart0.h" +#include "../msp/uart3.h" + +S_TASK_GAME _s_task_game; + +//============================================= +void L3_task_game_init(void) +{ + L1_task_init(&_s_task_game.task); + L3_task_s_go(_s_task_game,D_task_init); +} + +#define D_task_GAME_SELECT 0x60 +#define D_task_GAME_ZMG 0x61 +#define D_task_GAME_ZBT 0x62 +#define D_task_GAME_SchulteGrid 0x63 + +void L3_task_game_handler(S_TASK_GAME *s) +{ + TTSS_Task_init() + L2_task_go(D_task_GAME_SELECT); + + TTSS_Task_step(D_task_GAME_SELECT) + if(R.game.type == 0x51) + // if(R.game.type == 0xDA) + { + L0_uart0_uc('A'); + if (R.game.dat == 0x42) + // if (R.game.dat == 0xC1) + { + R.game.type = 0; + R.game.dat = 0; + L0_uart0_uc('z'); + L0_uart3_sendArray((U8 *)&audio_zmg,9); + Lc_delay_ms(1000); + L2_task_go_Tdelay(D_task_GAME_ZMG, 0); + } + if (R.game.dat == 0xC2) + { + L0_uart3_sendArray((U8 *)&audio_zbt,9); + Lc_delay_ms(1000); + L2_task_go_Tdelay(D_task_GAME_ZBT, 0); + } + if (R.game.dat == 0xC3) + { + L0_uart3_sendArray((U8 *)&audio_SchulteGrid,9); + Lc_delay_ms(1000); + L2_task_go_Tdelay(D_task_GAME_SchulteGrid, 0); + } + } + else if (R.game.type) + { + R.game.type = 0; + R.game.dat = 0; + L0_uart3_sendArray((U8 *)&audio_select,9); + Lc_delay_ms(1000); + L2_task_go_Tdelay(D_task_GAME_SELECT, 0); + } + + TTSS_Task_step(D_task_GAME_ZMG) + if (R.game.dat == 0x85) + { + R.game.dat = 0; + L0_uart3_sendArray((U8 *)&audio_begin,9); + Lc_delay_ms(1000); + } + else + { + L0_uart3_sendArray((U8 *)&audio_zmg_again,9); + Lc_delay_ms(1000); + } + + TTSS_Task_end(); +} + +#if 0 +//NFC协议:60 20 00 07 10 02 04 00 99 83 33 4E 36 +//起始帧:60 +//设备ID:20 +//数据长度:00 07 +//命令:10 +//数据:02 04 00 99 83 33 4E +//校验:36 从起始帧到数据字段 [60 20 00 07 10 02 04 00 99 83 33 4E] 的所有字节的依次异或值 +void parse_nfc_pkg() +{ + TPC_NFC *p = (TPC_NFC *) ts_uart[uNum3].r.buf; + p->ocr = p->buf[p->num[0] << 8 | p->num[1]]; + if(p->head == 0x60 && 1 /*count_ocr() */) + { + U16 num = (U16)p->num[0] << 8 | p->num[1]; + //只读取0x10的协议 + if(p->cmd == 0x10 && num == 0x07){ + //1.判定NFC卡号是否符合规则 + //2.保存NFC卡号到寄存器 + R.nfc.nfc_no[0] = p->buf[num-2]; + R.nfc.nfc_no[1] = p->buf[num-1]; + //3.设定授权标志 + R.auth_flag |= 0x01; + //4.打印日志 + print_nfc_pkg(p); + } + } +} + +void print_nfc_pkg(TPC_NFC *p) +{ + L0_uart0_sendstr("\r\n--------- Recv NFC --------\r\n"); + L0_uart0_sendstr("id : "); + L0_uart0_uchex(p->slaveId); + L0_uart0_0d0a(); + L0_uart0_sendstr("num: "); + L0_uart0_uchex(p->num[0]); + L0_uart0_uchex(p->num[1]); + L0_uart0_0d0a(); + L0_uart0_sendstr("cmd: "); + L0_uart0_uchex(p->cmd); + L0_uart0_0d0a(); + L0_uart0_sendstr("no : "); + L0_uart0_sendArrayHex(p->buf, (U16)p->num[0] << 8 | p->num[1]); + L0_uart0_0d0a(); + L0_uart0_sendstr("ocr: "); + L0_uart0_uchex(p->buf[(U16)p->num[0] << 8 | p->num[1]]); + L0_uart0_0d0a(); +} +#endif + + + diff --git a/source/app/task_game.h b/source/app/task_game.h new file mode 100644 index 0000000..4f7b8ab --- /dev/null +++ b/source/app/task_game.h @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 传控科技 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.h +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 + +////////////////////////////////////////////////////////////////////////////// + +#ifndef _APP_TASK_GAME_H +#define _APP_TASK_GAME_H + +#include "../ctask/task.h" +#include "../clib/clib.h" + +typedef struct _s_task_game +{ + TS_task task; +}S_TASK_GAME; + +// typedef struct _tpc_nfc_ +// { +// U8 head; +// U8 slaveId; +// U8 num[2]; +// U8 cmd; +// U8 buf[TPC_NFC_DAT_MAX]; +// U8 ocr; +// }TPC_GAME; + +extern S_TASK_GAME _s_task_game; +extern void L3_task_game_init(void); +extern void L3_task_game_handler(S_TASK_GAME *s); +// extern void parse_game_pkg(); +// extern void print_game_pkg(TPC_NFC *p); + +#endif // #ifndef diff --git a/source/app/task_key.c b/source/app/task_key.c index 0d10855..1e51e55 100644 --- a/source/app/task_key.c +++ b/source/app/task_key.c @@ -11,6 +11,9 @@ ////////////////////////////////////////////////////////////////////////////// #include "task_key.h" #include "../clib/clib.h" +#include "../msp/uart3.h" +#include "../msp/uart0.h" +#include "app_task_speech.h" struct _s_task_key_ s_task_key_handle; @@ -26,6 +29,13 @@ void L0_key_init(void) //EX1 = 1; L1_task_init(&s_task_key_handle.task); L3_task_s_go(s_task_key_handle,D_task_init); + s_task_key_handle.key1_ok = 0; + s_task_key_handle.key2_ok = 0; + s_task_key_handle.key3_ok = 0; + s_task_key_handle.time1= 0; + s_task_key_handle.time2 = 0; + s_task_key_handle.time3 = 0; + } #if 0 void INT0_isrHanddle(void) D_SERVE_INT0 @@ -72,153 +82,158 @@ void INT1_isrHanddle(void) D_SERVE_INT1 void L3_task_key_handle(struct _s_task_key_ *p) { + if(key1 == 0) + { + //Lc_delay_ms(10);//按键防抖 if(key1 == 0) - { - //Lc_delay_ms(10);//按键防抖 - if(key1 == 0) - { - p->key1_ok = 1; - while(!key1) - { - p->time1++; - // L0_uart0_uchex(p->time1); - } - } - } - if(p->key1_ok) { - - if(p->time1 >= 180) - { - // L0_uart0_uc('#'); - // L0_uart0_uchex(p->time1); - // //LED1 = ~LED1; - // LED4 = ~LED4; + p->key1_ok = 1; + while(!key1) + { + p->time1++; + // L0_uart0_uchex(p->time1); } - else - { - U8 front[14] = {0xFF,0xFE,0x0B,0x14,0x10,0x00,0x03,0x00,0x01,0x02,0x00,0x00,0x54,0xF3}; - LED3 = 1; - Lc_delay_ms(100); - LED3 = 0; - LED3 = ~LED3; - L3_gm35_send_data((U8 *)&front,14); - + } + } + if(p->key1_ok == 1) + { + if(p->time1 >= 10) + { + // L0_uart0_uchex(p->time1); + // //LED1 = ~LED1; + // LED4 = ~LED4; + L0_uart0_sendstr("zmg"); + L0_uart0_0d0a(); + L0_uart3_sendArray((U8 *)&audio_zmg,9); + LED1 = ~LED1; + } + else + { + // L0_uart0_uc('A'); + // // U8 front[14] = {0xFF,0xFE,0x0B,0x14,0x10,0x00,0x03,0x00,0x01,0x02,0x00,0x00,0x54,0xF3}; + // LED3 = 1; + // Lc_delay_ms(100); + // LED3 = 0; + // LED3 = ~LED3; + // // L3_gm35_send_data((U8 *)&front,14); #if 0 - U8 i; - U8 mu[9]; - U8 music[9] = {0x7E,0x07,0xA3,0x43,0x30,0x30,0x39,0x86,0xEF}; - FF FE 0B 14 10 00 03 00 01 02 00 00 54 F3 - //7E 07 A3 43 30 30 39 86 EF - for(i = 0;i<9;i++) - { - mu[i] = music[i] & 0xFF; - } - L0_uart3_sendArray((U8 *)&mu, 9); - L0_uart0_sendArray((U8 *)&mu, 9); - - #endif + U8 i; + U8 mu[9]; + U8 music[9] = {0x7E,0x07,0xA3,0x43,0x30,0x30,0x39,0x86,0xEF}; + FF FE 0B 14 10 00 03 00 01 02 00 00 54 F3 + //7E 07 A3 43 30 30 39 86 EF + for(i = 0;i<9;i++) + { + mu[i] = music[i] & 0xFF; } - p->key1_ok = 0; - p->time1=0; + L0_uart3_sendArray((U8 *)&mu, 9); + L0_uart0_sendArray((U8 *)&mu, 9); + #endif + } + p->key1_ok = 0; + p->time1 = 0; } + if(key2 == 0) + { + //Lc_delay_ms(10);//按键防抖 if(key2 == 0) - { - //Lc_delay_ms(10);//按键防抖 - if(key2 == 0) - { - p->key2_ok = 1; - while(!key2) - { - p->time2++; - } - } - } - if(p->key2_ok) { - if(p->time2>=180) - { - //LED1 = ~LED1; - } - else + p->key2_ok = 1; + while(!key2) { - - U8 back[14] = {0xFF,0xFE,0x0B,0x14,0x10,0x00,0x03,0x00,0x01,0x02,0x00,0x01,0x95,0x33}; - LED3 = 1; - Lc_delay_ms(100); - LED3 = 0; - LED3 = ~LED3; - L3_gm35_send_data((U8 *)&back,14); - - #if 0 - U8 i; - U8 mu[9]; - U8 music[9] = {0x7E,0x07,0xA3,0x43,0x30,0x30,0x39,0x86,0xEF}; - //FF FE 0B 14 10 00 03 00 01 02 00 00 54 - //7E 07 A3 43 30 30 39 86 EF - for(i = 0;i<9;i++) - { - mu[i] = music[i] & 0xFF; - } - L0_uart3_sendArray((U8 *)&mu, 9); - L0_uart0_sendArray((U8 *)&mu, 9); - - #endif + p->time2++; } - p->key2_ok = 0; - p->time2=0; + } } -#if 0 - if(p->key2_ok) + if(p->key2_ok == 1) //if(p->key2_ok) 这里的p->key2_ok总是被赋值为0xFB,原因未知 { - if(p->time2>=180) - { - LED1 = ~LED1; + L0_uart0_sendstr("p->key2_ok = "); + L0_uart0_uchex(p->key2_ok); + L0_uart0_0d0a(); + if(p->time2>=10) + { + L0_uart0_sendstr("zbt"); + L0_uart0_0d0a(); + L0_uart3_sendArray((U8 *)&audio_zbt,9); + LED2 = ~LED2; } else - { - LED2 = ~LED2; + { + // U8 back[14] = {0xFF,0xFE,0x0B,0x14,0x10,0x00,0x03,0x00,0x01,0x02,0x00,0x01,0x95,0x33}; + // LED3 = 1; + // Lc_delay_ms(100); + // LED3 = 0; + // LED3 = ~LED3; + // L3_gm35_send_data((U8 *)&back,14); + #if 0 + U8 i; + U8 mu[9]; + U8 music[9] = {0x7E,0x07,0xA3,0x43,0x30,0x30,0x39,0x86,0xEF}; + //FF FE 0B 14 10 00 03 00 01 02 00 00 54 + //7E 07 A3 43 30 30 39 86 EF + for(i = 0;i<9;i++) + { + mu[i] = music[i] & 0xFF; + } + L0_uart3_sendArray((U8 *)&mu, 9); + L0_uart0_sendArray((U8 *)&mu, 9); + #endif } p->key2_ok = 0; - p->time2=0; + p->time2 = 0; } -#endif - if(key3 == 0) - { - //Lc_delay_ms(10);//按键防抖 - if(key3 == 0) - { - p->key3_ok = 1; + #if 0 + if(p->key2_ok) + { + if(p->time2>=180) + { + LED1 = ~LED1; + } + else + { + LED2 = ~LED2; + } + p->key2_ok = 0; + p->time2=0; + } + #endif + if(key3 == 0) + { + //Lc_delay_ms(10);//按键防抖 + if(key3 == 0) + { + p->key3_ok = 1; while(!key3) { p->time3++; } - } - } - if(p->key3_ok) - { - if(p->time3>=180) + } + } + if(p->key3_ok == 1) //if(p->key3_ok) 这里的p->key3_ok总是被赋值为0x12,原因未知 + { + if(p->time3>=10) { - LED3 = ~LED3; - LED2 = ~LED2; - LED1 = ~LED1; - LED4 = ~LED4; - Lc_delay_ms(100); - // LED1 = 0; - L3_gm35_send_str("+++"); - Lc_delay_ms(1000); - //s_task_gm35_flow.mode=W600_AP; - L3_task_gm35_flow_init(W600_AP); - //G.w600_mode = 0; + L0_uart0_sendstr("SchulteGrid"); + L0_uart0_0d0a(); + L0_uart3_sendArray((U8 *)&audio_SchulteGrid,9); + // LED3 = ~LED3; + // LED2 = ~LED2; + // LED1 = ~LED1; + // LED4 = ~LED4; + // Lc_delay_ms(100); + // // LED1 = 0; + // L3_gm35_send_str("+++"); + // Lc_delay_ms(1000); + // //s_task_gm35_flow.mode=W600_AP; + // L3_task_gm35_flow_init(W600_AP); + // //G.w600_mode = 0; } else { //LED2 = ~LED2; } p->key3_ok = 0; - p->time3=0; + p->time3 = 0; } - - } diff --git a/source/app/task_register.c b/source/app/task_register.c index 1499c64..429d0bc 100644 --- a/source/app/task_register.c +++ b/source/app/task_register.c @@ -27,7 +27,7 @@ void L3_task_reglisten_init(void) } //配置模式任务 -#define D_task_WEIGHT_COUNT 0x50 +#define D_task_WEIGHT_COUNT 0x50 #define D_task_IAP 0x51 void L3_task_reglisten_handle(S_TASK_REGVAL_LISTEN *s) { diff --git a/source/app/task_w600.c b/source/app/task_w600.c index 8f67708..c1c89d2 100644 --- a/source/app/task_w600.c +++ b/source/app/task_w600.c @@ -244,13 +244,11 @@ void L3_task_gm35_flow_init(U8 mode) #define TTSS_TASK_MODE_CONFIG_WAIT 0x2A #define TTSS_TASK_MODE_SERVER_CLOSE 0x2B - #define INS_TIMEOUT 5 #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() diff --git a/source/app/task_w600.h b/source/app/task_w600.h index b62cc5e..3f4f634 100644 --- a/source/app/task_w600.h +++ b/source/app/task_w600.h @@ -23,13 +23,15 @@ ////<<<<<<<<<<<<<<<<<<< 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_WIFI "AT+CWJAP_DEF=\"ccsens\",\"ccsens123\"\r\n" // +#define AT_INS_ST_CIPMUX0 "AT+CIPMUX=0\r\n" // #define AT_INS_ST_TCP "AT+CIPSTART=\"TCP\",\"www.tall.wiki\",8195\r\n" //连接服务器 //#define AT_INS_ST_TCP "AT+CIPSTART=\"TCP\",\"192.168.0.81\",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" //查询连接状态 +#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" // + + #define AT_INS_AP "AT+CWMODE=2\r\n" //进入AP模式 diff --git a/source/asp/asp_oid.c b/source/asp/asp_oid.c index 82e638a..0abe888 100644 --- a/source/asp/asp_oid.c +++ b/source/asp/asp_oid.c @@ -285,4 +285,25 @@ void L1_oid_debug(u8 *para) ET0 = 1; } +//oid协议: +// 00 47 A0 00 00 00 4E 86 (MSB) +// 00 45 40 00 00 00 4E 86 (MSB) +// 00 4A A0 00 00 00 4E 86 (MSB) + +//type部分 63-60 0000 (type) +//保留部分 59-54 00 0000 +//angle部分 53–45 0 0000 0000b (angle) +//保留部分 44 0 +//小数部分 43–36 1111 0010b (Y decimal) +//小数部分 35–28 0111 0100b (X decimal) +//整数部分 27–14 00 0000 0000 0100b (Y integer) +//整数部分 13–0 00 0000 0000 0100b (X integer) + +void parse_oid_pkg() +{ + + + +} + diff --git a/source/bsp/bsp_config.c b/source/bsp/bsp_config.c index c8b64ac..a280703 100644 --- a/source/bsp/bsp_config.c +++ b/source/bsp/bsp_config.c @@ -70,8 +70,12 @@ void L0_board_config(void) D_stdIO_P0(BITN0); D_stdIO_P0(BITN1); D_stdIO_P1(BITN6); - D_stdIO_P3(BITN2); - D_stdIO_P3(BITN3); + + // D_stdIO_P3(BITN2); + D_HighR_P3(BITN2); + D_HighR_P3(BITN3); + + D_stdIO_P3(BITN4); D_stdIO_P3(BITN5); D_stdIO_P3(BITN6); @@ -81,7 +85,9 @@ void L0_board_config(void) //D_HighI_P5(BITN5); D_stdIO_P0(BITN2); D_OpenD_P5(BITN5); - D_OpenD_P4(BITN0); + + D_HighR_P4(BITN0); + D_HighI_P3(BITN4); D_HighI_P5(BITN0); D_HighI_P0(BITN5); diff --git a/source/bsp/bsp_config.h b/source/bsp/bsp_config.h index 5c3ae43..f1e86ca 100644 --- a/source/bsp/bsp_config.h +++ b/source/bsp/bsp_config.h @@ -147,8 +147,8 @@ #define D_UART0_485_TYPE TYPE_485_NONE //UART0启用485 #define D_UART0_485_SLAVER_ID_BROADCAST 0xFF //485从机总是响应0xFF消息 #define D_UART0_485_SLAVER_ID 0x01 //板卡作为485从机 slaverId - #define D_UART0_485_TX() P32 = 1; - #define D_UART0_485_RX() P32 = 0; + // #define D_UART0_485_TX() P32 = 1; + // #define D_UART0_485_RX() P32 = 0; #define D_UART2_485_TYPE TYPE_485_NONE //UART2不启用485 #define D_UART3_485_TYPE TYPE_485_NONE //UART2不启用485 #define D_UART4_485_TYPE TYPE_485_NONE //UART2不启用485 diff --git a/source/bsp/bsp_oid.c b/source/bsp/bsp_oid.c index b7efb97..60c8081 100644 --- a/source/bsp/bsp_oid.c +++ b/source/bsp/bsp_oid.c @@ -1,9 +1,12 @@ #include "bsp_oid.h" #include "intrins.h" #include "../msp/uart0.h" +#include "../msp/uart3.h" #include #include "../ctask/task.h" #include "../ctask/tick.h" +#include "../app/app_task_speech.h" + /****************************************************************************************************** @@ -13,7 +16,8 @@ AppDevice eAppDevice = ePointRead_2000A; ///volatile uint32_t RecvData[3]; Ts_OID_ ts_oid; -uint8_t TransCmd[7]; +uint8_t TransCmd[7]; + ///#define MAIN_Fosc 11059260L #if 0 #define MAIN_Fosc (12459260L/4) @@ -106,7 +110,7 @@ uint16_t L0_oid_RecvAck16(void) uint16_t AckValue; AckValue = 0; /// -LD_Oid_SDIO_OUT(); + LD_Oid_SDIO_OUT(); delay_us(D_DELAY_10US); LD_Oid_SCK_HIGH(); LD_Oid_SDIO_LOW(); @@ -158,53 +162,20 @@ void L0_oid_Recv64(void) LD_Oid_SCK_HIGH(); delay_us(D_DELAY_10US); LD_Oid_SCK_LOW(); - - - #if 0 - if(OID_DET) - { - if(i < 32) - { - RecvData[0] += 1; - } - if(i>=32 && i<64) - { - RecvData[1] += 1; - } - - } - - if(i < 31) - { - RecvData[0] <<= 1; - } - if( i >31 && i < 63) - { - RecvData[1] <<= 1; - } - #endif - - ///#else ts_oid.rec.d[i/8] <<= 1; if(OID_DET) { ts_oid.rec.d[i/8] |= 1; - // RecvData[1] += 1; } else { ts_oid.rec.d[i/8] &= 0xfe; } - // RecvData[1] <<= 1; - - - delay_us(D_DELAY_10US); } - - + ts_oid.time = D_sys_now; delay_us(D_DELAY_ROD_80US); @@ -283,7 +254,6 @@ uint32_t L1_oidReadRegister (uint16_t Data1) if(!OID_DET) { L0_oid_Recv64(); - /// uxReturn = RecvData[1]; uxReturn = ts_oid.rec.d32[1]; uxReturn &= 0xFFFF; @@ -403,64 +373,110 @@ vU16 Lc_dec_us100(vU16 pint,u8 pdec) } -void L2_oid_ParseF1(void) +void L2_oid_ParseF1(void) //解析 { -/// static uint8_t ucLogNum = 0; uint16_t u16i = 0; uint32_t u32t[2] = 0; -/// L1_print_rcv("\r\n F1="); + // L1_print_rcv("\r\n F1="); ts_oid.oid_type = ts_oid.rec.d[0]; - + + R.game.type = ts_oid.rec.d[6]; + R.game.dat = ts_oid.rec.d[7]; + + L0_uart0_sendstr("R.game.type = "); + L0_uart0_uchex(R.game.type); + L0_uart0_0d0a(); + L0_uart0_sendstr("R.game.dat = "); + L0_uart0_uchex(R.game.dat); + L0_uart0_0d0a(); + + // R.oid.type = ts_oid.rec.d[6]; + // R.oid.dat = ts_oid.rec.d[7]; + + // d[7] L0_uart0_sendstr("ts_oid.rec.d[0] = "); L0_uart0_uchex(ts_oid.rec.d[0]); L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d[1] = "); + L0_uart0_sendstr("ts_oid.rec.d[1] = "); L0_uart0_uchex(ts_oid.rec.d[1]); L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d[2] = "); + L0_uart0_sendstr("ts_oid.rec.d[2] = "); L0_uart0_uchex(ts_oid.rec.d[2]); L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d[3] = "); + L0_uart0_sendstr("ts_oid.rec.d[3] = "); L0_uart0_uchex(ts_oid.rec.d[3]); + L0_uart0_0d0a(); + L0_uart0_sendstr("ts_oid.rec.d[4] = "); + L0_uart0_uchex(ts_oid.rec.d[4]); L0_uart0_0d0a(); - - ///////// - L0_uart0_sendstr("ts_oid.rec.d16[0] = "); - L0_uart0_ushex(ts_oid.rec.d16[0]); - L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d16[1] = "); - L0_uart0_ushex(ts_oid.rec.d16[1]); + L0_uart0_sendstr("ts_oid.rec.d[5] = "); + L0_uart0_uchex(ts_oid.rec.d[5]); L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d16[2] = "); - L0_uart0_ushex(ts_oid.rec.d16[2]); + L0_uart0_sendstr("ts_oid.rec.d[6] = "); + L0_uart0_uchex(ts_oid.rec.d[6]); L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d16[3] = "); - L0_uart0_ushex(ts_oid.rec.d16[3]); + L0_uart0_sendstr("ts_oid.rec.d[7] = "); + L0_uart0_uchex(ts_oid.rec.d[7]); L0_uart0_0d0a(); - - // ///////// - - L0_uart0_sendstr("ts_oid.rec.d32[0] = "); - L0_uart0_ulhex(ts_oid.rec.d32[0]); - L0_uart0_0d0a(); - L0_uart0_sendstr("ts_oid.rec.d32[1] = "); - L0_uart0_ulhex(ts_oid.rec.d32[1]); - L0_uart0_0d0a(); - // ///////// - - L0_uart0_sendstr("ts_oid.oid_type = "); - L0_uart0_uchex(ts_oid.oid_type); - L0_uart0_0d0a(); - - - if(1)// if(ts_oid.rec.d[0] == 0x60) // 4 + // // d16 + // L0_uart0_sendstr("ts_oid.rec.d16[0] = "); + // L0_uart0_ushex(ts_oid.rec.d16[0]); + // L0_uart0_0d0a(); + // L0_uart0_sendstr("ts_oid.rec.d16[1] = "); + // L0_uart0_ushex(ts_oid.rec.d16[1]); + // L0_uart0_0d0a(); + // L0_uart0_sendstr("ts_oid.rec.d16[2] = "); + // L0_uart0_ushex(ts_oid.rec.d16[2]); + // L0_uart0_0d0a(); + // L0_uart0_sendstr("ts_oid.rec.d16[3] = "); + // L0_uart0_ushex(ts_oid.rec.d16[3]); + // L0_uart0_0d0a(); + // // d32 + // L0_uart0_sendstr("ts_oid.rec.d32[0] = "); + // L0_uart0_ulhex(ts_oid.rec.d32[0]); + // L0_uart0_0d0a(); + // L0_uart0_sendstr("ts_oid.rec.d32[1] = "); + // L0_uart0_ulhex(ts_oid.rec.d32[1]); + // L0_uart0_0d0a(); + // // oid_type + // L0_uart0_sendstr("ts_oid.oid_type = "); + // L0_uart0_uchex(ts_oid.oid_type); + // L0_uart0_0d0a(); + + + if(ts_oid.rec.d[0] == 0x00) // 4 {/// Bit43~Bit0:x,y 轴的坐标数据,x 坐标和 y 坐标都是由整数和小数部分 ///组成,整数部分 14bit,小数部分 8bit G.pen_t = 0; ts_oid.last_time = s_nos_tick.t_1s; ts_oid.Xint = ts_oid.rec.d16[3] & 0x3fff; + + #if 0 + // 测试oid,led,喇叭联动 + if(ts_oid.rec.d16[3] == 0x4E85) + { + L0_uart3_sendArray((U8 *)&audio_SchulteGrid,9); + LED1 = ~LED1; + } + if(ts_oid.rec.d16[3] == 0x4E86) + { + L0_uart3_sendArray((U8 *)&audio_up,9); + LED2 = ~LED2; + } + if(ts_oid.rec.d16[3] == 0x4E87) + { + L0_uart3_sendArray((U8 *)&audio_down,9); + LED3 = ~LED3; + } + if(ts_oid.rec.d16[3] == 0x4E88) + { + L0_uart3_sendArray((U8 *)&audio_zmg,9); + LED4 = ~LED4; + } + #endif + - if(ts_oid.Xint < 300)///取决于图片 fixme: cc + if(ts_oid.Xint < 300)///取决于图片 fixme: cc //0E87 --- 3719 { ts_oid.oid_x = 1; @@ -547,19 +563,17 @@ void L2_oid_ParseF1(void) //// 普通码(bit61=0) //// Bit60:码是否有效(1:无效码;0:有效码) //// Bit59~Bit28:保留 -/// Bit27~Bit0:有效数据 - /// G.oid_p = 1; +/// Bit27~Bit0:有效数据 +/// G.oid_p = 1; ts_oid.oid_p = 1; ts_oid.gCode = ts_oid.rec.d32[1]&0x0fFFffFF; -///R.oid3_order = (int)ts_oid.gCode *100; - - - - printf(" %ld %x ",ts_oid.gCode,(int)ts_oid.gCode); - +/// R.oid3_order = (int)ts_oid.gCode *100; + + printf(" %ld %x ",ts_oid.gCode,(int)ts_oid.gCode); L0_uart0_ulhex(ts_oid.gCode); - }else + } + else { ts_oid.oid_type = 0; L0_uart0_uc(','); @@ -704,10 +718,10 @@ void L1_Oid_readoid(void) { if(!OID_DET) { - LED1 = ~LED1; + // LED1 = ~LED1; ts_oid.pre_x = ts_oid.X100; ts_oid.pre_y = ts_oid.Y100; - L0_oid_Recv64(); + L0_oid_Recv64(); //ts_oid.rec.d[i/8] <<= 1; L2_oid_ParseF1(); //L2_oid_status(); L1_print_rcv("\r\n "); @@ -729,7 +743,7 @@ void L1_Oid_readoid(void) { G.pen_up = 1; G.pen_t =1; - //L0_uart2_sendstr("789"); + L0_uart0_sendstr("789"); } /// delay_us(100); } diff --git a/source/bsp/bsp_oid.h b/source/bsp/bsp_oid.h index 61082f8..7c20c28 100644 --- a/source/bsp/bsp_oid.h +++ b/source/bsp/bsp_oid.h @@ -1,8 +1,8 @@ #ifndef __OPTICALDATA__ #define __OPTICALDATA__ -#include "bsp_config.h" -#include "../app/app_config.h" +#include "bsp_config.h" +#include "../app/app_config.h" /****************************************************************************************************** 配置参数 @@ -35,15 +35,15 @@ #define LD_Oid_SDIO_INIT() D_HighR_P5(BITN0) -#define LD_Oid_SDIO_LOW() D_P50_OFF() -#define LD_Oid_SDIO_HIGH() D_P50_ON() +#define LD_Oid_SDIO_LOW() D_P50_OFF() +#define LD_Oid_SDIO_HIGH() D_P50_ON() #define LD_Oid_SDIO_IN() D_HighR_P5(BITN0)//高阻输入 #define LD_Oid_SDIO_OUT() D_HighI_P5(BITN0)//推挽输出 -#define LD_Oid_SDIO_AT() D_P50_AT() +#define LD_Oid_SDIO_AT() D_P50_AT() -#define LD_Oid_DIO_INIT(); LD_Oid_SCK_INIT();LD_Oid_SDIO_INIT(); +#define LD_Oid_DIO_INIT(); LD_Oid_SCK_INIT();LD_Oid_SDIO_INIT(); #define OID_DET P50 @@ -54,52 +54,50 @@ ////20211229依据53xx和54xx系列操作 -#define USERCMD_20FPS 0x24 -#define USERCMD_30FPS 0x25 -#define USERCMD_40FPS 0x26 -#define USERCMD_50FPS 0x27 -#define USERCMD_80FPS 0x3C -#define USERCMD_80FPS_EXIT 0x3B -#define USERCMD_DECODE_SHUT 0x4D -#define USERCMD_LIANCHUAN 0x40 -#define USERCMD_SUSPEND 0x57 -#define USERCMD_EN_ANGLE 0x10 -#define USERCMD_EN_POSITION 0x35 -#define USERCMD_SW_POSITION 0x43 -#define USERCMD_DATA_FORMAT_2 0x2C -#define USERCMD_LOU_GUANG 0xD7 -#define USERCMD_POWER_DOWN 0x56 - - - -#define OIDCMD_POWER_ON 0x0000FFF8 -#define OIDCMD_POWER_OFF 0x0000FFF7 +#define USERCMD_20FPS 0x24 +#define USERCMD_30FPS 0x25 +#define USERCMD_40FPS 0x26 +#define USERCMD_50FPS 0x27 +#define USERCMD_80FPS 0x3C +#define USERCMD_80FPS_EXIT 0x3B +#define USERCMD_DECODE_SHUT 0x4D +#define USERCMD_LIANCHUAN 0x40 +#define USERCMD_SUSPEND 0x57 +#define USERCMD_EN_ANGLE 0x10 +#define USERCMD_EN_POSITION 0x35 +#define USERCMD_SW_POSITION 0x43 +#define USERCMD_DATA_FORMAT_2 0x2C +#define USERCMD_LOU_GUANG 0xD7 +#define USERCMD_POWER_DOWN 0x56 + +#define OIDCMD_POWER_ON 0x0000FFF8 +#define OIDCMD_POWER_OFF 0x0000FFF7 /****************************************************************************************************** OID版本 *******************************************************************************************************/ -#define OID_VER_D 0x1169 -#define OID_VER_REG 0x1670 -#define OID_VER_F 0x1168 -#define REG_READOID_SET 0xD40 -#define REG_EN_DECODE 0xD63 -#define REG_ROM008 0xDA5 -#define REG_ROM009 0xDA6 -#define ROM_009 0x09 -#define ROM_008 0x00 +#define OID_VER_D 0x1169 +#define OID_VER_REG 0x1670 +#define OID_VER_F 0x1168 +#define REG_READOID_SET 0xD40 +#define REG_EN_DECODE 0xD63 +#define REG_ROM008 0xDA5 +#define REG_ROM009 0xDA6 +#define ROM_009 0x09 +#define ROM_008 0x00 /****************************************************************************************************** Dataformat 2定义 *******************************************************************************************************/ -#define CHECK_INVALID_DF2 0x40000000 -#define CHECK_OID_VERSION_DF2 0xFC000000 -#define OID_2_GENERAL_DF2 0x00000000 -#define OID_3_GENERAL_DF2 0x08000000 -#define OID_3_POSITION_DF2 0x04000000 -#define OID_3S_GENERAL_DF2 0x10000000 -#define OID_3S_POSITION_DF2 0x0C000000 -#define OID_35_GENERAL_DF2 0x14000000 -#define OID_4_GENERAL_DF2 0x1C000000 -#define OID_4_POSITION_DF2 0x18000000 -#define OID_4C_POSITION_DF2 0x20000000 +#define CHECK_INVALID_DF2 0x40000000 +#define CHECK_OID_VERSION_DF2 0xFC000000 +#define OID_2_GENERAL_DF2 0x00000000 +#define OID_3_GENERAL_DF2 0x08000000 +#define OID_3_POSITION_DF2 0x04000000 +#define OID_3S_GENERAL_DF2 0x10000000 +#define OID_3S_POSITION_DF2 0x0C000000 +#define OID_35_GENERAL_DF2 0x14000000 +#define OID_4_GENERAL_DF2 0x1C000000 +#define OID_4_POSITION_DF2 0x18000000 +#define OID_4C_POSITION_DF2 0x20000000 /****************************************************************************************************** 函数声明 *******************************************************************************************************/ @@ -140,21 +138,22 @@ uint8_t L1_oid_CheckVersionAndInit(AppDevice eAppDevice); typedef struct _ts_OID -{//8byte -/// u8 d[8]; +{ U_U64 rec; - U8 oid_type; //类型63–60 0110b - U16 angle; // 53–45 Angle 53,52 51 50 49,48 47 46 45 - U8 Ydec; //小数部分43–36 1111 0010b (Y decimal) - U8 Xdec; //小数部分35–28 0111 0100b (X decimal) - vU16 Yint; //整数部分 27–14 00 0000 0000 0100b (Y integer) - vU16 Xint; //整数部分 13–0 00 0000 0000 0100b (X integer) + + // Data format of OID + U8 oid_type; //oid类型 :63–60 0110b + U16 angle; //Angle :53–45 + U8 Ydec; //小数部分(Y decimal) :43–36 1111 0010b + U8 Xdec; //小数部分(X decimal) :35–28 0111 0100b + vU16 Yint; //整数部分(Y integer) :27–14 00 0000 0000 0100b + vU16 Xint; //整数部分(X integer) :13–0 00 0000 0000 0100b - vU16 Y100,X100;///放大100倍的输出 - vU32 gCode; // + vU16 Y100,X100; ///放大100倍的输出 + vU32 gCode; // vU32 time; - vU32 last_time; + vU32 last_time; vU32 overtime; diff --git a/source/bsp/rs485.h b/source/bsp/rs485.h index 291f19b..b710036 100644 --- a/source/bsp/rs485.h +++ b/source/bsp/rs485.h @@ -7,8 +7,8 @@ //485_RE P33 //485_DE P32 -#define D_485_TX() P32 = 1;// >750us -#define D_485_RX() P32 = 0; +// #define D_485_TX() P32 = 1;// >750us +// #define D_485_RX() P32 = 0; extern void L2_485_init(void); #endif \ No newline at end of file diff --git a/source/msp/UART0.C b/source/msp/UART0.C index a3b9ef6..60911da 100644 --- a/source/msp/UART0.C +++ b/source/msp/UART0.C @@ -43,7 +43,7 @@ void L0_uart0_buf_init(void) D_uart0_ES_INT(1); //默认处于接收状态 - D_UART0_485_RX() +// D_UART0_485_RX() } /*************************************************