A5133 接收RSU数据参数调整 579/1 579/head 580/target/1
authorSnickerSun <snickersun@163.com>
Wed, 24 Jul 2024 02:43:21 +0000 (10:43 +0800)
committerSnickerSun <snickersun@163.com>
Wed, 24 Jul 2024 02:43:21 +0000 (10:43 +0800)
code/sdk/drivers/peripheral/a5133/A5133Config.h
code/sdk/drivers/peripheral/a5133/A5133Main.c
code/sdk/drivers/peripheral/a5133/A5133Uti.c
code/sdk/drivers/peripheral/a5133/A5133main.h
code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index 2073d3f..542cab8 100644 (file)
@@ -85,7 +85,7 @@ const Uint8 code A5133_RFConfigTab_Main[]=
 \r
 const Uint8 code A5133_RFConfigTab_Addr0x20[]=\r
 {\r
-       0x0E, //page0, \r
+       0x0C, //page0,  //去掉preamble\r
        0x00, //page1,  \r
        0x00, //Page2,\r
        0x00, //page3,\r
index 4ca37e8..72e529f 100644 (file)
@@ -68,7 +68,9 @@ Uint8   idata    Mem_RH;
 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
-const Uint8 code ID_Tab[8]={0xC3,0x3C,0x95,0x6A,0x36,0x75,0xC5,0x2A};//ID code\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 //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
@@ -89,7 +91,7 @@ const Uint8 code PN9_Tab[]=
 /*********************************************************************\r
 * main loop\r
 *********************************************************************/\r
-void a5133_main(Uint8 Flag_MASTER)\r
+void a5133_main(Uint8 Flag_MASTER,uint8_t channel)\r
 {\r
        \r
        if(RF_Init())/* init RF */\r
@@ -103,6 +105,7 @@ void a5133_main(Uint8 Flag_MASTER)
 \r
        if (Flag_MASTER) \r
        {   \r
+               PRINT("Flag_MASTER\n");\r
                while(1)\r
                {\r
                        RF_WriteReg(GIO1_REG,0x01);/* gio1-wtr */\r
@@ -111,13 +114,13 @@ void a5133_main(Uint8 Flag_MASTER)
 \r
                        RF_FIFOLength(64-1);/* fifo length 64 bytes */ \r
                        RF_StrobeCmd(CMD_PLL);\r
-                       RF_SetCH(80);/* ch=80, freq=5805.001MHz */\r
+                       RF_SetCH(channel);/* ch=80, freq=5805.001MHz */\r
                        /*      To set RF channel                                                                                                                                                                                                                                                                                                                                */\r
                        /*      RF base Freq : 5725.001MHz                                                                                                                                                                                                                                                                                       */\r
                        /*      Channel step : 1MHz                                                                                                                                                                                                                                                                                                                      */\r
                        /*      SetCH        : 80                                                                                                                                                                                                                                                                                                                                */\r
                        /*      RF Frequency = RF base Freq + (Channel step * SetCH) = 5725.001MHz + ( 1MHz * 80 ) = 5805.001MHz */\r
-   \r
+                       printf("master channel %d , freq %d\n",channel,5725+channel);\r
                        RxCnt = 0;\r
                        Err_Loss=0;\r
                        Err_Frame=0;\r
@@ -135,8 +138,11 @@ void a5133_main(Uint8 Flag_MASTER)
                                        RF_StrobeCmd(CMD_TX);/* transmit packet */\r
                                \r
                                Delay10us(1);\r
-                               while(a5133_gpio_get_gio1_value());/* wait transmit completed */\r
-                               \r
+                               while(a5133_gpio_get_gio1_value())/* wait transmit completed */\r
+                               {\r
+                                       //sleep\r
+                                       LOS_Msleep(10);\r
+                               };   \r
                                if(RF_LVR_Check())/* check if BOD reset has occurred */\r
                                        break;/* exit loop & re-RF init */\r
                                else\r
@@ -144,7 +150,11 @@ void a5133_main(Uint8 Flag_MASTER)
                                \r
                                timer=0;\r
                                Flag_Timeout=0;\r
-                               while(a5133_gpio_get_gio1_value()==1 && Flag_Timeout==0);/* wait receive completed */\r
+                               while(a5133_gpio_get_gio1_value()==1 && Flag_Timeout==0)/* wait receive completed */\r
+                               {\r
+                                       //sleep\r
+                                       LOS_Msleep(10);\r
+                               };   \r
                                if (Flag_Timeout)\r
                                {\r
                                        RF_StrobeCmd(CMD_PLL);/* exit rx mode */\r
@@ -159,6 +169,7 @@ void a5133_main(Uint8 Flag_MASTER)
        }\r
        else\r
        { \r
+               PRINT("Flag_Slave\n");\r
                while(1)\r
                {\r
                        RF_WriteReg(GIO1_REG,0x01);/* gio1-wtr */\r
@@ -167,7 +178,8 @@ void a5133_main(Uint8 Flag_MASTER)
 \r
                        RF_FIFOLength(64-1);/* write data to tx fifo */ \r
                        RF_StrobeCmd(CMD_PLL);\r
-                       RF_SetCH(80);/* ch=80, freq=5805.001MHz */\r
+                       RF_SetCH(channel);/* ch=80, freq=5805.001MHz */\r
+                       printf("slave channel %d , freq %d\n",channel,5725+channel);\r
                   \r
                        RxCnt = 0;\r
                        Err_Loss=0;\r
@@ -185,7 +197,11 @@ void a5133_main(Uint8 Flag_MASTER)
                                        RF_StrobeCmd(CMD_RX);\r
             \r
                                Delay10us(1);\r
-                               while(a5133_gpio_get_gio1_value());\r
+                               while(a5133_gpio_get_gio1_value())\r
+                               {\r
+                                       //sleep\r
+                                       LOS_Msleep(10);\r
+                               };\r
                                RxPacket();\r
 \r
                                RF_FIFOWrite(64);\r
@@ -195,7 +211,10 @@ void a5133_main(Uint8 Flag_MASTER)
                                        RF_StrobeCmd(CMD_TX);\r
                                \r
                                Delay10us(1);\r
-                               while(a5133_gpio_get_gio1_value());   \r
+                               while(a5133_gpio_get_gio1_value()){\r
+                                       //sleep\r
+                                       LOS_Msleep(10);\r
+                               };   \r
                }\r
        }\r
        }\r
@@ -230,7 +249,7 @@ void ISR_Timer0 (void) //interrupt 1
                memcpy(&CmdBuf[7], &Err_BitCnt, 4);\r
 \r
                //输出日志\r
-               PRINT("RxCnt %d , Err_Loss %d , Err_Frame %d , Err_BitCnt %d \n",RxCnt,Err_Loss,Err_Frame,Err_BitCnt);\r
+               PRINT("=====RxCnt %d , Err_Loss %d , Err_Frame %d , Err_BitCnt %d \n",RxCnt,Err_Loss,Err_Frame,Err_BitCnt);\r
                // UartSendCnt=12;\r
                // Uartptr=&CmdBuf[0];\r
                // SBUF=CmdBuf[0];\r
@@ -387,7 +406,11 @@ Uint8 RF_Init(void)
        }\r
                \r
        RF_Config();/* config A7157 chip */\r
-       RF_TrimmedValue_Init();/* load trimming value */\r
+       if (RF_TrimmedValue_Init()) /* load trimming value */\r
+       {\r
+               printf("RF_TrimmedValue_Init failed\n");\r
+               return 1;\r
+       }\r
        if(RF_Cal())/* rf calibration */\r
        {\r
                printf("RF_Cal\n");\r
@@ -423,6 +446,21 @@ void RF_StrobeCmd(Uint8 cmd)
        a5133_gpio_scs_set_value(1);\r
 }\r
 \r
+#include "wearable_log.h"\r
+static void dump_tmpbuf(void)\r
+{\r
+       uint8_t hexstr[256]={0};\r
+       for (int i=0 ;i < 64;i++)\r
+       {\r
+               sprintf( (char*)&hexstr[i*2],"%02X",tmpbuf[i]);\r
+       }\r
+       // printf((char*)&hexstr[0]);\r
+       // printf("\n");\r
+       printf("rx %s\n",(char*)&hexstr[0]);\r
+    // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rx %s\n",hexstr);\r
+       \r
+\r
+}\r
 /*********************************************************************\r
 ** RxPacket\r
 *********************************************************************/\r
@@ -448,7 +486,8 @@ void RxPacket(void)
                }\r
        }\r
        a5133_gpio_scs_set_value(1);\r
