From 7206e3545afc3924bb049d545056ff869a668959 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Fri, 26 Jul 2024 16:45:16 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96a5133=E9=A9=B1=E5=8A=A8?= =?utf8?q?=EF=BC=8C=E5=8E=BB=E9=99=A4=E6=97=A0=E6=95=88=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../drivers/peripheral/a5133/A5133Config.h | 57 +++++---- .../drivers/peripheral/a5133/A5133GlobalVar.h | 40 +++--- code/sdk/drivers/peripheral/a5133/A5133Main.c | 115 ++++++++++++------ .../drivers/peripheral/a5133/A5133define.h | 11 +- code/sdk/drivers/peripheral/a5133/A5133main.h | 9 +- .../drivers/peripheral/utils/custom_utils.c | 38 ++++++ .../drivers/peripheral/utils/custom_utils.h | 4 + 7 files changed, 184 insertions(+), 90 deletions(-) diff --git a/code/sdk/drivers/peripheral/a5133/A5133Config.h b/code/sdk/drivers/peripheral/a5133/A5133Config.h index 542cab859..c5e54d2cb 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133Config.h +++ b/code/sdk/drivers/peripheral/a5133/A5133Config.h @@ -5,7 +5,6 @@ ********************************************************************/ #ifndef _A5133CONFIG_h_ #define _A5133CONFIG_h_ -#define code /************************************ * Define DR ************************************/ @@ -15,7 +14,7 @@ //#define DR_500Kbps //IF=1MHz #ifdef DR_4Mbps -const Uint8 code A5133_RFConfigTab_Main[]= +const Uint8 A5133_RFConfigTab_Main[]= { 0x00, //RESET register, 0x62, //MODE register, @@ -83,7 +82,7 @@ const Uint8 code A5133_RFConfigTab_Main[]= 0x00 //USID register, }; -const Uint8 code A5133_RFConfigTab_Addr0x20[]= +const Uint8 A5133_RFConfigTab_Addr0x20[]= { 0x0C, //page0, //去掉preamble 0x00, //page1, @@ -100,7 +99,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x21[]= +const Uint8 A5133_RFConfigTab_Addr0x21[]= { 0x09, //page0, 0x00, //page1, @@ -117,7 +116,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]= 0x56 //page12 crystal type 3225, CL=9pF, CSXTL=108 }; -const Uint8 code A5133_RFConfigTab_Addr0x22[]= +const Uint8 A5133_RFConfigTab_Addr0x22[]= { 0x00, //page0, 0x10, //page1, @@ -127,7 +126,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]= 0x04 //page5, }; -const Uint8 code A5133_RFConfigTab_Addr0x2A[]= +const Uint8 A5133_RFConfigTab_Addr0x2A[]= { 0x00, //page0, 0x01, //page1, @@ -144,7 +143,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x38[]= +const Uint8 A5133_RFConfigTab_Addr0x38[]= { 0x80, //page0, 0x50, //page1, @@ -160,7 +159,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]= 0x00 //page11, }; -const Uint8 code ACQ_Tab[]= +const Uint8 ACQ_Tab[]= { 0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00, //0c00~0x0F, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0, @@ -170,7 +169,7 @@ const Uint8 code ACQ_Tab[]= #endif /* end of DR_4Mbps */ #ifdef DR_2Mbps -const Uint8 code A5133_RFConfigTab_Main[]= +const Uint8 A5133_RFConfigTab_Main[]= { 0x00, //RESET register, 0x62, //MODE register, @@ -238,7 +237,7 @@ const Uint8 code A5133_RFConfigTab_Main[]= 0x00 //USID register, }; -const Uint8 code A5133_RFConfigTab_Addr0x20[]= +const Uint8 A5133_RFConfigTab_Addr0x20[]= { 0x0E, //page0, 0x00, //page1, @@ -255,7 +254,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x21[]= +const Uint8 A5133_RFConfigTab_Addr0x21[]= { 0x09, //page0, 0x00, //page1, @@ -272,7 +271,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]= 0x56 //page12 }; -const Uint8 code A5133_RFConfigTab_Addr0x22[]= +const Uint8 A5133_RFConfigTab_Addr0x22[]= { 0x00, //page0, 0x10, //page1, @@ -282,7 +281,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]= 0x04 //page5, }; -const Uint8 code A5133_RFConfigTab_Addr0x2A[]= +const Uint8 A5133_RFConfigTab_Addr0x2A[]= { 0x00, //page0, 0x01, //page1, @@ -299,7 +298,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x38[]= +const Uint8 A5133_RFConfigTab_Addr0x38[]= { 0x80, //page0, 0x50, //page1, @@ -315,7 +314,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]= 0x00 //page11, }; -const Uint8 code ACQ_Tab[]= +const Uint8 ACQ_Tab[]= { 0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00, //0c00~0x0F, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0, @@ -326,7 +325,7 @@ const Uint8 code ACQ_Tab[]= #ifdef DR_1Mbps -const Uint8 code A5133_RFConfigTab_Main[]= +const Uint8 A5133_RFConfigTab_Main[]= { 0x00, //RESET register, 0x62, //MODE register, @@ -394,7 +393,7 @@ const Uint8 code A5133_RFConfigTab_Main[]= 0x00 //USID register, }; -const Uint8 code A5133_RFConfigTab_Addr0x20[]= +const Uint8 A5133_RFConfigTab_Addr0x20[]= { 0x0E, //page0, 0x00, //page1, @@ -411,7 +410,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x21[]= +const Uint8 A5133_RFConfigTab_Addr0x21[]= { 0x09, //page0, 0x00, //page1, @@ -428,7 +427,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]= 0x56 //page12 }; -const Uint8 code A5133_RFConfigTab_Addr0x22[]= +const Uint8 A5133_RFConfigTab_Addr0x22[]= { 0x00, //page0, 0x10, //page1, @@ -438,7 +437,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]= 0x04 //page5, }; -const Uint8 code A5133_RFConfigTab_Addr0x2A[]= +const Uint8 A5133_RFConfigTab_Addr0x2A[]= { 0x00, //page0, 0x01, //page1, @@ -455,7 +454,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x38[]= +const Uint8 A5133_RFConfigTab_Addr0x38[]= { 0x80, //page0, 0x50, //page1, @@ -471,7 +470,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]= 0x00 //page11, }; -const Uint8 code ACQ_Tab[]= +const Uint8 ACQ_Tab[]= { 0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00, //0c00~0x0F, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0, @@ -481,7 +480,7 @@ const Uint8 code ACQ_Tab[]= #endif /* end of DR_1Mbps */ #ifdef DR_500Kbps -const Uint8 code A5133_RFConfigTab_Main[]= +const Uint8 A5133_RFConfigTab_Main[]= { 0x00, //RESET register, 0x62, //MODE register, @@ -549,7 +548,7 @@ const Uint8 code A5133_RFConfigTab_Main[]= 0x00 //USID register, }; -const Uint8 code A5133_RFConfigTab_Addr0x20[]= +const Uint8 A5133_RFConfigTab_Addr0x20[]= { 0x0E, //page0, 0x00, //page1, @@ -566,7 +565,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x21[]= +const Uint8 A5133_RFConfigTab_Addr0x21[]= { 0x09, //page0, 0x00, //page1, @@ -583,7 +582,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]= 0x56 //page12 }; -const Uint8 code A5133_RFConfigTab_Addr0x22[]= +const Uint8 A5133_RFConfigTab_Addr0x22[]= { 0x00, //page0, 0x10, //page1, @@ -593,7 +592,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]= 0x04 //page5, }; -const Uint8 code A5133_RFConfigTab_Addr0x2A[]= +const Uint8 A5133_RFConfigTab_Addr0x2A[]= { 0x00, //page0, 0x01, //page1, @@ -610,7 +609,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]= 0x00 //page12, }; -const Uint8 code A5133_RFConfigTab_Addr0x38[]= +const Uint8 A5133_RFConfigTab_Addr0x38[]= { 0x80, //page0, 0x50, //page1, @@ -626,7 +625,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]= 0x00 //page11, }; -const Uint8 code ACQ_Tab[]= +const Uint8 ACQ_Tab[]= { 0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00, //0c00~0x0F, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0, diff --git a/code/sdk/drivers/peripheral/a5133/A5133GlobalVar.h b/code/sdk/drivers/peripheral/a5133/A5133GlobalVar.h index 10be5de8b..d6f7e3bb8 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133GlobalVar.h +++ b/code/sdk/drivers/peripheral/a5133/A5133GlobalVar.h @@ -43,27 +43,27 @@ const Uint8 code PN9_Tab[]= /************************************************************************ ** Extern Global Variable Declaration ************************************************************************/ -extern Uint8 data timer; -extern Uint16 data TimerCnt; -extern Uint8 data Slot_TX; -extern Uint8 data Flag_Timeout; -extern Uint16 idata RxCnt; -extern Uint8 data *Uartptr; -extern Uint8 data UartSendCnt; -extern Uint8 data CmdBuf[25]; -extern Uint8 idata tmpbuf[80]; -extern Uint16 idata Err_Loss; -extern Uint16 idata Err_Frame; -extern Uint32 idata Err_BitCnt; -extern Uint8 data Flag_Report; -extern Uint8 idata Flag_FirstLink; -extern Uint8 data Flag_MASTER; +extern Uint8 timer; +extern Uint16 TimerCnt; +extern Uint8 Slot_TX; +extern Uint8 Flag_Timeout; +extern Uint16 RxCnt; +extern Uint8 *Uartptr; +extern Uint8 UartSendCnt; +extern Uint8 CmdBuf[25]; +extern Uint8 tmpbuf[80]; +extern Uint16 Err_Loss; +extern Uint16 Err_Frame; +extern Uint32 Err_BitCnt; +extern Uint8 Flag_Report; +extern Uint8 Flag_FirstLink; +extern Uint8 Flag_MASTER; -extern const Uint8 code BitCount_Tab[16]; -extern const Uint8 code ID_Tab[8]; -extern const Uint8 code KeyData_Tab[]; -extern const Uint8 code FCB_Tab[]; -extern const Uint8 code PN9_Tab[]; +extern const Uint8 BitCount_Tab[16]; +extern const Uint8 ID_Tab[8]; +extern const Uint8 KeyData_Tab[]; +extern const Uint8 FCB_Tab[]; +extern const Uint8 PN9_Tab[]; #endif diff --git a/code/sdk/drivers/peripheral/a5133/A5133Main.c b/code/sdk/drivers/peripheral/a5133/A5133Main.c index 0286212b0..0d613e151 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133Main.c +++ b/code/sdk/drivers/peripheral/a5133/A5133Main.c @@ -37,8 +37,6 @@ static void nop(void){} -#define idata - /********************************************************************* ** Constant Declaration *********************************************************************/ @@ -49,35 +47,33 @@ static void nop(void){} /************************************************************************ ** Global Variable Declaration ************************************************************************/ -Uint8 data timer; -Uint16 data TimerCnt; -Uint8 data Slot_TX; -Uint8 data Flag_Timeout; -Uint16 idata RxCnt; -Uint8 data *Uartptr; -// Uint8 data UartSendCnt; -Uint8 data CmdBuf[25]; -Uint8 idata tmpbuf[80]; -Uint16 idata Err_Loss; -Uint16 idata Err_Frame; -Uint32 idata Err_BitCnt; -// Uint8 data Flag_Report; -// Uint8 idata Flag_FirstLink; -// Uint8 idata Flag_MASTER; -Uint8 idata Mem_RH; -Uint8 idata Mem_RL; - -const Uint8 code BitCount_Tab[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4}; +Uint8 timer; +Uint16 TimerCnt; +Uint8 Slot_TX; +Uint8 Flag_Timeout; +Uint16 RxCnt; +Uint8 *Uartptr; + +Uint8 CmdBuf[25]; +Uint8 tmpbuf[80]; +Uint16 Err_Loss; +Uint16 Err_Frame; +Uint32 Err_BitCnt; + +Uint8 Mem_RH; +Uint8 Mem_RL; + +const Uint8 BitCount_Tab[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4}; // const Uint8 code ID_Tab[8]={0xC3,0x3C,0x95,0x6A,0x36,0x75,0xC5,0x2A};//ID code // const Uint8 code ID_Tab[8]={0xAA,0xAA,0xAA,0xAA,0xCC,0xCC,0xAA,0xAA}; -const Uint8 code ID_Tab[8]={0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55}; +const Uint8 ID_Tab[8]={0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55}; //const Uint8 //code ID_Tab[8]={0x34,0x75,0xC5,0x2A,0xC7,0x33,0x45,0xEA};//ID code //const Uint8 code ID_Tab[8]={0x55,0x55,0x55,0x55,0x34,0x75,0xC5,0x6A}; //ID2 code //const Uint8 code ID_Tab[8]={0xFF,0xFF,0xFF,0xFF,0x36,0x75,0xC5,0xBA}; //ID2 code //const Uint8 code ID_Tab[8]={0x34,0x75,0xC5,0x2A,0x34,0x75,0xC5,0x2A}; //ID2 code -const Uint8 code KeyData_Tab[16]={0x00,0x00,0x00,0x00,0x00,0x0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //keyData code -const Uint8 code FCB_Tab[20]={0x00,0x00,0x00,0x00,0x00,0x15,0x20,0x25,0x30,0x35,0x40,0x45,0x50,0x55,0x60,0x65,0x70,0x75,0x80,0x85}; //keyData code -const Uint8 code PN9_Tab[]= +const Uint8 KeyData_Tab[16]={0x00,0x00,0x00,0x00,0x00,0x0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //keyData code +const Uint8 FCB_Tab[20]={0x00,0x00,0x00,0x00,0x00,0x15,0x20,0x25,0x30,0x35,0x40,0x45,0x50,0x55,0x60,0x65,0x70,0x75,0x80,0x85}; //keyData code +const Uint8 PN9_Tab[]= { 0xFF,0x83,0xDF,0x17,0x32,0x09,0x4E,0xD1, 0xE7,0xCD,0x8A,0x91,0xC6,0xD5,0xC4,0xC4, 0x40,0x21,0x18,0x4E,0x55,0x86,0xF4,0xDC, @@ -91,8 +87,38 @@ const Uint8 code PN9_Tab[]= /********************************************************************* * main loop *********************************************************************/ + +static uint8_t send_data[2][64] = {0}; +static uint8_t send_data_index = 0; + +errcode_t a5133_set_send_data(uint8_t *senddata,uint8_t datalen) +{ + if ( datalen > 62 || datalen == 0 || senddata == NULL) + return ERRCODE_FAIL; + + if (send_data_index == 0) + { + memset(send_data[1],0,64); + memcpy(send_data,senddata,datalen); + uint16_t crc = CRC16_XMODEM(send_data[1],62); + send_data[1][62] = ((uint8_t*)&crc)[0]; + send_data[1][63] = ((uint8_t*)&crc)[1]; + send_data_index = 1; + }else{ + memset(send_data[0],0,64); + memcpy(send_data,senddata,datalen); + uint16_t crc = CRC16_XMODEM(send_data[0],62); + send_data[0][62] = ((uint8_t*)&crc)[0]; + send_data[0][63] = ((uint8_t*)&crc)[1]; + send_data_index = 0; + } + + return ERRCODE_SUCC; + +} void a5133_main(Uint8 Flag_MASTER,uint8_t channel) { + a5133_power_on(); if(RF_Init())/* init RF */ { @@ -131,7 +157,7 @@ void a5133_main(Uint8 Flag_MASTER,uint8_t channel) while(1) { - RF_FIFOWrite(64);/* write data to tx fifo */ + RF_FIFOWrite(send_data[send_data_index],64);/* write data to tx fifo */ if(RF_LVR_Check())/* check if BOD reset has occurred */ break;/* exit loop & re-RF init */ else @@ -204,7 +230,7 @@ void a5133_main(Uint8 Flag_MASTER,uint8_t channel) }; RxPacket(); - RF_FIFOWrite(64); + RF_FIFOWrite(PN9_Tab,64); if(RF_LVR_Check())/* check if BOD reset has occurred */ break;/* exit loop & re-RF init */ else @@ -424,7 +450,7 @@ Uint8 RF_Init(void) /********************************************************************* ** RF_FIFOWrite *********************************************************************/ -void RF_FIFOWrite(Uint8 len) +void RF_FIFOWrite(unsigned char *send_data,Uint8 len) { Uint8 i; @@ -432,7 +458,9 @@ void RF_FIFOWrite(Uint8 len) a5133_gpio_scs_set_value(0); ByteSend(FIFO_REG);//send address 0x05, bit7 cmd=0, bit6 r/w=0 for(i=0; i >4] + BitCount_Tab[tmp & 0x0F]); - err=1; - } + // if((recv ^ PN9_Tab[i])!=0) + // { + // tmp = recv ^ PN9_Tab[i]; + // Err_BitCnt += (BitCount_Tab[tmp>>4] + BitCount_Tab[tmp & 0x0F]); + // err=1; + // } } + //crccheck + a5133_gpio_scs_set_value(1); + uint16_t crc = CRC16_XMODEM(tmpbuf,62); + uint16_t recv_crc = *(uint16_t*)&tmpbuf[62]; + PRINT("crc[%X] , recv_crc %X\n",crc,recv_crc); + if ( crc != recv_crc) + { + err = 1; + } printf("=====RxPacket \n"); dump_tmpbuf(); if (err)//packet error @@ -883,7 +926,7 @@ void main_prog_ACK(Uint8 Flag_MASTER) while(1) { - RF_FIFOWrite(64); /* write data to tx fifo */ + RF_FIFOWrite(PN9_Tab,64); /* write data to tx fifo */ if(RF_LVR_Check())/* check if BOD reset has occurred */ break;/* exit loop & re-RF init */ else diff --git a/code/sdk/drivers/peripheral/a5133/A5133define.h b/code/sdk/drivers/peripheral/a5133/A5133define.h index 7df6f53d7..97a3a124d 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133define.h +++ b/code/sdk/drivers/peripheral/a5133/A5133define.h @@ -1,3 +1,13 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-07-20 10:36:21 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-26 15:48:42 + * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133define.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ /***************************************************************************** ** ** ** AMIC Proprietary Document ** @@ -16,7 +26,6 @@ #include // #include #include -#define data #define Sint8 signed char #define Sint16 signed int diff --git a/code/sdk/drivers/peripheral/a5133/A5133main.h b/code/sdk/drivers/peripheral/a5133/A5133main.h index 4ba748733..40bbc5506 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133main.h +++ b/code/sdk/drivers/peripheral/a5133/A5133main.h @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: 2024-07-20 10:36:21 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-23 18:49:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-26 14:41:31 * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133main.h * @Description: * @@ -54,7 +54,7 @@ errcode_t ByteSend(Uint8 src); Uint8 ByteRead(void); void RF_SetCH(Uint8); Uint8 RF_Init(void); -void RF_FIFOWrite(Uint8); +void RF_FIFOWrite(unsigned char *send_data,Uint8 len); void RF_StrobeCmd(Uint8); void RxPacket(void); Uint8 RF_Cal_CHGroup(Uint8 ch); @@ -73,5 +73,6 @@ Uint8 Is_Vpoak(void); void main_prog_ACK(Uint8 Flag_MASTER); void RF_TXPower(Uint8 tbf, Uint8 tpa); void a5133_main(Uint8 Flag_MASTER,uint8_t channel); - +void a5133_get_rxdata(uint8_t *databuf,uint8_t len); +errcode_t a5133_set_send_data(uint8_t *senddata,uint8_t datalen); #endif \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 52861ea12..37a7840e2 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -60,6 +60,10 @@ #include "mag_service.h" #include "ppg_service.h" +#ifdef SUPPORT_A5133_SERVICE +#include "A5133main.h" +#endif + errcode_t uapi_create_osThread_custom(app_task_definition_t *task_cfg) { if (task_cfg==NULL) @@ -2530,4 +2534,38 @@ void uapi_aging_test(uint32_t test_time) uint8_t uapi_get_cywee_static_state(void) { return cywee_get_static_state(); +} + +void uapi_get_a5133_rxdata(uint8_t *databuf,uint8_t len) +{ +#ifdef SUPPORT_A5133_SERVICE + a5133_get_rxdata(databuf,len); +#endif +} + + +uint16_t CRC16_XMODEM(uint8_t *bytes,uint16_t length) +{ + uint16_t crc = 0x0000; // initial value + int polynomial = 0x1021; + for (int index = 0; index < length; index++) { + uint8_t b = bytes[index]; + for (int i = 0; i < 8; i++) { + uint8_t bit = ((b >> (7 - i) & 1) == 1); + uint8_t c15 = ((crc >> 15 & 1) == 1); + crc <<= 1; + if (c15 ^ bit) crc ^= polynomial; + } + } + crc &= 0xffff; + return crc; +} + +errcode_t uapi_a5133_set_send_data(uint8_t *senddata,uint8_t datalen) +{ +#ifdef SUPPORT_A5133_SERVICE + return a5133_set_send_data(senddata,datalen); +#else + return ERRCODE_SUCC; +#endif } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index e9e5809e1..b00a4eb9f 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -238,6 +238,10 @@ uint8_t uapi_get_cywee_active_state(void); void uapi_get_file_data(char *path,uint8_t *data,uint8_t len); void uapi_save_file_data(char *path,uint8_t *data,uint8_t len); uint8_t uapi_get_cywee_static_state(void); +void uapi_get_a5133_rxdata(uint8_t *databuf,uint8_t len); +uint16_t CRC16_XMODEM(uint8_t *bytes,uint16_t length); +errcode_t uapi_a5133_set_send_data(uint8_t *senddata,uint8_t datalen); + #include "custom_utilscpp.h" -- 2.17.1