From f5aaa2a24c3e150d70a315edfd1ba5b2a711e202 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Wed, 24 Jul 2024 10:43:21 +0800 Subject: [PATCH] =?utf8?q?A5133=20=E6=8E=A5=E6=94=B6RSU=E6=95=B0=E6=8D=AE?= =?utf8?q?=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../drivers/peripheral/a5133/A5133Config.h | 2 +- code/sdk/drivers/peripheral/a5133/A5133Main.c | 127 ++++++++++++++---- code/sdk/drivers/peripheral/a5133/A5133Uti.c | 10 +- code/sdk/drivers/peripheral/a5133/A5133main.h | 8 +- .../a5133/service/a5133_service.cpp | 33 +++-- .../peripheral/utils/custom_utils_at_cmd.c | 12 ++ 6 files changed, 144 insertions(+), 48 deletions(-) diff --git a/code/sdk/drivers/peripheral/a5133/A5133Config.h b/code/sdk/drivers/peripheral/a5133/A5133Config.h index 2073d3f7b..542cab859 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133Config.h +++ b/code/sdk/drivers/peripheral/a5133/A5133Config.h @@ -85,7 +85,7 @@ const Uint8 code A5133_RFConfigTab_Main[]= const Uint8 code A5133_RFConfigTab_Addr0x20[]= { - 0x0E, //page0, + 0x0C, //page0, //去掉preamble 0x00, //page1, 0x00, //Page2, 0x00, //page3, diff --git a/code/sdk/drivers/peripheral/a5133/A5133Main.c b/code/sdk/drivers/peripheral/a5133/A5133Main.c index 4ca37e8c1..72e529fc3 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133Main.c +++ b/code/sdk/drivers/peripheral/a5133/A5133Main.c @@ -68,7 +68,9 @@ 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}; -const Uint8 code ID_Tab[8]={0xC3,0x3C,0x95,0x6A,0x36,0x75,0xC5,0x2A};//ID code +// 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 //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 @@ -89,7 +91,7 @@ const Uint8 code PN9_Tab[]= /********************************************************************* * main loop *********************************************************************/ -void a5133_main(Uint8 Flag_MASTER) +void a5133_main(Uint8 Flag_MASTER,uint8_t channel) { if(RF_Init())/* init RF */ @@ -103,6 +105,7 @@ void a5133_main(Uint8 Flag_MASTER) if (Flag_MASTER) { + PRINT("Flag_MASTER\n"); while(1) { RF_WriteReg(GIO1_REG,0x01);/* gio1-wtr */ @@ -111,13 +114,13 @@ void a5133_main(Uint8 Flag_MASTER) RF_FIFOLength(64-1);/* fifo length 64 bytes */ RF_StrobeCmd(CMD_PLL); - RF_SetCH(80);/* ch=80, freq=5805.001MHz */ + RF_SetCH(channel);/* ch=80, freq=5805.001MHz */ /* To set RF channel */ /* RF base Freq : 5725.001MHz */ /* Channel step : 1MHz */ /* SetCH : 80 */ /* RF Frequency = RF base Freq + (Channel step * SetCH) = 5725.001MHz + ( 1MHz * 80 ) = 5805.001MHz */ - + printf("master channel %d , freq %d\n",channel,5725+channel); RxCnt = 0; Err_Loss=0; Err_Frame=0; @@ -135,8 +138,11 @@ void a5133_main(Uint8 Flag_MASTER) RF_StrobeCmd(CMD_TX);/* transmit packet */ Delay10us(1); - while(a5133_gpio_get_gio1_value());/* wait transmit completed */ - + while(a5133_gpio_get_gio1_value())/* wait transmit completed */ + { + //sleep + LOS_Msleep(10); + }; if(RF_LVR_Check())/* check if BOD reset has occurred */ break;/* exit loop & re-RF init */ else @@ -144,7 +150,11 @@ void a5133_main(Uint8 Flag_MASTER) timer=0; Flag_Timeout=0; - while(a5133_gpio_get_gio1_value()==1 && Flag_Timeout==0);/* wait receive completed */ + while(a5133_gpio_get_gio1_value()==1 && Flag_Timeout==0)/* wait receive completed */ + { + //sleep + LOS_Msleep(10); + }; if (Flag_Timeout) { RF_StrobeCmd(CMD_PLL);/* exit rx mode */ @@ -159,6 +169,7 @@ void a5133_main(Uint8 Flag_MASTER) } else { + PRINT("Flag_Slave\n"); while(1) { RF_WriteReg(GIO1_REG,0x01);/* gio1-wtr */ @@ -167,7 +178,8 @@ void a5133_main(Uint8 Flag_MASTER) RF_FIFOLength(64-1);/* write data to tx fifo */ RF_StrobeCmd(CMD_PLL); - RF_SetCH(80);/* ch=80, freq=5805.001MHz */ + RF_SetCH(channel);/* ch=80, freq=5805.001MHz */ + printf("slave channel %d , freq %d\n",channel,5725+channel); RxCnt = 0; Err_Loss=0; @@ -185,7 +197,11 @@ void a5133_main(Uint8 Flag_MASTER) RF_StrobeCmd(CMD_RX); Delay10us(1); - while(a5133_gpio_get_gio1_value()); + while(a5133_gpio_get_gio1_value()) + { + //sleep + LOS_Msleep(10); + }; RxPacket(); RF_FIFOWrite(64); @@ -195,7 +211,10 @@ void a5133_main(Uint8 Flag_MASTER) RF_StrobeCmd(CMD_TX); Delay10us(1); - while(a5133_gpio_get_gio1_value()); + while(a5133_gpio_get_gio1_value()){ + //sleep + LOS_Msleep(10); + }; } } } @@ -230,7 +249,7 @@ void ISR_Timer0 (void) //interrupt 1 memcpy(&CmdBuf[7], &Err_BitCnt, 4); //输出日志 - PRINT("RxCnt %d , Err_Loss %d , Err_Frame %d , Err_BitCnt %d \n",RxCnt,Err_Loss,Err_Frame,Err_BitCnt); + PRINT("=====RxCnt %d , Err_Loss %d , Err_Frame %d , Err_BitCnt %d \n",RxCnt,Err_Loss,Err_Frame,Err_BitCnt); // UartSendCnt=12; // Uartptr=&CmdBuf[0]; // SBUF=CmdBuf[0]; @@ -387,7 +406,11 @@ Uint8 RF_Init(void) } RF_Config();/* config A7157 chip */ - RF_TrimmedValue_Init();/* load trimming value */ + if (RF_TrimmedValue_Init()) /* load trimming value */ + { + printf("RF_TrimmedValue_Init failed\n"); + return 1; + } if(RF_Cal())/* rf calibration */ { printf("RF_Cal\n"); @@ -423,6 +446,21 @@ void RF_StrobeCmd(Uint8 cmd) a5133_gpio_scs_set_value(1); } +#include "wearable_log.h" +static void dump_tmpbuf(void) +{ + uint8_t hexstr[256]={0}; + for (int i=0 ;i < 64;i++) + { + sprintf( (char*)&hexstr[i*2],"%02X",tmpbuf[i]); + } + // printf((char*)&hexstr[0]); + // printf("\n"); + printf("rx %s\n",(char*)&hexstr[0]); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rx %s\n",hexstr); + + +} /********************************************************************* ** RxPacket *********************************************************************/ @@ -448,7 +486,8 @@ void RxPacket(void) } } a5133_gpio_scs_set_value(1); - + printf("=====RxPacket \n"); + dump_tmpbuf(); if (err)//packet error Err_Frame++; } @@ -508,11 +547,23 @@ Uint8 RF_Cal(void) //calibration VBC,VDC procedure if(RF_Cal_CHGroup(20)) //calibrate channel group Bank I - return 1; + { + printf("%s,%d\n",__func__,__LINE__); + return 1; + + } if(RF_Cal_CHGroup(60)) //calibrate channel group Bank II - return 1; + { + printf("%s,%d\n",__func__,__LINE__); + return 1; + + } if(RF_Cal_CHGroup(100)) //calibrate channel group Bank III - return 1; + { + printf("%s,%d\n",__func__,__LINE__); + return 1; + + } RF_StrobeCmd(CMD_STBY); //return to STBY state @@ -530,7 +581,11 @@ Uint8 RF_Cal(void) Mem_RL = rlc; if(fbcf) +{ + printf("%s,%d\n",__func__,__LINE__); + return 1;//error +} return 0; } @@ -627,7 +682,7 @@ void RF_FIFOLength(Uint16 len) /********************************************************************* ** RF_TrimmedValue_Init *********************************************************************/ -void RF_TrimmedValue_Init(void) +int RF_TrimmedValue_Init(void) { Uint8 i; Uint8 trimValue[8]; @@ -661,7 +716,12 @@ void RF_TrimmedValue_Init(void) RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[2] & 0xC0) | trimValue[1], 2);//CTR } else - Err_State(); + { + + printf("%s,%d\n",__func__,__LINE__); + // Err_State(); + return 1; + } } else if((trimValue[0] + trimValue[1] + trimValue[2] + trimValue[3]) == trimValue[4]) //case2-CP+FT { @@ -672,8 +732,12 @@ void RF_TrimmedValue_Init(void) RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[0] & 0x03) | (trimValue[2]<<2), 0);//BDC RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[4] & 0x40) | trimValue[3], 4);//STM } - else - Err_State(); + else{ + printf("%s,%d\n",__func__,__LINE__); + // Err_State(); + return 1; + + } } else //only CP { @@ -685,8 +749,14 @@ void RF_TrimmedValue_Init(void) RF_WritePage(ROMP_REG, (A5133_RFConfigTab_Addr0x38[4] & 0x40) | trimValue[3], 4);//STM } else - Err_State(); + { + printf("%s,%d\n",__func__,__LINE__); + // Err_State(); + return 1; + } + } + return 0; } /********************************************************************* @@ -701,6 +771,7 @@ Sint16 RF_RSSI_Read(void) //RF power in(dBm) = (RSSI - RL) / (RH - RL) * 12 - 80dbm - 3 tmp = ((rssi*1.0 - Mem_RL) / (Mem_RH - Mem_RL) * 12.0) - 80 - 3; + printf("RF_RSSI_Read %d\n",tmp); return tmp; } @@ -819,7 +890,11 @@ void main_prog_ACK(Uint8 Flag_MASTER) RF_StrobeCmd(CMD_TX);/* transmit packet */ Delay10us(1); - while(a5133_gpio_get_gio1_value()); + while(a5133_gpio_get_gio1_value()) + { + //sleep + LOS_Msleep(10); + }; /* check vpoak */ if(Is_Vpoak()) @@ -851,7 +926,7 @@ void main_prog_ACK(Uint8 Flag_MASTER) timer=0; // TR0=1; // EA=1; - + while(1) { if(RF_LVR_Check())/* check if BOD reset has occurred */ @@ -860,7 +935,11 @@ void main_prog_ACK(Uint8 Flag_MASTER) RF_StrobeCmd(CMD_RX); Delay10us(1); - while(a5133_gpio_get_gio1_value()); + while(a5133_gpio_get_gio1_value()) + { + //sleep + LOS_Msleep(10); + }; /* check vpoak */ if(Is_Vpoak()) diff --git a/code/sdk/drivers/peripheral/a5133/A5133Uti.c b/code/sdk/drivers/peripheral/a5133/A5133Uti.c index 8d7b1a0d4..5aa6bb062 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133Uti.c +++ b/code/sdk/drivers/peripheral/a5133/A5133Uti.c @@ -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 diff --git a/code/sdk/drivers/peripheral/a5133/A5133main.h b/code/sdk/drivers/peripheral/a5133/A5133main.h index b37319e6b..4ba748733 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: penglei 1624952103@qq.com - * @LastEditTime: 2024-07-22 15:38:12 + * @LastEditors: SnickerSun snickersun@163.com + * @LastEditTime: 2024-07-23 18:49:25 * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133main.h * @Description: * @@ -63,7 +63,7 @@ void RF_Config(void); void RF_FCB(void); void RF_KeyData(void); void RF_FIFOLength(Uint16 len); -void RF_TrimmedValue_Init(void); +int RF_TrimmedValue_Init(void); Sint16 RF_RSSI_Read(void); void RF_PM_SleepMode(void); Uint8 RF_LVR_Check(void); @@ -72,6 +72,6 @@ void RF_AdvFIFO_Init(void); Uint8 Is_Vpoak(void); void main_prog_ACK(Uint8 Flag_MASTER); void RF_TXPower(Uint8 tbf, Uint8 tpa); -void a5133_main(Uint8 Flag_MASTER); +void a5133_main(Uint8 Flag_MASTER,uint8_t channel); #endif \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp b/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp index 178b51a8a..5c8700908 100644 --- a/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp +++ b/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp @@ -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; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 372eb3196..24a66f25a 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -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 }; -- 2.17.1