-\r
+       printf("=====RxPacket \n");\r
+       dump_tmpbuf();\r
        if (err)//packet error\r
                Err_Frame++;\r
 }\r
@@ -508,11 +547,23 @@ Uint8 RF_Cal(void)
 \r
        //calibration VBC,VDC procedure\r
        if(RF_Cal_CHGroup(20)) //calibrate channel group Bank I\r
-               return 1;\r
+       {\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+                       return 1;\r
+\r
+       }\r
        if(RF_Cal_CHGroup(60)) //calibrate channel group Bank II\r
-               return 1;\r
+       {\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+                       return 1;\r
+\r
+       }\r
        if(RF_Cal_CHGroup(100)) //calibrate channel group Bank III\r
-               return 1;\r
+       {\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+                       return 1;\r
+\r
+       }\r
 \r
        RF_StrobeCmd(CMD_STBY); //return to STBY state\r
 \r
@@ -530,7 +581,11 @@ Uint8 RF_Cal(void)
        Mem_RL = rlc;\r
 \r
        if(fbcf)\r
+{\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+\r
                return 1;//error\r
+}\r
 \r
        return 0;\r
 }\r
@@ -627,7 +682,7 @@ void RF_FIFOLength(Uint16 len)
 /*********************************************************************\r
 ** RF_TrimmedValue_Init\r
 *********************************************************************/\r
