【TI毫米波雷达】毫米波雷达芯片框架解析:out_of_box开箱demo代码重构,绕过上位机CLI指令(IWR6843AOP)_azimuth target separation with sra

% RF calibration data:None
% Range Detection Threshold (dB):15
% Doppler Detection Threshold (dB):15
% Range Peak Grouping:enabled
% Doppler Peak Grouping:enabled
% Static clutter removal:disabled
% Angle of Arrival FoV: Full FoV
% Range FoV: Full FoV
% Doppler FoV: Full FoV
% ***************************************************************
sensorStop
flushCfg
dfeDataOutputMode 1
channelCfg 15 7 0
adcCfg 2 1
adcbufCfg -1 0 1 1 1
profileCfg 0 60 359 7 57.14 0 0 70 1 256 5209 0 0 158
chirpCfg 0 0 0 0 0 0 0 1
chirpCfg 1 1 0 0 0 0 0 2
chirpCfg 2 2 0 0 0 0 0 4
frameCfg 0 2 16 0 100 1 0
lowPower 0 0
guiMonitor -1 1 1 0 0 0 1
cfarCfg -1 0 2 8 4 3 0 15 1
cfarCfg -1 1 0 4 2 3 1 15 1
multiObjBeamForming -1 1 0.5
clutterRemoval -1 0
calibDcRangeSig -1 0 -5 8 256
extendedMaxVelocity -1 0
lvdsStreamCfg -1 0 0 0
compRangeBiasAndRxChanPhase 0.0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0
measureRangeBiasAndRxChanPhase 0 1.5 0.2
CQRxSatMonitor 0 3 5 121 0
CQSigImgMonitor 0 127 4
analogMonitor 0 0
aoaFovCfg -1 -90 90 -90 90
cfarFovCfg -1 0 0 8.92
cfarFovCfg -1 1 -1 1.00
calibData 0 0 0
sensorStart


上位机输出结果:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/1e552540b855492ea59b3ea2c08463cf.png)  
 对应log:



mmwDemo:/>% ***************************************************************
Skipped

mmwDemo:/>% Created for SDK ver:03.06
Skipped

mmwDemo:/>% Created using Visualizer ver:3.6.0.0
Skipped

mmwDemo:/>% Frequency:60
Skipped

mmwDemo:/>% Platform:xWR68xx_AOP
Skipped

mmwDemo:/>% Scene Classifier:best_range_res
Skipped

mmwDemo:/>% Azimuth Resolution(deg):30 + 30
Skipped

mmwDemo:/>% Range Resolution(m):0.044
Skipped

mmwDemo:/>% Maximum unambiguous Range(m):9.02
Skipped

mmwDemo:/>% Maximum Radial Velocity(m/s):1
Skipped

mmwDemo:/>% Radial velocity resolution(m/s):0.13
Skipped

mmwDemo:/>% Frame Duration(msec):100
Skipped

mmwDemo:/>% RF calibration data:None
Skipped

mmwDemo:/>% Range Detection Threshold (dB):15
Skipped

mmwDemo:/>% Doppler Detection Threshold (dB):15
Skipped

mmwDemo:/>% Range Peak Grouping:enabled
Skipped

mmwDemo:/>% Doppler Peak Grouping:enabled
Skipped

mmwDemo:/>% Static clutter removal:disabled
Skipped

mmwDemo:/>% Angle of Arrival FoV: Full FoV
Skipped

mmwDemo:/>% Range FoV: Full FoV
Skipped

mmwDemo:/>% Doppler FoV: Full FoV
Skipped

mmwDemo:/>% ***************************************************************
Skipped

mmwDemo:/>sensorStop
Ignored: Sensor is already stopped

Done

mmwDemo:/>flushCfg
Done

mmwDemo:/>dfeDataOutputMode 1
Done

mmwDemo:/>channelCfg 15 7 0
Done

mmwDemo:/>adcCfg 2 1
Done

mmwDemo:/>adcbufCfg -1 0 1 1 1
Done

mmwDemo:/>profileCfg 0 60 359 7 57.14 0 0 70 1 256 5209 0 0 158
Done

mmwDemo:/>chirpCfg 0 0 0 0 0 0 0 1
Done

mmwDemo:/>chirpCfg 1 1 0 0 0 0 0 2
Done

mmwDemo:/>chirpCfg 2 2 0 0 0 0 0 4
Done

mmwDemo:/>frameCfg 0 2 16 0 100 1 0
Done

mmwDemo:/>lowPower 0 0
Done

mmwDemo:/>guiMonitor -1 1 1 0 0 0 1
Done

mmwDemo:/>cfarCfg -1 0 2 8 4 3 0 15 1
Done

mmwDemo:/>cfarCfg -1 1 0 4 2 3 1 15 1
Done

mmwDemo:/>multiObjBeamForming -1 1 0.5
Done

mmwDemo:/>clutterRemoval -1 0
Done

