Merge #590 into sdk602patch0626 from refs/changes/590/head 591/target/1 592/target/1 593/target/1
author彭磊 <1624952103@qq.com>
Fri, 26 Jul 2024 08:50:41 +0000 (08:50 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Fri, 26 Jul 2024 08:50:41 +0000 (08:50 +0000)
优化a5133驱动,去除无效字段

* refs/changes/590/head: (2 commits squashed)

  - 优化a5133驱动,去除无效字段

  - 修复编译问题

Signed-off-by: aliyun6865282430 <1624952103@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/590
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/drivers/peripheral/a5133/A5133Config.h
code/sdk/drivers/peripheral/a5133/A5133GlobalVar.h
code/sdk/drivers/peripheral/a5133/A5133Main.c
code/sdk/drivers/peripheral/a5133/A5133define.h
code/sdk/drivers/peripheral/a5133/A5133main.h
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index 81a20fa..7b1c961 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-07-24 09:39:01\r
+ * @LastEditTime: 2024-07-26 16:46:54\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -85,22 +85,6 @@ static uint32_t aging_time = 0;
 static uint8_t pwr_button_result = 0;\r
 static uint8_t func_button_result = 1;\r
 \r
-\r
-static int CRC16_XMODEM(uint8_t *bytes,uint16_t length) {\r
-    int crc = 0x0000;          // initial value\r
-    int polynomial = 0x1021;\r
-    for (int index = 0; index < length; index++) {\r
-        uint8_t b = bytes[index];\r
-        for (int i = 0; i < 8; i++) {\r
-            uint8_t bit = ((b >> (7 - i) & 1) == 1);\r
-            uint8_t c15 = ((crc >> 15 & 1) == 1);\r
-            crc <<= 1;\r
-            if (c15 ^ bit) crc ^= polynomial;\r
-        }\r
-    }\r
-    crc &= 0xffff;\r
-    return crc;\r
-}\r
 errcode_t factorytest_protocol_replymsg(uint8_t mode, uint8_t submode,uint8_t testitem,\r
                                 uint8_t *input_data,uint16_t input_len)\r
 {\r
index 542cab8..c5e54d2 100644 (file)
@@ -5,7 +5,6 @@
 ********************************************************************/\r
 #ifndef _A5133CONFIG_h_\r
 #define _A5133CONFIG_h_\r
-#define code \r
 /************************************\r
 * Define DR\r
 ************************************/\r
@@ -15,7 +14,7 @@
 //#define DR_500Kbps     //IF=1MHz\r
 \r
 #ifdef DR_4Mbps\r
-const Uint8 code A5133_RFConfigTab_Main[]=\r
+const Uint8 A5133_RFConfigTab_Main[]=\r
 {\r
        0x00, //RESET register,                 \r
        0x62, //MODE register, \r
@@ -83,7 +82,7 @@ const Uint8 code A5133_RFConfigTab_Main[]=
        0x00  //USID register,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x20[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x20[]=\r
 {\r
        0x0C, //page0,  //去掉preamble\r
        0x00, //page1,  \r
@@ -100,7 +99,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]=
        0x00  //page12, \r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x21[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x21[]=\r
 {\r
        0x09, //page0, \r
        0x00, //page1,  \r
@@ -117,7 +116,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]=
        0x56  //page12 crystal type 3225, CL=9pF, CSXTL=108\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x22[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x22[]=\r
 {\r
        0x00, //page0, \r
        0x10, //page1,\r
@@ -127,7 +126,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]=
        0x04  //page5,  \r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x2A[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x2A[]=\r
 {\r
        0x00, //page0, \r
        0x01, //page1,  \r
@@ -144,7 +143,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x38[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x38[]=\r
 {\r
        0x80, //page0,\r
        0x50, //page1,\r
@@ -160,7 +159,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]=
        0x00  //page11,\r
 };  \r
 \r
-const Uint8 code ACQ_Tab[]=\r
+const Uint8  ACQ_Tab[]=\r
 {\r
        0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00,  //0c00~0x0F,\r
   0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0,\r
@@ -170,7 +169,7 @@ const Uint8 code ACQ_Tab[]=
 #endif /* end of DR_4Mbps */\r
 \r
 #ifdef DR_2Mbps\r
-const Uint8 code A5133_RFConfigTab_Main[]=\r
+const Uint8  A5133_RFConfigTab_Main[]=\r
 {\r
        0x00, //RESET register,                 \r
        0x62, //MODE register, \r
@@ -238,7 +237,7 @@ const Uint8 code A5133_RFConfigTab_Main[]=
        0x00  //USID register,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x20[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x20[]=\r
 {\r
        0x0E, //page0, \r
        0x00, //page1,  \r
@@ -255,7 +254,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x21[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x21[]=\r
 {\r
        0x09, //page0, \r
        0x00, //page1,  \r
@@ -272,7 +271,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]=
        0x56  //page12\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x22[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x22[]=\r
 {\r
        0x00, //page0, \r
        0x10, //page1,\r
@@ -282,7 +281,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]=
        0x04  //page5,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x2A[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x2A[]=\r
 {\r
        0x00, //page0, \r
        0x01, //page1,  \r
@@ -299,7 +298,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x38[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x38[]=\r
 {\r
        0x80, //page0,\r
        0x50, //page1,\r
@@ -315,7 +314,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]=
        0x00  //page11,\r
 };\r
 \r
-const Uint8 code ACQ_Tab[]=\r
+const Uint8  ACQ_Tab[]=\r
 {\r
   0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00,  //0c00~0x0F,\r
   0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0,\r
@@ -326,7 +325,7 @@ const Uint8 code ACQ_Tab[]=
 \r
 \r
 #ifdef DR_1Mbps\r
-const Uint8 code A5133_RFConfigTab_Main[]=\r
+const Uint8  A5133_RFConfigTab_Main[]=\r
 {\r
        0x00, //RESET register,                 \r
        0x62, //MODE register, \r
@@ -394,7 +393,7 @@ const Uint8 code A5133_RFConfigTab_Main[]=
        0x00  //USID register,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x20[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x20[]=\r
 {\r
        0x0E, //page0, \r
        0x00, //page1,  \r
@@ -411,7 +410,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x21[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x21[]=\r
 {\r
        0x09, //page0, \r
        0x00, //page1,  \r
@@ -428,7 +427,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]=
        0x56  //page12\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x22[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x22[]=\r
 {\r
        0x00, //page0, \r
        0x10, //page1,\r
@@ -438,7 +437,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]=
        0x04  //page5,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x2A[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x2A[]=\r
 {\r
        0x00, //page0, \r
        0x01, //page1,  \r
@@ -455,7 +454,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x38[]=\r
+const Uint8  A5133_RFConfigTab_Addr0x38[]=\r
 {\r
        0x80, //page0,\r
        0x50, //page1,\r
@@ -471,7 +470,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]=
        0x00  //page11,\r
 };\r
 \r
-const Uint8 code ACQ_Tab[]=\r
+const Uint8  ACQ_Tab[]=\r
 {\r
        0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00,  //0c00~0x0F,\r
   0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0,\r
@@ -481,7 +480,7 @@ const Uint8 code ACQ_Tab[]=
 #endif /* end of DR_1Mbps */\r
 \r
 #ifdef DR_500Kbps \r
-const Uint8 code A5133_RFConfigTab_Main[]=\r
+const Uint8  A5133_RFConfigTab_Main[]=\r
 {\r
        0x00, //RESET register,         \r
        0x62, //MODE register, \r
@@ -549,7 +548,7 @@ const Uint8 code A5133_RFConfigTab_Main[]=
        0x00  //USID register,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x20[]=\r
+const Uint8 A5133_RFConfigTab_Addr0x20[]=\r
 {\r
        0x0E, //page0,\r
        0x00, //page1,  \r
@@ -566,7 +565,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x20[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x21[]=\r
+const Uint8 A5133_RFConfigTab_Addr0x21[]=\r
 {\r
        0x09, //page0,\r
        0x00, //page1,  \r
@@ -583,7 +582,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x21[]=
        0x56  //page12\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x22[]=\r
+const Uint8 A5133_RFConfigTab_Addr0x22[]=\r
 {\r
        0x00, //page0, \r
        0x10, //page1,\r
@@ -593,7 +592,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x22[]=
        0x04  //page5,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x2A[]=\r
+const Uint8 A5133_RFConfigTab_Addr0x2A[]=\r
 {\r
        0x00, //page0,\r
        0x01, //page1,  \r
@@ -610,7 +609,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x2A[]=
        0x00  //page12,\r
 };\r
 \r
-const Uint8 code A5133_RFConfigTab_Addr0x38[]=\r
+const Uint8 A5133_RFConfigTab_Addr0x38[]=\r
 {\r
        0x80, //page0,\r
        0x50, //page1,\r
@@ -626,7 +625,7 @@ const Uint8 code A5133_RFConfigTab_Addr0x38[]=
        0x00  //page11,\r
 };\r
 \r
-const Uint8 code ACQ_Tab[]=\r
+const Uint8 ACQ_Tab[]=\r
 {\r
        0x03,0x50, 0x03,0x50, 0x03,0x50, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x40, 0x03,0x00,  //0c00~0x0F,\r
   0x03,0x40, 0x03,0x40, 0x03,0x40, 0x02,0xB0, 0x03,0x20, 0x02,0xc0, 0x02,0x80, 0x03,0xF0,\r
index 10be5de..d6f7e3b 100644 (file)
@@ -43,27 +43,27 @@ const Uint8 code PN9_Tab[]=
 /************************************************************************\r
 **  Extern Global Variable Declaration\r
 ************************************************************************/\r
-extern Uint8   data       timer;\r
-extern Uint16  data     TimerCnt;\r
-extern Uint8   data     Slot_TX;\r
-extern Uint8   data       Flag_Timeout;\r
-extern Uint16  idata   RxCnt;\r
-extern Uint8   data    *Uartptr;\r
-extern Uint8   data       UartSendCnt;\r
-extern Uint8   data       CmdBuf[25];\r
-extern Uint8   idata      tmpbuf[80];\r
-extern Uint16  idata   Err_Loss;\r
-extern Uint16  idata    Err_Frame;\r
-extern Uint32  idata      Err_BitCnt;\r
-extern Uint8   data       Flag_Report;\r
-extern Uint8   idata    Flag_FirstLink;\r
-extern Uint8   data       Flag_MASTER;\r
+extern Uint8              timer;\r
+extern Uint16       TimerCnt;\r
+extern Uint8        Slot_TX;\r
+extern Uint8              Flag_Timeout;\r
+extern Uint16          RxCnt;\r
+extern Uint8       *Uartptr;\r
+extern Uint8              UartSendCnt;\r
+extern Uint8              CmdBuf[25];\r
+extern Uint8              tmpbuf[80];\r
+extern Uint16          Err_Loss;\r
+extern Uint16      Err_Frame;\r
+extern Uint32             Err_BitCnt;\r
+extern Uint8              Flag_Report;\r
+extern Uint8       Flag_FirstLink;\r
+extern Uint8              Flag_MASTER;\r
 \r
-extern  const Uint8 code BitCount_Tab[16];\r
-extern  const Uint8 code ID_Tab[8];\r
-extern  const Uint8 code KeyData_Tab[];\r
-extern  const Uint8 code FCB_Tab[];\r
-extern  const Uint8 code PN9_Tab[];\r
+extern  const Uint8  BitCount_Tab[16];\r
+extern  const Uint8  ID_Tab[8];\r
+extern  const Uint8  KeyData_Tab[];\r
+extern  const Uint8  FCB_Tab[];\r
+extern  const Uint8  PN9_Tab[];\r
 \r
 #endif\r
 \r
index 0286212..0d613e1 100644 (file)
@@ -37,8 +37,6 @@
 \r
 static void nop(void){}\r
 \r
-#define idata\r
-\r
 /*********************************************************************\r
 **  Constant Declaration\r
 *********************************************************************/\r
@@ -49,35 +47,33 @@ static void nop(void){}
 /************************************************************************\r
 **  Global Variable Declaration\r
 ************************************************************************/\r
-Uint8  data     timer;\r
-Uint16  data     TimerCnt;\r
-Uint8  data     Slot_TX;\r
-Uint8  data     Flag_Timeout;\r
-Uint16 idata    RxCnt;\r
-Uint8   data     *Uartptr;\r
-// Uint8       data     UartSendCnt;\r
-Uint8  data     CmdBuf[25];\r
-Uint8  idata    tmpbuf[80];\r
-Uint16 idata    Err_Loss;\r
-Uint16  idata    Err_Frame;\r
-Uint32 idata    Err_BitCnt;\r
-// Uint8       data     Flag_Report;\r
-// Uint8   idata    Flag_FirstLink;\r
-// Uint8   idata    Flag_MASTER;\r
-Uint8   idata    Mem_RH;\r
-Uint8   idata    Mem_RL;\r
-\r
-const Uint8 code BitCount_Tab[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};\r
+Uint8           timer;\r
+Uint16       TimerCnt;\r
+Uint8       Slot_TX;\r
+Uint8           Flag_Timeout;\r
+Uint16          RxCnt;\r
+Uint8        *Uartptr;\r
+\r
+Uint8           CmdBuf[25];\r
+Uint8           tmpbuf[80];\r
+Uint16          Err_Loss;\r
+Uint16      Err_Frame;\r
+Uint32          Err_BitCnt;\r
+\r
+Uint8       Mem_RH;\r
+Uint8       Mem_RL;\r
+\r
+const Uint8  BitCount_Tab[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};\r
 // const Uint8 code ID_Tab[8]={0xC3,0x3C,0x95,0x6A,0x36,0x75,0xC5,0x2A};//ID code\r
 // const Uint8 code ID_Tab[8]={0xAA,0xAA,0xAA,0xAA,0xCC,0xCC,0xAA,0xAA};\r
-const Uint8 code ID_Tab[8]={0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55};\r
+const Uint8  ID_Tab[8]={0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55};\r
 //const Uint8 //code ID_Tab[8]={0x34,0x75,0xC5,0x2A,0xC7,0x33,0x45,0xEA};//ID code\r
 //const Uint8 code ID_Tab[8]={0x55,0x55,0x55,0x55,0x34,0x75,0xC5,0x6A}; //ID2 code\r
 //const Uint8 code ID_Tab[8]={0xFF,0xFF,0xFF,0xFF,0x36,0x75,0xC5,0xBA}; //ID2 code\r
 //const Uint8 code ID_Tab[8]={0x34,0x75,0xC5,0x2A,0x34,0x75,0xC5,0x2A}; //ID2 code\r
-const Uint8 code KeyData_Tab[16]={0x00,0x00,0x00,0x00,0x00,0x0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //keyData code\r
-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\r
-const Uint8 code PN9_Tab[]=\r
+const Uint8  KeyData_Tab[16]={0x00,0x00,0x00,0x00,0x00,0x0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //keyData code\r
+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\r
+const Uint8  PN9_Tab[]=\r
 {   0xFF,0x83,0xDF,0x17,0x32,0x09,0x4E,0xD1,\r
     0xE7,0xCD,0x8A,0x91,0xC6,0xD5,0xC4,0xC4,\r
     0x40,0x21,0x18,0x4E,0x55,0x86,0xF4,0xDC,\r
@@ -91,8 +87,38 @@ const Uint8 code PN9_Tab[]=
 /*********************************************************************\r
 * main loop\r
 *********************************************************************/\r
+\r
+static uint8_t send_data[2][64] = {0};\r
+static uint8_t send_data_index = 0;\r
+\r
+errcode_t a5133_set_send_data(uint8_t *senddata,uint8_t datalen)\r
+{\r
+       if ( datalen > 62 || datalen == 0  || senddata == NULL)\r
+               return ERRCODE_FAIL;\r
+\r
+       if (send_data_index == 0)\r
+       {\r
+               memset(send_data[1],0,64);\r
+               memcpy(send_data,senddata,datalen);\r
+               uint16_t crc =  CRC16_XMODEM(send_data[1],62); \r
+               send_data[1][62] = ((uint8_t*)&crc)[0];\r
+               send_data[1][63] = ((uint8_t*)&crc)[1];\r
+               send_data_index = 1;\r
+       }else{\r
+               memset(send_data[0],0,64);\r
+               memcpy(send_data,senddata,datalen);\r
+               uint16_t crc =  CRC16_XMODEM(send_data[0],62); \r
+               send_data[0][62] = ((uint8_t*)&crc)[0];\r
+               send_data[0][63] = ((uint8_t*)&crc)[1];\r
+               send_data_index = 0;\r
+       }\r
+\r
+       return ERRCODE_SUCC;\r
+\r
+}\r
 void a5133_main(Uint8 Flag_MASTER,uint8_t channel)\r
 {\r
+\r
        a5133_power_on();\r
        if(RF_Init())/* init RF */\r
        {\r
@@ -131,7 +157,7 @@ void a5133_main(Uint8 Flag_MASTER,uint8_t channel)
       \r
                        while(1)\r
                        {       \r
-                               RF_FIFOWrite(64);/* write data to tx fifo */\r
+                               RF_FIFOWrite(send_data[send_data_index],64);/* write data to tx fifo */\r
                                if(RF_LVR_Check())/* check if BOD reset has occurred */\r
                                        break;/* exit loop & re-RF init */\r
                                else\r
@@ -204,7 +230,7 @@ void a5133_main(Uint8 Flag_MASTER,uint8_t channel)
                                };\r
                                RxPacket();\r
 \r
-                               RF_FIFOWrite(64);\r
+                               RF_FIFOWrite(PN9_Tab,64);\r
                                if(RF_LVR_Check())/* check if BOD reset has occurred */\r
                                        break;/* exit loop & re-RF init */\r
                                else\r
@@ -424,7 +450,7 @@ Uint8 RF_Init(void)
 /*********************************************************************\r
 ** RF_FIFOWrite\r
 *********************************************************************/\r
-void RF_FIFOWrite(Uint8 len)\r
+void RF_FIFOWrite(unsigned char *send_data,Uint8 len)\r
 {\r
        Uint8 i;\r
 \r
@@ -432,7 +458,9 @@ void RF_FIFOWrite(Uint8 len)
        a5133_gpio_scs_set_value(0);\r
        ByteSend(FIFO_REG);//send address 0x05, bit7 cmd=0, bit6 r/w=0\r
        for(i=0; i <len; i++)\r
-               ByteSend(PN9_Tab[i]);\r
+       {\r
+               ByteSend(send_data[i]);\r
+       }\r
        a5133_gpio_scs_set_value(1);\r
 }\r
 \r
@@ -461,6 +489,12 @@ static void dump_tmpbuf(void)
        \r
 \r
 }\r
+\r
+void a5133_get_rxdata(uint8_t *databuf,uint8_t len)\r
+{\r
+    memcpy_s(databuf,len,tmpbuf,strlen((const char*)tmpbuf));\r
+}\r
+\r
 /*********************************************************************\r
 ** RxPacket\r
 *********************************************************************/\r
@@ -478,14 +512,23 @@ void RxPacket(void)
        {\r
                recv = ByteRead();\r
                tmpbuf[i]=recv;\r
-               if((recv ^ PN9_Tab[i])!=0)\r
-               {\r
-                       tmp = recv ^ PN9_Tab[i];\r
-                       Err_BitCnt += (BitCount_Tab[tmp>>4] + BitCount_Tab[tmp & 0x0F]);\r
-                       err=1;\r
-               }\r
+               // if((recv ^ PN9_Tab[i])!=0)\r
+               // {\r
+               //      tmp = recv ^ PN9_Tab[i];\r
+               //      Err_BitCnt += (BitCount_Tab[tmp>>4] + BitCount_Tab[tmp & 0x0F]);\r
+               //      err=1;\r
+               // }\r
        }\r
+       //crccheck\r
+\r
        a5133_gpio_scs_set_value(1);\r
+       uint16_t crc = CRC16_XMODEM(tmpbuf,62);\r
+       uint16_t recv_crc =  *(uint16_t*)&tmpbuf[62];\r
+       PRINT("crc[%X] , recv_crc %X\n",crc,recv_crc);\r
+       if (  crc != recv_crc)\r
+       {\r
+               err = 1;\r
+       }\r
        printf("=====RxPacket \n");\r
        dump_tmpbuf();\r
        if (err)//packet error\r
@@ -883,7 +926,7 @@ void main_prog_ACK(Uint8 Flag_MASTER)
                \r
                        while(1)\r
                        {       \r
-                               RF_FIFOWrite(64); /* write data to tx fifo */\r
+                               RF_FIFOWrite(PN9_Tab,64); /* write data to tx fifo */\r
                                if(RF_LVR_Check())/* check if BOD reset has occurred */\r
                                        break;/* exit loop & re-RF init */\r
                                else\r
index 7df6f53..97a3a12 100644 (file)
@@ -1,3 +1,13 @@
+/*\r
+ * @Author: penglei 1624952103@qq.com\r
+ * @Date: 2024-07-20 10:36:21\r
+ * @LastEditors: penglei 1624952103@qq.com\r
+ * @LastEditTime: 2024-07-26 15:48:42\r
+ * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133define.h\r
+ * @Description: \r
+ * \r
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. \r
+ */\r
 /*****************************************************************************\r
 **                                                                          **\r
 **                         AMIC Proprietary Document                        **\r
@@ -16,7 +26,6 @@
 #include <string.h>\r
 // #include <intrins.h>\r
 #include <stdint.h>\r
-#define data\r
 \r
 #define Sint8  signed   char\r
 #define Sint16 signed   int\r
index 4ba7487..40bbc55 100644 (file)
@@ -1,8 +1,8 @@
 /*\r
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-07-20 10:36:21\r
- * @LastEditors: SnickerSun snickersun@163.com\r
- * @LastEditTime: 2024-07-23 18:49:25\r
+ * @LastEditors: penglei 1624952103@qq.com\r
+ * @LastEditTime: 2024-07-26 14:41:31\r
  * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133main.h\r
  * @Description: \r
  * \r
@@ -54,7 +54,7 @@ errcode_t ByteSend(Uint8 src);
 Uint8 ByteRead(void);\r
 void RF_SetCH(Uint8);\r
 Uint8 RF_Init(void);\r
-void RF_FIFOWrite(Uint8);\r
+void RF_FIFOWrite(unsigned char *send_data,Uint8 len);\r
 void RF_StrobeCmd(Uint8);\r
 void RxPacket(void);\r
 Uint8 RF_Cal_CHGroup(Uint8 ch);\r
@@ -73,5 +73,6 @@ Uint8 Is_Vpoak(void);
 void main_prog_ACK(Uint8 Flag_MASTER);\r
 void RF_TXPower(Uint8 tbf, Uint8 tpa);\r
 void a5133_main(Uint8 Flag_MASTER,uint8_t channel);\r
-\r
+void a5133_get_rxdata(uint8_t *databuf,uint8_t len);\r
+errcode_t a5133_set_send_data(uint8_t *senddata,uint8_t datalen);\r
 #endif
\ No newline at end of file
index 52861ea..37a7840 100644 (file)
 #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
index e9e5809..b00a4eb 100644 (file)
@@ -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"