From: SnickerSun Date: Fri, 26 Jan 2024 03:36:33 +0000 (+0800) Subject: mmc5603指南针添加校准记录,不重启之前,校准信息都在。 X-Git-Tag: release_V1.2.70_20241020_135402~1324 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=6a631c260dfb5aa83f97dfe6556db4cba3fd3c2f;p=mirrors%2FFD230.git mmc5603指南针添加校准记录,不重启之前,校准信息都在。 --- 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; }