mmwDemo:/>calibDcRangeSig -1 0 -5 8 256
Done

mmwDemo:/>extendedMaxVelocity -1 0
Done

mmwDemo:/>lvdsStreamCfg -1 0 0 0
Done

mmwDemo:/>compRangeBiasAndRxChanPhase 0.0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0
Done

mmwDemo:/>measureRangeBiasAndRxChanPhase 0 1.5 0.2
Done

mmwDemo:/>CQRxSatMonitor 0 3 5 121 0
Done

mmwDemo:/>CQSigImgMonitor 0 127 4
Done

mmwDemo:/>analogMonitor 0 0
Done

mmwDemo:/>aoaFovCfg -1 -90 90 -90 90
Done

mmwDemo:/>cfarFovCfg -1 0 0 8.92
Done

mmwDemo:/>cfarFovCfg -1 1 -1 1.00
Done

mmwDemo:/>calibData 0 0 0
Done

mmwDemo:/>sensorStart
Debug: Init Calibration Status = 0x1ffe

Done


上位机发送配置指令时 串口发送结果:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/1e9ff950610d46b881cbe320054a2ec9.png)



version
queryDemoStatus
% ***************************************************************
% Created for SDK ver:03.06
% Created using Visualizer ver:3.6.0.0
% Frequency:60
% Platform:xWR68xx_AOP
% Scene Classifier:best_range_res
% Azimuth Resolution(deg):30 + 30
% Range Resolution(m):0.044
% Maximum unambiguous Range(m):9.02
% Maximum Radial Velocity(m/s):1
% Radial velocity resolution(m/s):0.13
% Frame Duration(msec):100
% RF calibration data:None
% Range Detection Threshold (dB):15
% Doppler Detection Threshold (dB):15
% Range Peak Grouping:enabled
% Doppler Peak Grouping:enabled
% Static clutter removal:disabled
% Angle of Arrival FoV: Full FoV
% Range FoV: Full FoV
% Doppler FoV: Full FoV
% ***************************************************************
sensorStop
flushCfg
dfeDataOutputMode 1
channelCfg 15 7 0
adcCfg 2 1
adcbufCfg -1 0 1 1 1
profileCfg 0 60 359 7 57.14 0 0 70 1 256 5209 0 0 158
chirpCfg 0 0 0 0 0 0 0 1
chirpCfg 1 1 0 0 0 0 0 2
chirpCfg 2 2 0 0 0 0 0 4
frameCfg 0 2 16 0 100 1 0
lowPower 0 0
guiMonitor -1 1 1 0 0 0 1
cfarCfg -1 0 2 8 4 3 0 15 1
cfarCfg -1 1 0 4 2 3 1 15 1
multiObjBeamForming -1 1 0.5
clutterRemoval -1 0
calibDcRangeSig -1 0 -5 8 256
extendedMaxVelocity -1 0
lvdsStreamCfg -1 0 0 0
compRangeBiasAndRxChanPhase 0.0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0
measureRangeBiasAndRxChanPhase 0 1.5 0.2
CQRxSatMonitor 0 3 5 121 0
CQSigImgMonitor 0 127 4
analogMonitor 0 0
aoaFovCfg -1 -90 90 -90 90
cfarFovCfg -1 0 0 8.92
cfarFovCfg -1 1 -1 1.00
calibData 0 0 0
sensorStart


芯片返回到上位机的结果 串口数据:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/b26d610fefd247f68e3561dd1b2896e5.png)



******************************************

xWR64xx MMW Demo 03.06.00.00

******************************************

mmwDemo:/>version
Platform : xWR68xx_AOP

mmWave SDK Version : 03.06.00.00

Device Info : IWR68XX QM non-secure AOP ES 02.00

RF F/W Version : 06.03.02.06.20.08.11

RF F/W Patch : 00.00.00.00.00.00.00

mmWaveLink Version : 01.02.06.06

Lot number : 5509421

Wafer number : 6

Die coordinates in wafer: X = 26, Y = 8

Done

mmwDemo:/>queryDemoStatus
Sensor State: 0

Data port baud rate: 921600

Done

mmwDemo:/>configDataPort 921600 1
Done

mmwDemo:/>version
Platform : xWR68xx_AOP

mmWave SDK Version : 03.06.00.00

Device Info : IWR68XX QM non-secure AOP ES 02.00

RF F/W Version : 06.03.02.06.20.08.11

RF F/W Patch : 00.00.00.00.00.00.00

mmWaveLink Version : 01.02.06.06

Lot number : 5509421

Wafer number : 6

Die coordinates in wafer: X = 26, Y = 8

Done

mmwDemo:/>queryDemoStatus
Sensor State: 0

Data port baud rate: 921600

Done

mmwDemo:/>configDataPort 921600 1
Done

mmwDemo:/>% ***************************************************************
Skipped

mmwDemo:/>% Created for SDK ver:03.06
Skipped

