From 6a631c260dfb5aa83f97dfe6556db4cba3fd3c2f Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Fri, 26 Jan 2024 11:36:33 +0800 Subject: [PATCH] =?utf8?q?mmc5603=E6=8C=87=E5=8D=97=E9=92=88=E6=B7=BB?= =?utf8?q?=E5=8A=A0=E6=A0=A1=E5=87=86=E8=AE=B0=E5=BD=95=EF=BC=8C=E4=B8=8D?= =?utf8?q?=E9=87=8D=E5=90=AF=E4=B9=8B=E5=89=8D=EF=BC=8C=E6=A0=A1=E5=87=86?= =?utf8?q?=E4=BF=A1=E6=81=AF=E9=83=BD=E5=9C=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../peripheral/mag/mmc5603/mmc5603_main.c | 79 +++++-------------- 1 file changed, 19 insertions(+), 60 deletions(-) diff --git a/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c b/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c index dc4d7eb26..23f82dc08 100644 --- a/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c +++ b/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c @@ -156,25 +156,18 @@ extern uint8_t is_xts_test_done(void); /* This variable is used to save calibrated mag sensor parameters */ float caliMagPara[4] = {0.0f}; /* convert the coordinate system */ - acc_coordinate_raw_to_real(A_LAYOUT, acc_raw_data, acc_real_data); - MMC_LOG("acc_coordinate_raw_to_real raw(%.02f,%.02f,%.02f) , real(%.02f,%.02f,%.02f)\r\n", - acc_raw_data[0],acc_raw_data[1],acc_raw_data[2], - acc_real_data[0],acc_real_data[1],acc_real_data[2] - ); - /* Get the MMC5603 mag raw data, unit is gauss */ + acc_coordinate_raw_to_real(A_LAYOUT, acc_raw_data, acc_real_data); + // /* Get the MMC5603 mag raw data, unit is gauss */ MMC5603_GetData(mag_raw_data); /* Convert the coordinate system */ mag_coordinate_raw_to_real(M_LAYOUT, mag_raw_data, mag_real_data); - MMC_LOG("mag_coordinate_raw_to_real raw(%.02f,%.02f,%.02f) , real(%.02f,%.02f,%.02f)\r\n", - mag_raw_data[0],mag_raw_data[1],mag_raw_data[2], - mag_real_data[0],mag_real_data[1],mag_real_data[2] - ); - /* Below functions are algorithm interface. * input acc, mag data into algorithm * make sure that acc and mag XYZ data meet the right-hand(right-front-up) coordinate system */ + + // MMC_LOG("acc_raw :%f %f %f mag_raw:%f %f %f \r\n",acc_real_data[0],acc_real_data[1],acc_real_data[2],mag_real_data[0],mag_real_data[1],mag_real_data[2]); MainAlgorithmProcess(acc_real_data, mag_real_data, 1); /* Get calibrated mag data */ @@ -186,57 +179,23 @@ extern uint8_t is_xts_test_done(void); calMagZ = caliMag[2]; - /* Get orientation vector */ - if (GetCalOri(acc_real_data, caliMag, caliOri) == 1 ) - { + // MMC_LOG("calmag :%f %f %f \r\n",caliMag[0],caliMag[1],caliMag[2]); - /* Get the accuracy of the algorithm */ - iAccuracy = GetMagAccuracy(); - - /* Get the fAzimuth Pitch Roll for the eCompass */ - fAzimuth = caliOri[0]; - fPitch = caliOri[1]; - fRoll = caliOri[2]; - if(iAccuracy == 3){ - MMC_LOG("== Mag x %.02F,y %.02F , z %.02F\r\n", - calMagX,//高斯X - calMagY,//高斯Y - calMagZ//高斯Z - ); - MMC_LOG("iAccuracy %d== Acc Azimuth %.02F,Pitch %.02F , Roll %.02F\r\n", - iAccuracy,//可信度 - fAzimuth, //水平方向角,左转右转 - fPitch,//上下俯仰角 - fRoll//左右翻滚角 - ); - }else{ - MMC_LOG("--iAccuracy %d < 3 skip\r\n", - iAccuracy //可信度 - ); - - MMC_LOG("--== Mag x %.02F,y %.02F , z %.02F\r\n", - calMagX,//高斯X - calMagY,//高斯Y - calMagZ//高斯Z - ); - MMC_LOG("--iAccuracy %d== Acc Azimuth %.02F,Pitch %.02F , Roll %.02F\r\n", - iAccuracy,//可信度 - fAzimuth, //水平方向角,左转右转 - fPitch,//上下俯仰角 - fRoll//左右翻滚角 - ); - - } - } + GetCalOri(acc_real_data, caliMag, caliOri); + fAzimuth = caliOri[0]; + fPitch = caliOri[1]; + fRoll = caliOri[2]; + iAccuracy = GetMagAccuracy(); + + // MMC_LOG("fAzimuth =%f iAccuracy=%d\r\n",fAzimuth,iAccuracy); - /* Get the SET Flag from algorithm */ - if(GetMagSaturation()) - { - //MEMSIC_Magnetic_Sensor_SET(); //Do SET action - MMC_LOG("Do SET action MMC5603_SET\r\n"); - MMC5603_SET(); - } + // if(GetMagSaturation()) + // { + // //MEMSIC_Magnetic_Sensor_SET(); //Do SET action + // MMC_LOG("Do SET action MMC5603_SET\r\n"); + // MMC5603_SET(); + // } /* Get corrected mag data */ save_flag = GetCalPara(caliMagPara); @@ -260,7 +219,7 @@ extern uint8_t is_xts_test_done(void); clock_gettime(CLOCK_MONOTONIC, &time); uint32_t _endTimestamp = (uint32_t ) time.tv_sec * SEC_TO_MILLISEC + time.tv_nsec / MILLISEC_TO_NANOSEC; - MMC_LOG("mmc5603_check cost %u\r\n",(_endTimestamp-_startTimestamp)); + // MMC_LOG("mmc5603_check cost %u\r\n",(_endTimestamp-_startTimestamp)); return 0; } -- 2.17.1