You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.6 KiB

////////////////////////////////////////////////////////////////////////////
///@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