mmwDemo:/>% Created using Visualizer ver:3.6.0.0
Skipped

mmwDemo:/>% Frequency:60
Skipped

mmwDemo:/>% Platform:xWR68xx_AOP
Skipped

mmwDemo:/>% Scene Classifier:best_range_res
Skipped

mmwDemo:/>% Azimuth Resolution(deg):30 + 30
Skipped

mmwDemo:/>% Range Resolution(m):0.044
Skipped

mmwDemo:/>% Maximum unambiguous Range(m):9.02
Skipped

mmwDemo:/>% Maximum Radial Velocity(m/s):1
Skipped

mmwDemo:/>% Radial velocity resolution(m/s):0.13
Skipped

mmwDemo:/>% Frame Duration(msec):100
Skipped

mmwDemo:/>% RF calibration data:None
Skipped

mmwDemo:/>% Range Detection Threshold (dB):15
Skipped

mmwDemo:/>% Doppler Detection Threshold (dB):15
Skipped

mmwDemo:/>% Range Peak Grouping:enabled
Skipped

mmwDemo:/>% Doppler Peak Grouping:enabled
Skipped

mmwDemo:/>% Static clutter removal:disabled
Skipped

mmwDemo:/>% Angle of Arrival FoV: Full FoV
Skipped

mmwDemo:/>% Range FoV: Full FoV
Skipped

mmwDemo:/>% Doppler FoV: Full FoV
Skipped

mmwDemo:/>% ***************************************************************
Skipped

mmwDemo:/>sensorStop
Ignored: Sensor is already stopped

Done

mmwDemo:/>flushCfg
Done

mmwDemo:/>dfeDataOutputMode 1
Done

mmwDemo:/>channelCfg 15 7 0
Done

mmwDemo:/>adcCfg 2 1
Done

mmwDemo:/>adcbufCfg -1 0 1 1 1
Done

mmwDemo:/>profileCfg 0 60 359 7 57.14 0 0 70 1 256 5209 0 0 158
Done

mmwDemo:/>chirpCfg 0 0 0 0 0 0 0 1
Done

mmwDemo:/>chirpCfg 1 1 0 0 0 0 0 2
Done

mmwDemo:/>chirpCfg 2 2 0 0 0 0 0 4
Done

mmwDemo:/>frameCfg 0 2 16 0 100 1 0
Done

mmwDemo:/>lowPower 0 0
Done

mmwDemo:/>guiMonitor -1 1 1 0 0 0 1
Done

mmwDemo:/>cfarCfg -1 0 2 8 4 3 0 15 1
Done

mmwDemo:/>cfarCfg -1 1 0 4 2 3 1 15 1
Done

mmwDemo:/>multiObjBeamForming -1 1 0.5
Done

mmwDemo:/>clutterRemoval -1 0
Done

mmwDemo:/>calibDcRangeSig -1 0 -5 8 256
Done

mmwDemo:/>extendedMaxVelocity -1 0
Done

mmwDemo:/>lvdsStreamCfg -1 0 0 0
Done

mmwDemo:/>compRangeBiasAndRxChanPhase 0.0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0 1 0 -1 0
Done

mmwDemo:/>measureRangeBiasAndRxChanPhase 0 1.5 0.2
Done

mmwDemo:/>CQRxSatMonitor 0 3 5 121 0
Done

mmwDemo:/>CQSigImgMonitor 0 127 4
Done

mmwDemo:/>analogMonitor 0 0
Done

mmwDemo:/>aoaFovCfg -1 -90 90 -90 90
Done

mmwDemo:/>cfarFovCfg -1 0 0 8.92
Done

mmwDemo:/>cfarFovCfg -1 1 -1 1.00
Done

mmwDemo:/>calibData 0 0 0
Done

mmwDemo:/>sensorStart
Debug: Init Calibration Status = 0x1ffe

Done

mmwDemo:/>


## CLI配置流程


CLI的SDK内置函数:



