sop板
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.
 
 
 
 

98 lines
2.5 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_nfc.h"
#include "../app/app_config.h"
#include "../bsp/bsp_config.h"
#include "../msp/uart0.h"
#include "../msp/uart2.h"
S_TASK_NFC _s_task_nfc;
//=============================================
void L3_task_nfc_init(void)
{
L1_task_init(&_s_task_nfc.task);
L3_task_s_go(_s_task_nfc,D_task_init);
}
#define D_task_NFC_READ 0x50
void L3_task_nfc_handler(S_TASK_NFC *s)
{
TTSS_Task_init()
L2_task_go(D_task_NFC_READ);
TTSS_Task_step(D_task_NFC_READ)
if(ts_uart[uNum2].r.ok == 1)
{
ts_uart[uNum2].r.ok = 0;
parse_nfc_pkg();
}
//send next
L2_task_go_Tdelay(D_task_NFC_READ, 0);
TTSS_Task_end();
}
//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[uNum2].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();
}