-void RF_TrimmedValue_Init(void)\r
+int RF_TrimmedValue_Init(void)\r
 {\r
        Uint8 i;\r
        Uint8 trimValue[8];\r
@@ -661,7 +716,12 @@ void RF_TrimmedValue_Init(void)
                        RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[2] & 0xC0) | trimValue[1], 2);//CTR          \r
                }\r
                else\r
-                       Err_State();\r
+               {\r
+\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+                       // Err_State();\r
+                       return 1;\r
+               }\r
    }\r
        else if((trimValue[0] + trimValue[1] + trimValue[2] + trimValue[3]) == trimValue[4]) //case2-CP+FT\r
        {\r
@@ -672,8 +732,12 @@ void RF_TrimmedValue_Init(void)
                        RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[0] & 0x03) | (trimValue[2]<<2), 0);//BDC\r
                        RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[4] & 0x40) | trimValue[3], 4);//STM\r
                }\r
-               else\r
-                       Err_State();\r
+               else{\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+                       // Err_State();\r
+                       return 1;\r
+\r
+               }\r
        }\r
        else //only CP\r
        {\r
@@ -685,8 +749,14 @@ void RF_TrimmedValue_Init(void)
                        RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[4] & 0x40) | trimValue[3], 4);//STM\r
                }\r
                else\r
-                       Err_State();     \r
+               {\r
+                       printf("%s,%d\n",__func__,__LINE__);\r
+                       // Err_State();  \r
+                       return 1;\r
+               }\r
+   \r
        }\r
+       return 0;\r
 }\r
   \r
 /*********************************************************************\r
@@ -701,6 +771,7 @@ Sint16 RF_RSSI_Read(void)
 \r
        //RF power in(dBm) = (RSSI - RL) / (RH - RL)  * 12  -  80dbm - 3\r
        tmp = ((rssi*1.0 - Mem_RL) / (Mem_RH - Mem_RL) * 12.0) - 80 - 3; \r
+       printf("RF_RSSI_Read %d\n",tmp);\r
        return tmp;\r
 }\r
 \r
@@ -819,7 +890,11 @@ void main_prog_ACK(Uint8 Flag_MASTER)
                                        RF_StrobeCmd(CMD_TX);/* transmit packet */\r
                                \r
                                Delay10us(1);\r
