From d723fed230e8af1c751eab1ab0998ea714abc819 Mon Sep 17 00:00:00 2001 From: Zhangwen <13970730+mkc46119@user.noreply.gitee.com> Date: Sat, 1 Mar 2025 19:45:20 +0800 Subject: [PATCH] =?UTF-8?q?feature=EF=BC=9A1.=E4=BB=BB=E5=8A=A11:task=5Fap?= =?UTF-8?q?pstatus=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +- source/app/app_config.c | 4 +- source/app/app_config.h | 7 ++- source/app/main.c | 26 +++++++- source/app/main.h | 9 ++- source/app/task_appTEST.c | 67 ++++++++++++++++++++ source/app/task_appTEST.h | 28 +++++++++ source/app/task_appstatus.c | 119 ++++++++++++++++++++++-------------- source/app/task_appstatus.h | 4 +- source/bsp/bsp_WT2605B.c | 17 +++--- source/bsp/bsp_WT2605B.h | 13 ++-- source/bsp/bsp_config.c | 4 +- source/bsp/bsp_led.c | 23 +++++-- source/bsp/bsp_led.h | 12 ++-- source/clib/clib.c | 2 +- source/msp/msp_eeprom.c | 2 +- source/msp/msp_eeprom.h | 4 +- 17 files changed, 253 insertions(+), 91 deletions(-) create mode 100644 source/app/task_appTEST.c create mode 100644 source/app/task_appTEST.h diff --git a/.vscode/settings.json b/.vscode/settings.json index 2fde315..f6d9d0e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,6 +37,7 @@ "bsp_wt2605.h": "c", "bsp_key.h": "c", "task_appstatus.h": "c", - "bsp_wt2605b.h": "c" + "bsp_wt2605b.h": "c", + "task_apptset.h": "c" } } \ No newline at end of file diff --git a/source/app/app_config.c b/source/app/app_config.c index 1f6799e..40db913 100644 --- a/source/app/app_config.c +++ b/source/app/app_config.c @@ -2,7 +2,7 @@ ///#include "../bsp/cs1232.h" #include "../bsp/chipid.h" // #include "../msp/eeprom.h" -#include "../msp/msp_eeprom.h" +// #include "../msp/msp_eeprom.h" #include "../clib/clib.h" @@ -103,7 +103,7 @@ void L3_reg_reset(void) { U8 i = 0; - R.app_status = POW_OFF; + R.app_status = POW_ON; R.pen_sta = 0; diff --git a/source/app/app_config.h b/source/app/app_config.h index c86047c..d028915 100644 --- a/source/app/app_config.h +++ b/source/app/app_config.h @@ -36,9 +36,10 @@ typedef enum { POW_OFF = 0, //开机状态 POW_ON = 1, //关机状态 - WIFI_CONNECTED = 2, //WIFI连接成功 - TCP_CONNECTED = 3, //TCP连接成 - WIFI_CONFIG = 9, //WIFI配置连接中 + WIFI_CONFIG = 2, //WIFI配置连接中 + WIFI_CONNECTED = 3, //WIFI连接成功 + TCP_CONNECTED = 4, //TCP连接成 + }APP_STATUS; diff --git a/source/app/main.c b/source/app/main.c index 4e9739a..fee198d 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -42,6 +42,7 @@ void L0_TASK_init(void) //系统状态任务初始化 L3_task_AppStatus_init(); + L3_task_AppTest_init(); // //游戏任务初始化 // L3_task_game_init(); // //寄存器监听任务初始化 @@ -62,7 +63,7 @@ void L0_TASK_init(void) //=============================================== void main(void) { - // int i; + int i; // u8 voice_30[6] = {0x7E,0x04,0xAE,0x1E,0xD0,0xEF}; // u8 voice_13[6] = {0x7E,0x04,0xAE,0x0D,0xBF,0xEF}; @@ -83,6 +84,8 @@ void main(void) L0_uart0_sendArray("PEN_V2",6); L0_uart0_0d0a(); + + //Lc_delay_ms(3000); //L0_uart3_sendArray((U8 *)&voice_30,6); @@ -116,11 +119,28 @@ void main(void) // L0_uart0_0d0a(); // } // L0_uart0_sendArrayHex(data_save_arr, 30); - L0_uart0_uc('.'); - } + L0_uart0_uc('.'); + // i ++; + // if (i == 2) + // { + // L2_GREEN_LED_ON(); + + // } + // if (i == 4) + // { + // L2_RED_LED_ON(); + // } + // if (i == 6) + // { + // i = 0; + // L2_LED_OFF(); + // } + // L0_uart3_sendArray((U8 *)&audio_up,9); + } L3_task_appstatus_handler(&_s_task_appstatus); + L3_task_AppTest_handler(&_s_task_apptest); // // 串口2的 接收数据 测试 // if(ts_uart[uNum2].r.ok == 1) diff --git a/source/app/main.h b/source/app/main.h index 3b978b1..3cff543 100644 --- a/source/app/main.h +++ b/source/app/main.h @@ -47,7 +47,7 @@ #include "../msp/uart4.h" // #include "../msp/eeprom.h" -#include "../msp/msp_eeprom.h" +// #include "../msp/msp_eeprom.h" #include "../bsp/bsp_config.h" #include "../bsp/chipid.h" @@ -68,13 +68,12 @@ #include "../app/task_game.h" #include "../app/app_data_save.h" -#include "task_appstatus.h" - -#include "task_appstatus.h" +#include "../app/task_appstatus.h" +#include "../app/task_appTEST.h" #include "../bsp/bsp_led.h" #include "../bsp/bsp_key.h" #include "../bsp/bsp_WT2605B.h" - +#include "../app/app_config.h" #include "../asp/asp_oid.h" #include "../ctask/tick.h" diff --git a/source/app/task_appTEST.c b/source/app/task_appTEST.c new file mode 100644 index 0000000..bdf0054 --- /dev/null +++ b/source/app/task_appTEST.c @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////// +///@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 "../app/task_appTEST.h" +#include "app_config.h" + + +S_TASK_APPTEST _s_task_apptest; + +void L3_task_AppTest_init(void) +{ + L1_task_init(&_s_task_apptest.task); + L3_task_s_go(_s_task_apptest,D_task_init); +} + +#define D_task_Status00 0x50 +#define D_task_Status01 0x51 +#define D_task_Status02 0x52 +#define D_task_Status03 0x53 +#define D_task_Status04 0x54 + + // POW_OFF = 0, //开机状态 + // POW_ON = 1, //关机状态 + // WIFI_CONNECTED = 2, //WIFI连接成功 + // TCP_CONNECTED = 3, //TCP连接成 + // WIFI_CONFIG = 9, //WIFI配置连接中 + +void L3_task_AppTest_handler(S_TASK_APPTEST *s) +{ + TTSS_Task_init() + L2_task_go(D_task_Status00); + + TTSS_Task_step(D_task_Status00) + + R.app_status = POW_OFF; + L2_task_go_Tdelay(D_task_Status01,D_Tdelay_10s); + + TTSS_Task_step(D_task_Status01) + + R.app_status = POW_ON; + L2_task_go_Tdelay(D_task_Status02,D_Tdelay_10s); + + TTSS_Task_step(D_task_Status02) + R.app_status = WIFI_CONFIG; + L2_task_go_Tdelay(D_task_Status03,D_Tdelay_10s); + + TTSS_Task_step(D_task_Status03) + + R.app_status = WIFI_CONNECTED; + L2_task_go_Tdelay(D_task_Status04,D_Tdelay_10s); + + TTSS_Task_step(D_task_Status04) + + R.app_status = TCP_CONNECTED; + L2_task_go_Tdelay(D_task_Status00,D_Tdelay_10s); + + TTSS_Task_end(); +} \ No newline at end of file diff --git a/source/app/task_appTEST.h b/source/app/task_appTEST.h new file mode 100644 index 0000000..1487d0f --- /dev/null +++ b/source/app/task_appTEST.h @@ -0,0 +1,28 @@ +//////////////////////////////////////////////////////////////////////////// +///@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 _TASK_APPTEST_H +#define _TASK_APPTEST_H + +#include "../ctask/task.h" + +typedef struct _s_task_apptest +{ + TS_task task; +}S_TASK_APPTEST; + +extern S_TASK_APPTEST _s_task_apptest; +extern void L3_task_AppTest_init(void); +extern void L3_task_AppTest_handler(S_TASK_APPTEST *s); + +#endif // #ifndef diff --git a/source/app/task_appstatus.c b/source/app/task_appstatus.c index 15507ae..28c4a66 100644 --- a/source/app/task_appstatus.c +++ b/source/app/task_appstatus.c @@ -16,6 +16,8 @@ #include "../bsp/bsp_WT2605B.h" #include "../app/app_config.h" #include "../bsp/bsp_config.h" +#include "../msp/uart0.h" +#include "../bsp/bsp_led.h" S_TASK_APPSTATUS _s_task_appstatus; @@ -27,8 +29,13 @@ void L3_task_AppStatus_init(void) L3_task_s_go(_s_task_appstatus,D_task_init); } -#define D_task_DETECTCHANGE 0x50 -#define D_task_HANDLECHANGE 0x51 +#define D_task_DETECTCHANGE 0x50 +#define D_task_HANDLECHANGE 0x51 +#define D_task_WIFICONFIG_STATUS01 0x52 +#define D_task_WIFICONFIG_STATUS02 0x53 +#define D_task_WIFICONN_STATUS01 0x54 +#define D_task_WIFICONN_STATUS02 0x55 + void L3_task_appstatus_handler(S_TASK_APPSTATUS *s) { @@ -40,72 +47,92 @@ void L3_task_appstatus_handler(S_TASK_APPSTATUS *s) { s->status = R.app_status; L2_task_go_Tdelay(D_task_HANDLECHANGE,D_Tdelay_300ms); - } + } + else if (s->status == WIFI_CONFIG) + { + L2_task_go_Tdelay(D_task_WIFICONFIG_STATUS01,0); + } + else if (s->status == WIFI_CONNECTED) + { + L2_task_go_Tdelay(D_task_WIFICONN_STATUS01,0); + } + TTSS_Task_step(D_task_HANDLECHANGE) if(s->status == POW_OFF) { // LED灯灭 - RED_LED = LED_OFF; - GREEN_LED = LED_OFF; - // 音频播放关机语音后断电 + L2_LED_OFF(); + // // 音频播放关机语音后断电 L2_WT2605B_broadcast(&audio_powerdown); - Lc_delay_ms(1000); - L2_WT2605B_PWROFF(); - // OID和WIFI断电 - L0_PW_3V3_OFF(); - + // Lc_delay_ms(1000); + // L2_WT2605B_PWROFF(); + // // OID和WIFI断电 + // L0_PW_3V3_OFF(); } else if (s->status == POW_ON) { + L0_uart0_uc(R.app_status); // LED红灯常亮,LED绿灯灭 - RED_LED = LED_ON; - GREEN_LED = LED_OFF; + L2_RED_LED_ON(); // 音频通电后播放开机语音 - L2_WT2605B_PWRON(); - Lc_delay_ms(1000); - L2_WT2605B_broadcast(&audio_wellcome); - // OID和WIFI通电 - L0_PW_3V3_ON(); + // L2_WT2605B_PWRON(); + // Lc_delay_ms(1000); + L2_WT2605B_broadcast(&audio_poweron); + // // OID和WIFI通电 + // L0_PW_3V3_ON(); + } + else if (s->status == WIFI_CONFIG) + { + // 灯灭 + L2_LED_OFF(); +// // 音频播放 +// L2_WT2605B_PWRON(); +// Lc_delay_ms(1000); + L2_WT2605B_broadcast(&audio_config_mode); +// // L2_WT2605B_broadcast(&audio_Wifi_Config); +// // OID和WIFI通电 +// L0_PW_3V3_ON(); } else if (s->status == WIFI_CONNECTED) { - // LED红绿交替闪烁 - RED_LED = ~RED_LED; - GREEN_LED = ~GREEN_LED; + // 灯灭 + L2_LED_OFF(); // 音频播放 - L2_WT2605B_PWRON(); - Lc_delay_ms(1000); -// L2_WT2605B_broadcast(audio_Wifi_Connected); - // OID和WIFI通电 - L0_PW_3V3_ON(); +// L2_WT2605B_PWRON(); +// Lc_delay_ms(1000); + L2_WT2605B_broadcast(&audio_wifi_connected); +// // OID和WIFI通电 +// L0_PW_3V3_ON(); } + else if (s->status == TCP_CONNECTED) { // LED红灯灭,LED绿灯常亮 - RED_LED = LED_OFF; - GREEN_LED = LED_ON; - // 音频播放 - L2_WT2605B_PWRON(); - Lc_delay_ms(1000); -// L2_WT2605B_broadcast(audio_TCP_Connected); - // OID和WIFI通电 - L0_PW_3V3_ON(); + L2_GREEN_LED_ON(); +// // 音频播放 +// L2_WT2605B_PWRON(); +// Lc_delay_ms(1000); + L2_WT2605B_broadcast(&audio_TCP_connected); +// // OID和WIFI通电 +// L0_PW_3V3_ON(); } - else if (s->status == WIFI_CONFIG) - { - // LED红灯闪烁,LED绿灯灭 - RED_LED = ~RED_LED; - GREEN_LED = LED_OFF; - // 音频播放 - L2_WT2605B_PWRON(); - Lc_delay_ms(1000); -// L2_WT2605B_broadcast(&audio_Wifi_Config); - // OID和WIFI通电 - L0_PW_3V3_ON(); - } L2_task_go_Tdelay(D_task_DETECTCHANGE,D_Tdelay_300ms); + TTSS_Task_step(D_task_WIFICONFIG_STATUS01) + L2_RED_LED_ON(); + L2_task_go_Tdelay(D_task_WIFICONFIG_STATUS02,D_Tdelay_500ms); + TTSS_Task_step(D_task_WIFICONFIG_STATUS02) + L2_LED_OFF(); + L2_task_go_Tdelay(D_task_DETECTCHANGE,D_Tdelay_500ms); + + TTSS_Task_step(D_task_WIFICONN_STATUS01) + L2_GREEN_LED_ON(); + L2_task_go_Tdelay(D_task_WIFICONN_STATUS02,D_Tdelay_500ms); + TTSS_Task_step(D_task_WIFICONN_STATUS02) + L2_LED_OFF(); + L2_task_go_Tdelay(D_task_DETECTCHANGE,D_Tdelay_500ms); + TTSS_Task_end(); } \ No newline at end of file diff --git a/source/app/task_appstatus.h b/source/app/task_appstatus.h index c432b3b..b72c1c3 100644 --- a/source/app/task_appstatus.h +++ b/source/app/task_appstatus.h @@ -11,8 +11,8 @@ ////////////////////////////////////////////////////////////////////////////// -#ifndef _APPSTATUS_TASK_APPSTATUS_H -#define _APPSTATUS_TASK_APPSTATUS_H +#ifndef _TASK_APPSTATUS_H +#define _TASK_APPSTATUS_H #include "../ctask/task.h" #include "../clib/clib.h" diff --git a/source/bsp/bsp_WT2605B.c b/source/bsp/bsp_WT2605B.c index afc57c3..73413f6 100644 --- a/source/bsp/bsp_WT2605B.c +++ b/source/bsp/bsp_WT2605B.c @@ -2,16 +2,17 @@ #include "../msp/UART3.h" -TS_SPEECH_AUDIO audio_wellcome = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x31,0x8F,0xEF}; -TS_SPEECH_AUDIO audio_up = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x32,0x90,0xEF}; -TS_SPEECH_AUDIO audio_down = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x33,0x91,0xEF}; -TS_SPEECH_AUDIO audio_zmg = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x34,0x92,0xEF}; -TS_SPEECH_AUDIO audio_zbt = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x35,0x93,0xEF}; -TS_SPEECH_AUDIO audio_SchulteGrid = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x36,0x94,0xEF}; +TS_SPEECH_AUDIO audio_powerdown = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x31,0x8F,0xEF}; +TS_SPEECH_AUDIO audio_poweron = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x32,0x90,0xEF}; +TS_SPEECH_AUDIO audio_wifi_connected = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x33,0x91,0xEF}; +TS_SPEECH_AUDIO audio_TCP_connected = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x34,0x92,0xEF}; +TS_SPEECH_AUDIO audio_config_mode = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x35,0x93,0xEF}; +TS_SPEECH_AUDIO audio_config_success = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x36,0x94,0xEF}; + TS_SPEECH_AUDIO audio_select = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x37,0x95,0xEF}; TS_SPEECH_AUDIO audio_begin = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x38,0x96,0xEF}; TS_SPEECH_AUDIO audio_tip = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x39,0x97,0xEF}; -TS_SPEECH_AUDIO audio_powerdown = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x3A,0x98,0xEF}; +//TS_SPEECH_AUDIO audio_powerdown = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x3A,0x98,0xEF}; TS_SPEECH_AUDIO audio_zmg_again = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x3B,0x99,0xEF}; TS_SPEECH_AUDIO audio_zmg_success = {0x7E,0x07,0xA3,0x54,0x30,0x30,0x3C,0x9A,0xEF}; @@ -38,7 +39,7 @@ void L2_WT2605B_PWROFF() void L2_WT2605B_Broadcast(TS_SPEECH_AUDIO *music) { - L0_uart3_sendArray((U8 *)&music,9); + L0_uart3_sendArray((U8 *)music,9); } void L2_WT2605B_VioceUp(void) diff --git a/source/bsp/bsp_WT2605B.h b/source/bsp/bsp_WT2605B.h index 24a806c..a0b8d6d 100644 --- a/source/bsp/bsp_WT2605B.h +++ b/source/bsp/bsp_WT2605B.h @@ -25,12 +25,13 @@ typedef struct vU8 end; }TS_SPEECH_VOLUME; -extern TS_SPEECH_AUDIO audio_wellcome; -extern TS_SPEECH_AUDIO audio_up; -extern TS_SPEECH_AUDIO audio_down; -extern TS_SPEECH_AUDIO audio_zmg; -extern TS_SPEECH_AUDIO audio_zbt; -extern TS_SPEECH_AUDIO audio_SchulteGrid; +extern TS_SPEECH_AUDIO audio_powerdown; +extern TS_SPEECH_AUDIO audio_poweron; +extern TS_SPEECH_AUDIO audio_wifi_connected; +extern TS_SPEECH_AUDIO audio_TCP_connected; +extern TS_SPEECH_AUDIO audio_config_mode; +extern TS_SPEECH_AUDIO audio_config_success; + extern TS_SPEECH_AUDIO audio_select; extern TS_SPEECH_AUDIO audio_begin; extern TS_SPEECH_AUDIO audio_tip; diff --git a/source/bsp/bsp_config.c b/source/bsp/bsp_config.c index e97ddf2..75a9ca8 100644 --- a/source/bsp/bsp_config.c +++ b/source/bsp/bsp_config.c @@ -1,7 +1,7 @@ #include "bsp_config.h" -#include "../msp/msp_UART0.h" +// #include "../msp/msp_UART0.h" // #include "../msp/eeprom.h" -#include "../msp/msp_eeprom.h" +// #include "../msp/msp_eeprom.h" //////////////////////////////////////////////////////////////////////////// ///@copyright Copyright (c) 2018, 传控科技 All rights reserved. diff --git a/source/bsp/bsp_led.c b/source/bsp/bsp_led.c index becf369..cf4790f 100644 --- a/source/bsp/bsp_led.c +++ b/source/bsp/bsp_led.c @@ -2,15 +2,28 @@ void L2_led_init() { - D_HighI_P5(BITN5); + D_HighI_P2(BITN6); + D_HighI_P2(BITN7); + + GREEN_LED = LED_OFF; + RED_LED = LED_OFF; + +} + +void L2_GREEN_LED_ON(void) +{ + GREEN_LED = LED_ON; + RED_LED = LED_OFF; } -void L2_led_ON(u8 LED) +void L2_RED_LED_ON(void) { - LED = LED_ON; + GREEN_LED = LED_OFF; + RED_LED = LED_ON; } -void L2_led_OFF(u8 LED) +void L2_LED_OFF(void) { - LED = LED_OFF; + GREEN_LED = LED_OFF; + RED_LED = LED_OFF; } diff --git a/source/bsp/bsp_led.h b/source/bsp/bsp_led.h index 99f5eba..d2b8855 100644 --- a/source/bsp/bsp_led.h +++ b/source/bsp/bsp_led.h @@ -3,13 +3,17 @@ #include "bsp_config.h" -#define RED_LED P55 //单色绿灯 -#define GREEN_LED P26 //双色红灯 -#define LED_ON 1 -#define LED_OFF 0 +#define RED_LED P27 //双色红灯 +#define GREEN_LED P26 //双色绿灯 + +#define LED_ON 0 +#define LED_OFF 1 extern void L2_led_init(); +extern void L2_RED_LED_ON(); +extern void L2_GREEN_LED_ON(); +extern void L2_LED_OFF(); #endif \ No newline at end of file diff --git a/source/clib/clib.c b/source/clib/clib.c index 8e7de00..3ce59dc 100644 --- a/source/clib/clib.c +++ b/source/clib/clib.c @@ -13,7 +13,7 @@ #include "type.h" #include "clib.h" #include "../msp/uart0.h" -#include "../msp/time.h" +//#include "../msp/time.h" U8 Lc_strStartsWith(U8 *s1,U8 *s2) diff --git a/source/msp/msp_eeprom.c b/source/msp/msp_eeprom.c index 3a89cfa..073fd5a 100644 --- a/source/msp/msp_eeprom.c +++ b/source/msp/msp_eeprom.c @@ -28,7 +28,7 @@ fixme:注意时钟和flash 相关 同时关注掉电和容错 #include "msp_eeprom.h" -#include "debug_drv.h" +//#include "debug_drv.h" #if(TYPE_MCU == TYPE_MCU_STC_8A || TYPE_MCU == TYPE_MCU_STC_8F) xxx diff --git a/source/msp/msp_eeprom.h b/source/msp/msp_eeprom.h index b6015dc..43e2e2f 100644 --- a/source/msp/msp_eeprom.h +++ b/source/msp/msp_eeprom.h @@ -18,8 +18,8 @@ #ifndef _msp_eeprom_H_ #define _msp_eeprom_H_ -#include "c_type51.h" -#include "c_lib.h" +//#include "c_type51.h" +//#include "c_lib.h" ///>>>端口位定义,可修改!!!!!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>