22 #include <xdc/runtime/System.h>
23 #include <ti/sysbios/BIOS.h>
24 #include <ti/sysbios/knl/Task.h>
25 #include <ti/sysbios/knl/Event.h>
26 #include <ti/sysbios/knl/Semaphore.h>
27 #include <ti/sysbios/knl/Clock.h>
28 #include <ti/sysbios/heaps/HeapBuf.h>
29 #include <ti/sysbios/heaps/HeapMem.h>
30 #include <ti/sysbios/knl/Event.h>
33 #include <ti/common/sys_common.h>
34 #include <ti/drivers/uart/UART.h>
35 #include <ti/drivers/osal/DebugP.h>
36 #include <ti/control/mmwavelink/mmwavelink.h>
37 #include <ti/utils/cli/cli.h>
62 MMWave_CalibrationCfg calibrationCfg;
74 memset ((
void *)&calibrationCfg, 0,
sizeof(MMWave_CalibrationCfg));
77 calibrationCfg.dfeDataOutputMode =
78 MMWave_DFEDataOutputMode_ADVANCED_FRAME;
79 calibrationCfg.u.chirpCalibrationCfg.enableCalibration =
true;
80 calibrationCfg.u.chirpCalibrationCfg.enablePeriodicity =
true;
81 calibrationCfg.u.chirpCalibrationCfg.periodicTimeInFrames = 10U;
83 System_printf (
"[MSS] \t [DEBUG] Sensor will start momentarily. \n");
86 if (MMWave_start (
gMCB.
ctrlHandle, &calibrationCfg, &errCode) < 0) {
89 System_printf (
"[MSS] \t [ERROR] mmWave start failed [Error code %d]\n", errCode);
99 System_printf (
"[MSS] \t [ERROR] Please ensure that the XXXCfg CLI command is invoked before starting the sensor\n");
124 System_printf (
"Error: mmWave stop failed [Error code %d]\n", errCode);
127 System_printf (
"Debug: Sensor has been stopped\n");
135 System_printf (
"Error: Sensor has already been stopped. Reconfigure and start the sensor if required\n");
149 MMWave_OpenCfg openCfg;
151 rlProfileCfg_t profileCfg;
152 rlChirpCfg_t chirpCfg;
153 rlFrameCfg_t frameCfg;
162 openCfg.freqLimitLow = 760U;
163 openCfg.freqLimitHigh = 810U;
164 openCfg.defaultAsyncEventHandler = MMWave_DefaultAsyncEventHandler_MSS;
172 if (MMWave_open (
gMCB.
ctrlHandle, &openCfg, NULL, &errCode) < 0) {
173 System_printf (
"[MSS] \t [ERROR] mmWave open configuration failed [Error code %d]\n", errCode);
184 retVal = rlSetProfileConfig (RL_DEVICE_MAP_INTERNAL_BSS, 1U, &profileCfg);
185 if (retVal != RL_RET_CODE_OK) {
186 System_printf (
"[MSS] \t [ERROR] Unable to configure the profile [Error %d]\n", retVal);
194 retVal = rlSetChirpConfig(RL_DEVICE_MAP_INTERNAL_BSS, 1U, &chirpCfg);
196 if (retVal != RL_RET_CODE_OK) {
197 System_printf (
"[MSS] \t [ERROR] Unable to configure the chirp [Error %d]\n", retVal);
205 retVal = rlSetFrameConfig(RL_DEVICE_MAP_INTERNAL_BSS, &frameCfg);
206 if (retVal != RL_RET_CODE_OK) {
207 System_printf (
"[MSS] \t [ERROR] Unable to configure the frame [Error %d]\n", retVal);
213 System_printf (
"[MSS] \t [DEBUG] Basic configuration completed. Start the sensor...\n");
227 MMWave_OpenCfg openCfg;
229 rlProfileCfg_t profileCfg;
230 rlChirpCfg_t chirpCfg;
231 rlAdvFrameCfg_t advFrameCfg;
234 rlRfLdoBypassCfg_t rfLdoBypassCfg[1] = {0};
242 openCfg.freqLimitLow = 760U;
243 openCfg.freqLimitHigh = 810U;
244 openCfg.defaultAsyncEventHandler = MMWave_DefaultAsyncEventHandler_MSS;
252 if (MMWave_open (
gMCB.
ctrlHandle, &openCfg, NULL, &errCode) < 0) {
253 System_printf (
"[MSS] \t [ERROR] mmWave open configuration failed [Error code %d]\n", errCode);
256 System_printf (
"Set LDO Bypass\n");
257 rfLdoBypassCfg->ldoBypassEnable = 0x03;
258 retVal = rlRfSetLdoBypassConfig(RL_DEVICE_MAP_INTERNAL_BSS, (rlRfLdoBypassCfg_t*)rfLdoBypassCfg);
260 if (retVal != RL_RET_CODE_OK) {
261 System_printf (
"[MSS] \t [ERROR] LDO Bypass config failed [Error %d]\n", retVal);
275 retVal = rlSetProfileConfig (RL_DEVICE_MAP_INTERNAL_BSS, 1U, &profileCfg);
276 if (retVal != RL_RET_CODE_OK) {
277 System_printf (
"[MSS] \t [ERROR] Unable to configure the profile %d [Error %d]\n", indx, retVal);
288 retVal = rlSetChirpConfig(RL_DEVICE_MAP_INTERNAL_BSS, 1U, &chirpCfg);
289 if (retVal != RL_RET_CODE_OK) {
291 System_printf (
"Error: Unable to configure chirp %d [Error %d]\n", indx, retVal);
298 retVal = rlSetAdvFrameConfig(RL_DEVICE_MAP_INTERNAL_BSS, &advFrameCfg);
299 if (retVal != RL_RET_CODE_OK)
301 System_printf (
"[MSS]\t [ERROR] Advanced Frame configuration failed [Error %d]\n", retVal);
307 System_printf (
"[MSS] \t [DEBUG] MMWave has been configured.\n");
319 static char* dummy[1];
322 memset((
void *)&cliCfg, 0,
sizeof(CLI_Cfg));
325 cliCfg.cliPrompt =
"mmWAVE FMCW Radar Design:/>";
327 cliCfg.taskPriority = 3;
329 cliCfg.enableMMWaveExtension = 0U;
330 cliCfg.usePolledMode =
true;
331 cliCfg.tableEntry[0].cmd =
"basicCfg";
332 cliCfg.tableEntry[0].helpString =
"Basic Cfg [Hardcoded Parameters]";
335 cliCfg.tableEntry[1].cmd =
"advFrameCfg";
336 cliCfg.tableEntry[1].helpString =
"Advanced Frame Cfg [Hardcoded Parameters]";
339 cliCfg.tableEntry[2].cmd =
"sensorStart";
340 cliCfg.tableEntry[2].helpString =
"Start the sensor; ensure that the configuration is completed";
343 cliCfg.tableEntry[3].cmd =
"sensorStop";
344 cliCfg.tableEntry[3].helpString =
"Stop the sensor";
349 if (CLI_open (&cliCfg) < 0)
351 System_printf (
"[MSS] \t [ERROR] Unable to open the CLI\n");
354 System_printf (
"[MSS] \t [DEBUG] CLI is operational\n");