-                               while(a5133_gpio_get_gio1_value());\r
+                               while(a5133_gpio_get_gio1_value())\r
+                               {\r
+                                       //sleep\r
+                                       LOS_Msleep(10);\r
+                               };   \r
 \r
                                /* check vpoak */\r
                                if(Is_Vpoak())\r
@@ -851,7 +926,7 @@ void main_prog_ACK(Uint8 Flag_MASTER)
                        timer=0;\r
                        // TR0=1;\r
                        // EA=1;\r
-\r
+                       \r
                        while(1)\r
                        {\r
                                if(RF_LVR_Check())/* check if BOD reset has occurred */\r
@@ -860,7 +935,11 @@ void main_prog_ACK(Uint8 Flag_MASTER)
                                        RF_StrobeCmd(CMD_RX);\r
             \r
                                Delay10us(1);\r
-                               while(a5133_gpio_get_gio1_value());\r
+                               while(a5133_gpio_get_gio1_value())\r
+                               {\r
+                                       //sleep\r
+                                       LOS_Msleep(10);\r
+                               };   \r
                                \r
                                /* check vpoak */\r
                                if(Is_Vpoak())\r
index 8d7b1a0..5aa6bb0 100644 (file)
@@ -365,7 +365,7 @@ errcode_t ByteSend(Uint8 src)
        Uint8 i;
        //nop();
        //uapi_cat1_wakeup_cat1(1);
-       a5133_gpio_set_value(S_AGPIO_L30,1);
+       // a5133_gpio_set_value(S_AGPIO_L30,1);
        //uapi_gpio_set_val(S_AGPIO_L30, GPIO_LEVEL_HIGH);
        // a5133_gpio_set_value(GIO1_IN,1);     
        for(i = 0; i < 8; i++)
@@ -386,7 +386,7 @@ errcode_t ByteSend(Uint8 src)
        // a5133_gpio_set_value(GIO1_IN,0);     
        //nop();
        //uapi_cat1_wakeup_cat1(0);
-       a5133_gpio_set_value(S_AGPIO_L30,0);
+       // a5133_gpio_set_value(S_AGPIO_L30,0);
 #endif
        return ret;
 }
@@ -416,7 +416,7 @@ Uint8 ByteRead(void)
        a5133_gpio_sdio_set_value(1);   
        //nop();
        //uapi_cat1_wakeup_cat1(1);
-       a5133_gpio_set_value(S_AGPIO_L30,1);
+       // a5133_gpio_set_value(S_AGPIO_L30,1);
        // a5133_gpio_set_value(GIO1_IN,1);              
        // P0OE = P0OE & (~0x02);
        a5133_gpio_set_direction(SDIO_IN_OUT,0);
@@ -438,9 +438,9 @@ Uint8 ByteRead(void)
        a5133_gpio_set_direction(SDIO_IN_OUT,1);
        //nop();
        //uapi_cat1_wakeup_cat1(0);
-       a5133_gpio_set_value(S_AGPIO_L30,0);
+       // a5133_gpio_set_value(S_AGPIO_L30,0);
        // a5133_gpio_set_value(GIO1_IN,0);              
-       printf("ByteRead tmp[%2X]\n",tmp);
+       // printf("ByteRead tmp[%2X]\n",tmp);
        // P0OE = P0OE | (0x02);
        return tmp;
 #endif