static int32_t CLI_MMWaveVersion (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveFlushCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveDataOutputMode (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveChannelCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveADCCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveProfileCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveChirpCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveFrameCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveAdvFrameCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveSubFrameCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveLowPowerCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveContModeCfg (int32_t argc, char* argv[]);
static int32_t CLI_MMWaveBPMCfgAdvanced (int32_t argc, char* argv[]);


demo代码用户自定义函数:



static int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIMultiObjBeamForming (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLICalibDcRangeSig (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIClutterRemoval (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIADCBufCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLICompRangeBiasAndRxChanPhaseCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIMeasureRangeBiasAndRxChanPhaseCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLICfarFovCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIAoAFovCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIExtendedMaxVelocity (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIChirpQualityRxSatMonCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIChirpQualitySigImgMonCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIAnalogMonitorCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLILvdsStreamCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIConfigDataPort (int32_t argc, char* argv[]);


其中 SDK内置的函数在接受到串口命令时 也会调用 但是是存在内部一个全局变量`gCLI`中  
 最后再通过`CLI_getMMWaveExtensionConfig`和`CLI_getMMWaveExtensionOpenConfig`把变量复制到用户自定义的全局变量结构体`gMmwMCB`中 从而完成配置  
 这里的配置仅仅是写入结构体 真正配置的地方是在调用MMwave相关API函数时 在这里是在`MmwDemo_CLISensorStart`函数中完成配置


## CLI重构


根据官方手册 跳过CLI配置需要以下几个步骤:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/204a034b6530413d93577a777257568b.png)  
 但是按照这个来 完全没用  
 会在配置时报错参数无效/冲突等等  
 但是 首先还是覆写CLI初始化函数 使其只执行我们定义的函数



void MmwDemo_CLIInit (uint8_t taskPriority)
{
if(Remix_Flag)
{
MmwDemo_sensorConfig_task();
}
else
{
CLI_Cfg cliCfg;
char demoBanner[256];
uint32_t cnt;
/* Create Demo Banner to be printed out by CLI */
sprintf(&demoBanner[0],
“******************************************\n”
“xWR64xx MMW Demo %02d.%02d.%02d.%02d\n”
“******************************************\n”,
MMWAVE_SDK_VERSION_MAJOR,
MMWAVE_SDK_VERSION_MINOR,
MMWAVE_SDK_VERSION_BUGFIX,
MMWAVE_SDK_VERSION_BUILD
);


在我们自定义的函数中 仿照命令配置函数的方式来写各个配置函数 同时 通过上位机确定想要的配置:  
 当然 无关紧要的函数可以省去



void MmwDemo_sensorConfig_task(void)
{
int32_t errCode;

/\* Sanity Check: We need the mmWave handle to work. \*/
if (gMmwMCB.ctrlHandle == NULL)
{
    return;
}

/\* Initialize the mmWave control configuration: \*/
memset ((void \*)&gMmwMCB.cfg.ctrlCfg, 0, sizeof(MMWave_CtrlCfg));

mmwave_freq_scale_factor = SOC\_getDeviceRFFreqScaleFactor(gMmwMCB.socHandle, &errCode);
if(errCode < 0)
{
    return;
}

CLI\_Remix\_sensorStop();
CLI\_Remix\_flushCfg();
CLI\_Remix\_dfeDataOutputMode(1);
CLI\_Remix\_channelCfg(15,7,0);
CLI\_Remix\_adcCfg(2,1);
CLI\_Remix\_adcbufCfg(-1,0,1,1,1);
CLI\_Remix\_profileCfg(0,60,47,7,57.14,0,0,70,1,272,5535,0,0,158);
CLI\_Remix\_chirpCfg(0,0,0,0,0,0,0,1);
CLI\_Remix\_chirpCfg(1,1,0,0,0,0,0,2);
CLI\_Remix\_chirpCfg(2,2,0,0,0,0,0,4);
CLI\_Remix\_frameCfg(0,2,16,0,50,1,0);
CLI\_Remix\_lowPower(0,0);
CLI\_Remix\_guiMonitor(-1,1,1,0,0,0,1);
CLI\_Remix\_cfarCfg(-1,0,2,8,4,3,0,15,1);
CLI\_Remix\_cfarCfg(-1,1,0,4,2,3,1,15,1);
CLI\_Remix\_multiObjBeamForming(-1,1,0.5);
CLI\_Remix\_clutterRemoval(-1,0);
CLI\_Remix\_calibDcRangeSig(-1,0,-5,8,256);
CLI\_Remix\_extendedMaxVelocity(-1,0);
CLI\_Remix\_lvdsStreamCfg(-1,0,0,0);
CLI\_Remix\_compRangeBiasAndRxChanPhase(0.0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0,1,0,-1,0);
CLI\_Remix\_measureRangeBiasAndRxChanPhase(0,1.5,0.2);
CLI\_Remix\_CQRxSatMonitor(0,3,5,121,0);
CLI\_Remix\_CQSigImgMonitor(0,89,6);
CLI\_Remix\_analogMonitor(0,0);
CLI\_Remix\_aoaFovCfg(-1,-90,90,-90,90);
CLI\_Remix\_cfarFovCfg(-1,0,0,9.48);
CLI\_Remix\_cfarFovCfg(-1,1,-4,4.00);
CLI\_Remix\_calibData(0,0,0);
CLI\_Remix\_sensorStart();

return;

}


另外 正如之前所说 内部SDK的函数在覆写时 直接把配置参数给到我们用户自定义的结构体`gMmwMCB`中即可  
 比如配置chirp profile frame的函数:



void CLI_Remix_profileCfg(int a1,float a2,float a3,float a4,float a5,int a6,int a7,float a8,float a9,int a10,int a11,int a12,int a13,int a14)
{
rlProfileCfg_t profileCfg;
uint8_t index;
int32_t errCode;
MMWave_ProfileHandle profileHandle;
MMWave_ProfileHandle* ptrBaseCfgProfileHandle;

/\* Sanity Check: Profile configuration is valid only for the Frame or

Advanced Frame Mode: */
if ((gMmwMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_FRAME) &&
(gMmwMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_ADVANCED_FRAME))
{
//CLI_write (“Error: Configuration is valid only if the DFE Output Mode is Frame or Advanced Frame\n”);
return;
}

if (gMmwMCB.cfg.ctrlCfg.dfeDataOutputMode == MMWave_DFEDataOutputMode_FRAME)
{
    ptrBaseCfgProfileHandle = &gMmwMCB.cfg.ctrlCfg.u.frameCfg.profileHandle[0U];
}
else
{
    ptrBaseCfgProfileHandle = &gMmwMCB.cfg.ctrlCfg.u.advancedFrameCfg.profileHandle[0U];
}

/\* Initialize the profile configuration: \*/
memset ((void \*)&profileCfg, 0, sizeof(rlProfileCfg\_t));

/\* Populate the profile configuration: \*/
profileCfg.profileId             = a1;

/\* Translate from GHz to [1 LSB = gCLI\_mmwave\_freq\_scale\_factor \* 1e9 / 2^26 Hz] units

* of mmwavelink format */
profileCfg.startFreqConst = (uint32_t) (((float)a2) * (1U << 26) /mmwave_freq_scale_factor);

/\* Translate below times from us to [1 LSB = 10 ns] units of mmwavelink format \*/
profileCfg.idleTimeConst         = (uint32\_t)((float)a3 \* 1000 / 10);
profileCfg.adcStartTimeConst     = (uint32\_t)((float)a4 \* 1000 / 10);
profileCfg.rampEndTime           = (uint32\_t)((float)a5 \* 1000 / 10);

profileCfg.txOutPowerBackoffCode = a6;
profileCfg.txPhaseShifter        = a7;

/\* Translate from MHz/us to [1 LSB = (gCLI\_mmwave\_freq\_scale\_factor \* 1e6 \* 900) / 2^26 kHz/uS]

* units of mmwavelink format */
profileCfg.freqSlopeConst = (int16_t)((float)a8 * (1U << 26) /((mmwave_freq_scale_factor * 1e3) * 900.0));

/\* Translate from us to [1 LSB = 10 ns] units of mmwavelink format \*/
profileCfg.txStartTime           = (int32\_t)(((float)a9) \* 1000 / 10);

profileCfg.numAdcSamples         = a10;
profileCfg.digOutSampleRate      = a11;
profileCfg.hpfCornerFreq1        = a12;
profileCfg.hpfCornerFreq2        = a13;
profileCfg.rxGain                = a14;

/\* Search for a free space in the mmWave configuration block: \*/
for (index = 0U; index < MMWAVE_MAX_PROFILE; index++)
{
    /\* Did we get a free entry? \*/
    if (ptrBaseCfgProfileHandle[index] == NULL)
    {
        /\* YES: We can add the profile. \*/
        break;
    }
}
if (index == MMWAVE_MAX_PROFILE)
{
    /\* Error: All the profiles have been exhausted \*/
    return;
}

/\* Add the profile to the mmWave module: \*/
profileHandle = MMWave\_addProfile (gMmwMCB.ctrlHandle, &profileCfg, &errCode);
if (profileHandle == NULL)
{
    /\* Error: Unable to add the profile. Return the error code back \*/
    return;
}

/\* Record the profile: \*/
ptrBaseCfgProfileHandle[index] = profileHandle;
return;

}
void CLI_Remix_chirpCfg(int a1,int a2,int a3,float a4,float a5,float a6,float a7,int a8)
{
rlChirpCfg_t chirpCfg;
MMWave_ProfileHandle profileHandle;
int32_t errCode;

/\* Sanity Check: Chirp configuration is valid only for the Frame or

Advanced Frame Mode: */
if ((gMmwMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_FRAME) &&
(gMmwMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_ADVANCED_FRAME))
{
//CLI_write (“Error: Configuration is valid only if the DFE Output Mode is Chirp\n”);
return;
}

/\* Initialize the chirp configuration: \*/
memset ((void \*)&chirpCfg, 0, sizeof(rlChirpCfg\_t));

/\* Populate the chirp configuration: \*/
chirpCfg.chirpStartIdx   = a1;
chirpCfg.chirpEndIdx     = a2;
chirpCfg.profileId       = a3;

/\* Translate from Hz to number of [1 LSB = (gCLI\_mmwave\_freq\_scale\_factor \* 1e9) / 2^26 Hz]

* units of mmwavelink format */
chirpCfg.startFreqVar = (uint32_t) ((float)a4 * (1U << 26) /
(mmwave_freq_scale_factor * 1e9));

/\* Translate from KHz/us to number of [1 LSB = (gCLI\_mmwave\_freq\_scale\_factor \* 1e6) \* 900 /2^26 KHz/us]

* units of mmwavelink format */
chirpCfg.freqSlopeVar = (uint16_t) ((float)a5 * (1U << 26) /
((mmwave_freq_scale_factor * 1e6) * 900.0));

/\* Translate from us to [1 LSB = 10ns] units of mmwavelink format \*/
chirpCfg.idleTimeVar     = (uint32\_t)((float)a6 \* 1000.0 / 10.0);

/\* Translate from us to [1 LSB = 10ns] units of mmwavelink format \*/
chirpCfg.adcStartTimeVar = (uint32\_t)((float)a7 \* 1000.0 / 10.0);

chirpCfg.txEnable        = a8;

/\* Get the profile handle to which the chirp is to be added: \*/
if (MMWave\_getProfileHandle (gMmwMCB.ctrlHandle, chirpCfg.profileId,
                             &profileHandle, &errCode) < 0)
{
    /\* Error: Unable to get the profile handle. Return the error code \*/
    return;
}

/\* Add the chirp to the profile \*/
if (MMWave\_addChirp (profileHandle, &chirpCfg, &errCode) == NULL)
{
    /\* Error: Unable to add the chirp. Return the error code. \*/
    return;
}
return;

}
void CLI_Remix_frameCfg(int a1,int a2,int a3,int a4,float a5,int a6,float a7)
{
rlFrameCfg_t frameCfg;

/\* Sanity Check: Frame configuration is valid only for the Frame or

Advanced Frame Mode: */
if (gMmwMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_FRAME)
{
//CLI_write (“Error: Configuration is valid only if the DFE Output Mode is Chirp\n”);
return;
}

/\* Initialize the frame configuration: \*/
memset ((void \*)&frameCfg, 0, sizeof(rlFrameCfg\_t));

/\* Populate the frame configuration: \*/
frameCfg.chirpStartIdx      = a1;
frameCfg.chirpEndIdx        = a2;
frameCfg.numLoops           = a3;
frameCfg.numFrames          = a4;
frameCfg.framePeriodicity   = (uint32\_t)((float)a5 \* 1000000 / 5);
frameCfg.triggerSelect      = a6;
frameCfg.frameTriggerDelay  = (uint32\_t)((float)a7 \* 1000000 / 5);

/\* Save Configuration to use later \*/
memcpy((void \*)&gMmwMCB.cfg.ctrlCfg.u.frameCfg.frameCfg, (void \*)&frameCfg, sizeof(rlFrameCfg\_t));
return;

}


配置完成后 调用`MmwDemo_CLISensorStart`即可 但是这个函数会将CLI内部结构体`gCLI`的值读到用户结构体中 如果没有用CLI来配置的话 内部结构体时空的 所以得重构`MmwDemo_CLISensorStart`


## `MmwDemo_CLISensorStart`函数重构


在此函数中 由于我们先前已经将所有的配置覆写了 并且赋值到用户结构体中 所以我们只需要将`CLI_getMMWaveExtensionConfig`和`CLI_getMMWaveExtensionOpenConfig`注释掉即可  
 如:



int CLI_Remix_sensorStart(void)
{
bool doReconfig = true;
int32_t retVal = 0;

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

* Do sensor state management to influence the sensor actions
***********************************************************************************/

/\* Error checking initial state: no partial config is allowed

until the first sucessful sensor start state */
if ((gMmwMCB.sensorState == MmwDemo_SensorState_INIT) ||
(gMmwMCB.sensorState == MmwDemo_SensorState_OPENED))
{
MMWave_CtrlCfg ctrlCfg;

    /\* need to get number of sub-frames so that next function to check

* pending state can work */
//CLI_getMMWaveExtensionConfig (&ctrlCfg);
memcpy((void*)&ctrlCfg,(void*)&gMmwMCB.cfg.ctrlCfg,sizeof(MMWave_CtrlCfg));
gMmwMCB.dataPathObj.objDetCommonCfg.preStartCommonCfg.numSubFrames =
MmwDemo_RFParser_getNumSubFrames(&ctrlCfg);

    if (MmwDemo\_isAllCfgInPendingState() == 0)
    {
        System\_printf ("Error: Full configuration must be provided before sensor can be started "
                   "the first time\n");

        /\* Although not strictly needed, bring back to the initial value since we

* are rejecting this first time configuration, prevents misleading debug. */
gMmwMCB.dataPathObj.objDetCommonCfg.preStartCommonCfg.numSubFrames = 0;

        return -1;
    }
}

if (gMmwMCB.sensorState == MmwDemo_SensorState_STARTED)
{
    System\_printf ("Ignored: Sensor is already started\n");
    return 0;
}

if (doReconfig == false)
{
     /\* User intends to issue sensor start without config, check if no

config was issued after stop and generate error if this is the case. */
if (! MmwDemo_isAllCfgInNonPendingState())
{
/* Message user differently if all config was issued or partial config was
issued. */
if (MmwDemo_isAllCfgInPendingState())
{
System_printf ("Error: You have provided complete new configuration, "
"issue “sensorStart” (without argument) if you want it to "
“take effect\n”);
}
else
{
System_printf ("Error: You have provided partial configuration between stop and this "
“command and partial configuration cannot be undone.”
“Issue the full configuration and do “sensorStart” \n”);
}
return -1;
}
}
else
{
/* User intends to issue sensor start with full config, check if all config
was issued after stop and generate error if is the case. */
MMWave_CtrlCfg ctrlCfg;

    /\* need to get number of sub-frames so that next function to check

* pending state can work */
//CLI_getMMWaveExtensionConfig (&ctrlCfg);
memcpy((void*)&ctrlCfg,(void*)&gMmwMCB.cfg.ctrlCfg,sizeof(MMWave_CtrlCfg));
gMmwMCB.dataPathObj.objDetCommonCfg.preStartCommonCfg.numSubFrames =
MmwDemo_RFParser_getNumSubFrames(&ctrlCfg);

    if (MmwDemo\_isAllCfgInPendingState() == 0)
    {
        /\* Message user differently if no config was issued or partial config was

issued. */
if (MmwDemo_isAllCfgInNonPendingState())
{
System_printf ("Error: You have provided no configuration, "
"issue “sensorStart 0” OR provide "
“full configuration and issue “sensorStart”\n”);
}
else
{
System_printf ("Error: You have provided partial configuration between stop and this "
“command and partial configuration cannot be undone.”
“Issue the full configuration and do “sensorStart” \n”);
}
/* Although not strictly needed, bring back to the initial value since we
* are rejecting this first time configuration, prevents misleading debug. */
gMmwMCB.dataPathObj.objDetCommonCfg.preStartCommonCfg.numSubFrames = 0;

        return -1;
    }
}


/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

* Retreive and check mmwave Open related config before calling openSensor
***********************************************************************************/

/\* Fill demo's MCB mmWave openCfg structure from the CLI configs\*/
if (gMmwMCB.sensorState == MmwDemo_SensorState_INIT)
{
    /\* Get the open configuration: \*/
    //CLI\_getMMWaveExtensionOpenConfig (&gMmwMCB.cfg.openCfg);
    /\* call sensor open \*/
    retVal = MmwDemo\_openSensor(true);
    if(retVal != 0)
    {
        return -1;
    }
    gMmwMCB.sensorState = MmwDemo_SensorState_OPENED;
}
else
{
    /\* openCfg related configurations like chCfg, lowPowerMode, adcCfg

* are only used on the first sensor start. If they are different
* on a subsequent sensor start, then generate a fatal error
* so the user does not think that the new (changed) configuration
* takes effect, the board needs to be reboot for the new
* configuration to be applied.
*/
MMWave_OpenCfg openCfg;
//CLI_getMMWaveExtensionOpenConfig (&openCfg);
memcpy((void*)&openCfg,(void*)&gMmwMCB.cfg.openCfg,sizeof(MMWave_OpenCfg));
/* Compare openCfg->chCfg*/
if(memcmp((void *)&gMmwMCB.cfg.openCfg.chCfg, (void *)&openCfg.chCfg,
sizeof(rlChanCfg_t)) != 0)
{
MmwDemo_debugAssert(0);
}

    /\* Compare openCfg->lowPowerMode\*/
    if(memcmp((void \*)&gMmwMCB.cfg.openCfg.lowPowerMode, (void \*)&openCfg.lowPowerMode,
                      sizeof(rlLowPowerModeCfg\_t)) != 0)
    {
        MmwDemo\_debugAssert(0);
    }
    /\* Compare openCfg->adcOutCfg\*/
    if(memcmp((void \*)&gMmwMCB.cfg.openCfg.adcOutCfg, (void \*)&openCfg.adcOutCfg,
                      sizeof(rlAdcOutCfg\_t)) != 0)
    {
        MmwDemo\_debugAssert(0);
    }
}



/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

* Retrieve mmwave Control related config before calling startSensor
***********************************************************************************/
/* Get the mmWave ctrlCfg from the CLI mmWave Extension */
if(doReconfig)
{
/* if MmwDemo_openSensor has non-first time related processing, call here again*/
/* call sensor config */
//CLI_getMMWaveExtensionConfig (&gMmwMCB.cfg.ctrlCfg);
retVal = MmwDemo_configSensor();
if(retVal != 0)
{
return -1;
}
}

retVal = MmwDemo\_startSensor();
if(retVal != 0)
{
    return -1;
}

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

* Set the state
***********************************************************************************/
gMmwMCB.sensorState = MmwDemo_SensorState_STARTED;
return 0;
}


## 数据输出


在main.c中的数据输出函数`MmwDemo_transmitProcessedOutput`(位于线程函数`MmwDemo_DPC_ObjectDetection_dpmTask`中)之前 可以定义一个用于输出点云数据的函数(传参为result) 比如:



MMWave_Remix_Result_Output(result);
//MmwDemo_transmitProcessedOutput(gMmwMCB.loggingUartHandle, result,&currSubFrameStats->outputStats);


可以进行方位角等计算  
 其中 方位角 俯仰角与距离、坐标的关系如下:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/a355f16e057244f0b1bfee938fdacd84.jpeg)



TargetList[i].x = TargetList[i].range*cos(TargetList[i].elevation * sin(TargetList[i].azimuth);
TargetList[i].y = TargetList[i].range*cos(TargetList[i].elevation * cos(TargetList[i].azimuth);
TargetList[i].z = TargetList[i].range * sin(TargetList[i].elevation);


输出函数调用到了串口:(建议115200\*8 不然速度过慢会导致下一个帧开始时 还没运行完 就会报错)



void MMWave_Remix_Result_Output(DPC_ObjectDetection_ExecuteResult *result)
{
uint8_t i=0;
uint8_t numObjOut=result->numObjOut;
char buf[100];
memset(&TargetList, 0, sizeof(Target_t) * 100);
float timestamp=0.0f;
current_timestamp=(result->stats->interFrameStartTimeStamp)/200000000.0f;

if(current_timestamp<=last_timestamp)
{
    timestamp_overflow_flag++;
}

timestamp=timestamp_overflow_flag\*timestamp_overflow+current_timestamp;
last_timestamp=current_timestamp;

memset(buf,0,sizeof(buf));
sprintf(buf,"[INFO] frame:%u\n",frame_flag);
UART\_writePolling (gMmwMCB.commandUartHandle,(uint8\_t\*)buf,strlen(buf));

for(i=0;i<numObjOut;i++)
{
    TargetList[i].timestamp=timestamp;
    TargetList[i].id=i;
    TargetList[i].used=true;
    TargetList[i].SNR=0.1f\*result->objOutSideInfo[i].snr;
    TargetList[i].velocity=result->objOut[i].velocity;
    TargetList[i].x=result->objOut[i].x;
    TargetList[i].y=result->objOut[i].y;

最后

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。

因此收集整理了一份《2024年嵌入式&物联网开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

img

img

img

img

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上嵌入式&物联网开发知识点,真正体系化!

如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新!!

en(buf));

for(i=0;i<numObjOut;i++)
{
    TargetList[i].timestamp=timestamp;
    TargetList[i].id=i;
    TargetList[i].used=true;
    TargetList[i].SNR=0.1f\*result->objOutSideInfo[i].snr;
    TargetList[i].velocity=result->objOut[i].velocity;
    TargetList[i].x=result->objOut[i].x;
    TargetList[i].y=result->objOut[i].y;

最后

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。

因此收集整理了一份《2024年嵌入式&物联网开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

[外链图片转存中…(img-YJrVpn04-1715624864047)]

[外链图片转存中…(img-TkWtvJXi-1715624864048)]

[外链图片转存中…(img-M5K4ai64-1715624864049)]

[外链图片转存中…(img-Y8JVsyti-1715624864049)]

[外链图片转存中…(img-LbJdVAp4-1715624864050)]

[外链图片转存中…(img-ujneEhsa-1715624864051)]

[外链图片转存中…(img-IPev89Yb-1715624864051)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上嵌入式&物联网开发知识点,真正体系化!

如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新!!

  • 28
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
开发ti毫米波雷达demo是一个涉及到雷达技术和软件开发的项目。ti毫米波雷达是一种高频率的雷达技术,能够通过波束形成和高分辨率的目标检测来实现人与环境的感知。 首先,我们需要确定项目的目标和需求。比如,我们希望通过ti毫米波雷达demo实现人员检测和跟踪,以及建立二维地图等功能。 接下来,我们需要选取合适的硬件设备,如ti毫米波雷达模块。然后进行硬件的连接和驱动配置,以确保雷达模块可以正常工作。 在软件开发方面,我们需要编写程序来接收雷达模块的数据,并进行处理和分析。可以使用C/C++等编程语言去编写雷达数据的采集和处理算法,以实现目标检测、跟踪和地图绘制等功能。此外,还需要编写图形界面程序,方便用户与系统交互。 在项目开发过程中,可以使用开发板和开发工具来进行调试和测试,确保系统的稳定性和功能的完善。 最后,我们需要进行整体的测试与优化,以确保ti毫米波雷达demo可以准确地完成人员检测和跟踪,并生成准确的地图。同时,需要对系统进行性能优化,以提高系统的实时性和响应能力。 总结起来,开发ti毫米波雷达demo是一个复杂的工程,需要结合雷达技术和软件开发技术。通过合适的硬件选型、编程算法和图形界面设计,可以实现人员检测、跟踪和地图绘制等功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值