index b37319e..4ba7487 100644 (file)
@@ -1,8 +1,8 @@
 /*\r
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-07-20 10:36:21\r
- * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-07-22 15:38:12\r
+ * @LastEditors: SnickerSun snickersun@163.com\r
+ * @LastEditTime: 2024-07-23 18:49:25\r
  * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133main.h\r
  * @Description: \r
  * \r
@@ -63,7 +63,7 @@ void RF_Config(void);
 void RF_FCB(void);\r
 void RF_KeyData(void);\r
 void RF_FIFOLength(Uint16 len);\r
-void RF_TrimmedValue_Init(void);\r
+int RF_TrimmedValue_Init(void);\r
 Sint16 RF_RSSI_Read(void);\r
 void RF_PM_SleepMode(void);\r
 Uint8 RF_LVR_Check(void);\r
@@ -72,6 +72,6 @@ void RF_AdvFIFO_Init(void);
 Uint8 Is_Vpoak(void);\r
 void main_prog_ACK(Uint8 Flag_MASTER);\r
 void RF_TXPower(Uint8 tbf, Uint8 tpa);\r
-void a5133_main(Uint8 Flag_MASTER);\r
+void a5133_main(Uint8 Flag_MASTER,uint8_t channel);\r
 \r
 #endif
\ No newline at end of file
index 178b51a..5c87009 100644 (file)
@@ -140,21 +140,26 @@ static void a5133_service_check_task(void  *arg)
             continue;
         }
 
-        if (mail == A5133_SERVICE_CMD_TYPE_RUN_MASTER)
-        {
-            PRINT("A5133_SERVICE_CMD_TYPE_RUN_MASTER \n");
-            a5133_service_timer_start_check(50);
-            a5133_main(MASTER);
-        }else if (mail == A5133_SERVICE_CMD_TYPE_RUN_SLAVE)
-        {
+        PRINT("A5133_SERVICE_CMD_TYPE_RUN \n");
+        a5133_service_timer_start_check(50);
+        a5133_main(SLAVE,mail);
+
+
+        // if (mail == A5133_SERVICE_CMD_TYPE_RUN_MASTER)
+        // {
+        //     PRINT("A5133_SERVICE_CMD_TYPE_RUN_MASTER \n");
+        //     a5133_service_timer_start_check(50);
+        //     a5133_main(MASTER);
+        // }else if (mail == A5133_SERVICE_CMD_TYPE_RUN_SLAVE)
+        // {
             
-            PRINT("A5133_SERVICE_CMD_TYPE_RUN_SLAVE \n");
-            a5133_service_timer_start_check(50);
-            a5133_main(SLAVE);
-        }else if (mail == A5133_SERVICE_CMD_TYPE_TIMER_CHECK)
-        {
+        //     PRINT("A5133_SERVICE_CMD_TYPE_RUN_SLAVE \n");
+        //     a5133_service_timer_start_check(50);
+        //     a5133_main(SLAVE);
+        // }else if (mail == A5133_SERVICE_CMD_TYPE_TIMER_CHECK)
+        // {
             
-        }
+        // }
     }
     a5133_server_break_flag = 0;
     a5133_service_running_stat = false;
@@ -175,7 +180,7 @@ errcode_t uapi_a5133_service_init(void)
     app_task_definition_t taskcfg={0};
     taskcfg.create_queue_handle = create_a5133_queue;
     taskcfg.attr.name="a5133_service";
-    taskcfg.attr.priority = osPriorityNormal;
+    taskcfg.attr.priority = osPriorityBelowNormal;
     taskcfg.attr.stack_size = A5133_SERVICE_TASK_SIZE;
     taskcfg.func = a5133_service_check_task;
     taskcfg.use_mem = USE_EXTEND_MEM;
index 372eb31..24a66f2 100644 (file)
@@ -797,6 +797,8 @@ static uint32_t custom_get_cywee_active_state(uint8_t *para, uint32_t paraLen, c
     return ERRCODE_SUCC;
 }
 #ifdef SUPPORT_A5133_SERVICE
+
+
 static uint32_t custom_a5133_send_msg(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 {
     UNUSED(strCommonCmd);
@@ -822,6 +824,13 @@ static uint32_t custom_a5133_send_msg(uint8_t *para, uint32_t paraLen, char *str
     
     return ERRCODE_SUCC;
 }
+static uint32_t custom_a5133_rssi(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+    wstp_print("RF_RSSI_Read!!!\n");
+    RF_RSSI_Read();
+    return 0;
+}
+
 #endif
 
 
@@ -886,6 +895,9 @@ static const at_cmd_table_t g_custom_utils_cmd[] = {
     {(char *)"AT^GETCYWEEACTIVE", custom_get_cywee_active_state, (char *)" "},
 #ifdef SUPPORT_A5133_SERVICE
     {(char *)"AT^A5133SENDDATA", custom_a5133_send_msg, (char *)" "},
+    {(char *)"AT^A5133RSSI", custom_a5133_rssi, (char *)" "},
+
+    
 #endif
 };