This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IWR1443BOOST: send config to IWR1443 without using visualizer

Part Number: IWR1443BOOST
Other Parts Discussed in Thread: IWR1443

Hi,

 I am trying to do a project using IWR1443 board on Linux platform.I want to be able to configure the board using code so i can have same configuration settings and need not to reconfigure it every time i power up the board. Can somebody guide me as to how this can be done?

Regards,

Neha

  • Hello Neha,

    The appropriate engineer has been assigned to your post. They should respond as soon as they are available.

    Regards,

    Adrian
  • I have done this using the CLI functions that are already present in the demo source code. I call my custom config function MmwDemo_IniRSSDSSCfg() from inside MmwDemo_CLIInit ().  MmwDemo_CLIInit () is defined in cli.c, found inside the mmwave demo project workspace. Everything for the custom config function is defined in ini_cfg.h and ini_cfg.h. It's a bit of clunky way of doing it, but it works. ini_cfg.h 

    /*
     * @file ini_cfg.c
     *
     *  Created on: Nov 9, 2017
     *      Author: hstubeda
     *
     *   @brief
     *      MMWave Demo automatic self-configuration
     *
     *  \par
     *  NOTE:
     *      (C) Copyright 2017 Ross Video, Ltd.
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include <string.h>
    /* mmWave SDK Include Files: */
    #include <ti/utils/cli/include/cli_internal.h>
    
    /* local includes */
    //#include "cli.h"
    #include "ini_cfg.h"
    
    /**************************************************************************
     *************************** Extern Definitions ***************************
     **************************************************************************/
    /* CLI Extended Command Functions */
    extern int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLIPeakGroupingCfg (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLIMultiObjBeamForming (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLICalibDcRangeSig (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[]);
    extern int32_t MmwDemo_CLISetDataLogger (int32_t argc, char* argv[]);
    
    
    /**************************************************************************
     ****************** Local Function Definitions ***************************
     **************************************************************************/
    
    /**
     *  @b Description
     *  @n
     *      This function uses CLI command string to configure the sensor;
     *      This function can be run from within code, and does not require user input from CLI.
     *
     *  @param[in] cmd[]
     *      CLI command, broken into its constituent arguments
     *      e.g multiObjBeamForming 1 0.5 is {"multiObjBeamForming", "1", "0.5"}
     *
     *  @retval
     *      Not Applicable.
     */
    void MmwDemo_CfgWithCmdString (uint32_t num_arg, char* cmd[])
    {
        if(     strcmp("sensorStop",          cmd[0]) == 0)
            MmwDemo_CLISensorStop         (num_arg, cmd);
    
        else if(strcmp("guiMonitor",          cmd[0]) == 0)
            MmwDemo_CLIGuiMonSel          (num_arg, cmd);
    
        else if(strcmp("cfarCfg",             cmd[0]) == 0)
            MmwDemo_CLICfarCfg            (num_arg, cmd);
    
        else if(strcmp("peakGrouping",        cmd[0]) == 0)
            MmwDemo_CLIPeakGroupingCfg    (num_arg, cmd);
    
        else if(strcmp("multiObjBeamForming", cmd[0]) == 0)
            MmwDemo_CLIMultiObjBeamForming(num_arg, cmd);
    
        else if(strcmp("calibDcRangeSig",     cmd[0]) == 0)
            MmwDemo_CLICalibDcRangeSig    (num_arg, cmd);
    
        else if(strcmp("sensorStart",         cmd[0]) == 0)
            MmwDemo_CLISensorStart        (num_arg, cmd);
    
        else
            CLI_MMWaveExtensionHandler    (num_arg, cmd);
    
        return;
    }
    
    /**
     *  @b Description
     *  @n
     *      This function instantiates initial configuration structure using CLI command strings,
     *      and uses these strings to configure the sensor
     *
     *  @param[in] cmd
     *      Commands
     *
     *  @retval
     *      Not Applicable.
     */
    void MmwDemo_IniRSSDSSCfg(void)
    {
        String_Cfg_Cmds iniCfgCmds;
        uint32_t c = 0;
    
        iniCfgCmds.sensorStop[0] = "sensorStop";
    
        iniCfgCmds.flushCfg[0] = "flushCfg";
    
        iniCfgCmds.dfeDataOutputMode[0] = "dfeDataOutputMode";
        iniCfgCmds.dfeDataOutputMode[1] = "1";
    
        iniCfgCmds.channelCfg[0] = "channelCfg";
        iniCfgCmds.channelCfg[1] = "15";
        iniCfgCmds.channelCfg[2] = "3";
        iniCfgCmds.channelCfg[3] = "0";
    
        iniCfgCmds.adcCfg[0] = "adcCfg";
        iniCfgCmds.adcCfg[1] = "2";
        iniCfgCmds.adcCfg[2] = "1";
    
        iniCfgCmds.adcbufCfg[0] = "adcbufCfg";
        iniCfgCmds.adcbufCfg[1] = "0";
        iniCfgCmds.adcbufCfg[2] = "0";
        iniCfgCmds.adcbufCfg[3] = "1";
        iniCfgCmds.adcbufCfg[4] = "1";
    
        iniCfgCmds.profileCfg [0] = "profileCfg";
        iniCfgCmds.profileCfg[ 1] = "0";
        iniCfgCmds.profileCfg[ 2] = "77";
        iniCfgCmds.profileCfg[ 3] = "194";
        iniCfgCmds.profileCfg[ 4] = "7";
        iniCfgCmds.profileCfg[ 5] = "40";
        iniCfgCmds.profileCfg[ 6] = "0";
        iniCfgCmds.profileCfg[ 7] = "0";
        iniCfgCmds.profileCfg[ 8] = "100";
        iniCfgCmds.profileCfg[ 9] = "1";
        iniCfgCmds.profileCfg[10] = "64";
        iniCfgCmds.profileCfg[11] = "2000";
        iniCfgCmds.profileCfg[12] = "0";
        iniCfgCmds.profileCfg[13] = "0";
        iniCfgCmds.profileCfg[14] = "30";
    
        iniCfgCmds.chirpCfg1[0] = "chirpCfg";
        iniCfgCmds.chirpCfg1[1] = "0";
        iniCfgCmds.chirpCfg1[2] = "0";
        iniCfgCmds.chirpCfg1[3] = "0";
        iniCfgCmds.chirpCfg1[4] = "0";
        iniCfgCmds.chirpCfg1[5] = "0";
        iniCfgCmds.chirpCfg1[6] = "0";
        iniCfgCmds.chirpCfg1[7] = "0";
        iniCfgCmds.chirpCfg1[8] = "1";
    
        iniCfgCmds.chirpCfg2[0] = "chirpCfg";
        iniCfgCmds.chirpCfg2[1] = "1";
        iniCfgCmds.chirpCfg2[2] = "1";
        iniCfgCmds.chirpCfg2[3] = "0";
        iniCfgCmds.chirpCfg2[4] = "0";
        iniCfgCmds.chirpCfg2[5] = "0";
        iniCfgCmds.chirpCfg2[6] = "0";
        iniCfgCmds.chirpCfg2[7] = "0";
        iniCfgCmds.chirpCfg2[8] = "2";
    
        iniCfgCmds.frameCfg[0] = "frameCfg";
        iniCfgCmds.frameCfg[1] = "0";
        iniCfgCmds.frameCfg[2] = "1";
        iniCfgCmds.frameCfg[3] = "16";
        iniCfgCmds.frameCfg[4] = "0";
        iniCfgCmds.frameCfg[5] = "100";
        iniCfgCmds.frameCfg[6] = "1";
        iniCfgCmds.frameCfg[7] = "0"; //frame delay upon sensor startup; change this value between different sensors to avoid sensor cross-interference
    
        iniCfgCmds.guiMonitor[0] = "guiMonitor";
        iniCfgCmds.guiMonitor[1] = "1";
        iniCfgCmds.guiMonitor[2] = "0";
        iniCfgCmds.guiMonitor[3] = "0";
        iniCfgCmds.guiMonitor[4] = "0";
        iniCfgCmds.guiMonitor[5] = "0";
        iniCfgCmds.guiMonitor[6] = "0";
    
        iniCfgCmds.cfarCfgRange[0] = "cfarCfg";
        iniCfgCmds.cfarCfgRange[1] = "0";
        iniCfgCmds.cfarCfgRange[2] = "0";
        iniCfgCmds.cfarCfgRange[3] = "8";
        iniCfgCmds.cfarCfgRange[4] = "4";
        iniCfgCmds.cfarCfgRange[5] = "4";
        iniCfgCmds.cfarCfgRange[6] = "0";
        iniCfgCmds.cfarCfgRange[7] = "5120";
    
        iniCfgCmds.cfarCfgDoppler[0] = "cfarCfg";
        iniCfgCmds.cfarCfgDoppler[1] = "1";
        iniCfgCmds.cfarCfgDoppler[2] = "0";
        iniCfgCmds.cfarCfgDoppler[3] = "4";
        iniCfgCmds.cfarCfgDoppler[4] = "2";
        iniCfgCmds.cfarCfgDoppler[5] = "3";
        iniCfgCmds.cfarCfgDoppler[6] = "0";
        iniCfgCmds.cfarCfgDoppler[7] = "3413";
    
        iniCfgCmds.peakGrouping[0] = "peakGrouping";
        iniCfgCmds.peakGrouping[1] = "1";
        iniCfgCmds.peakGrouping[2] = "1";
        iniCfgCmds.peakGrouping[3] = "1";
        iniCfgCmds.peakGrouping[4] = "1";
        iniCfgCmds.peakGrouping[5] = "63";
    
        iniCfgCmds.multiObjBeamForming[0] = "multiObjBeamForming";
        iniCfgCmds.multiObjBeamForming[1] = "1";
        iniCfgCmds.multiObjBeamForming[2] = "0.5";
    
        iniCfgCmds.calibDcRangeSig[0] = "calibDcRangeSig";
        iniCfgCmds.calibDcRangeSig[1] = "1";
        iniCfgCmds.calibDcRangeSig[2] = "-5";
        iniCfgCmds.calibDcRangeSig[3] = "20";
        iniCfgCmds.calibDcRangeSig[4] = "256";
    
        iniCfgCmds.sensorStart[0] = "sensorStart";
    
        //arrays cannot be set like this in C; need to copy them, or set each pointer individually, as was done above
        //iniCfgCmds.sensorStop          = {"sensorStop"};
        //iniCfgCmds.flushCfg            = {"flushCfg"};
        //iniCfgCmds.dfeDataOutputMode   = {"dfeDataOutputMode", "1"};
        //iniCfgCmds.channelCfg          = {"channelCfg", "15", "3", "0"};
        //iniCfgCmds.adcCfg              = {"adcCfg", "2", "1"};
        //iniCfgCmds.adcbufCfg           = {"adcbufCfg", "0", "0", "1", "1"};
        //iniCfgCmds.profileCfg          = {"profileCfg", "0", "77", "194", "7", "40", "0", "0", "100", "1", "64", "2000", "0", "0", "30"};
        //iniCfgCmds.chirpCfg1           = {"chirpCfg1", "0", "0", "0", "0", "0", "0", "0", "1"};
        //iniCfgCmds.chirpCfg2           = {"chirpCfg2", "1", "1", "0", "0", "0", "0", "0", "2"};
        //iniCfgCmds.frameCfg            = {"frameCfg", "0", "1", "16", "0", "100", "1", "0"};
        //iniCfgCmds.guiMonitor          = {"guiMonitor", "1", "0", "0", "0", "0", "0"};
        //iniCfgCmds.cfarCfgRange        = {"cfarCfg", "0", "0", "8", "4", "4", "0", "3413"};
        //iniCfgCmds.cfarCfgDoppler      = {"cfarCfg", "1", "0", "4", "2", "3", "0", "5120"};
        //iniCfgCmds.peakGrouping        = {"peakGrouping", "1", "1", "1", "1", "63"};
        //iniCfgCmds.multiObjBeamForming = {"multiObjBeamForming", "1", "0.5"};
        //iniCfgCmds.calibDcRangeSig     = {"calibDcRangeSig", "1", "-5", "20", "256"};
        //iniCfgCmds.sensorStart         = {"sensorStart"};
    
        MmwDemo_CfgWithCmdString ( 1, iniCfgCmds.sensorStop         );
        for (c = 1 ; c <= 50000000 ; c++); //this delay ensures the sensor stops
        MmwDemo_CfgWithCmdString ( 1, iniCfgCmds.flushCfg           );
        MmwDemo_CfgWithCmdString ( 2, iniCfgCmds.dfeDataOutputMode  );
        MmwDemo_CfgWithCmdString ( 4, iniCfgCmds.channelCfg         );
        MmwDemo_CfgWithCmdString ( 3, iniCfgCmds.adcCfg             );
        MmwDemo_CfgWithCmdString ( 5, iniCfgCmds.adcbufCfg          );
        MmwDemo_CfgWithCmdString (15, iniCfgCmds.profileCfg         );
        MmwDemo_CfgWithCmdString ( 9, iniCfgCmds.chirpCfg1          );
        MmwDemo_CfgWithCmdString ( 9, iniCfgCmds.chirpCfg2          );
        MmwDemo_CfgWithCmdString ( 8, iniCfgCmds.frameCfg           );
        MmwDemo_CfgWithCmdString ( 7, iniCfgCmds.guiMonitor         );
        MmwDemo_CfgWithCmdString ( 8, iniCfgCmds.cfarCfgRange       );
        MmwDemo_CfgWithCmdString ( 8, iniCfgCmds.cfarCfgDoppler     );
        MmwDemo_CfgWithCmdString ( 6, iniCfgCmds.peakGrouping       );
        MmwDemo_CfgWithCmdString ( 3, iniCfgCmds.multiObjBeamForming);
        MmwDemo_CfgWithCmdString ( 5, iniCfgCmds.calibDcRangeSig    );
        MmwDemo_CfgWithCmdString ( 1, iniCfgCmds.sensorStart        );
    
        return;
    }
    
    
     
    /*
     *   @file  cli.c
     *
     *   @brief
     *      Mmw (Milli-meter wave) DEMO CLI Implementation
     *
     *  \par
     *  NOTE:
     *      (C) Copyright 2016 Texas Instruments, Inc.
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /**************************************************************************
     *************************** Include Files ********************************
     **************************************************************************/
    
    /* Standard Include Files. */
    #include <stdint.h>
    #include <stdlib.h>
    #include <stddef.h>
    #include <string.h>
    #include <stdio.h>
    
    /* BIOS/XDC Include Files. */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/Memory.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/heaps/HeapBuf.h>
    #include <ti/sysbios/heaps/HeapMem.h>
    #include <ti/sysbios/knl/Event.h>
    
    /* mmWave SDK Include Files: */
    #include <ti/common/sys_common.h>
    #include <ti/common/mmwave_sdk_version.h>
    #include <ti/drivers/uart/UART.h>
    #include <ti/control/mmwavelink/mmwavelink.h>
    #include <ti/utils/cli/cli.h>
    #include <ti/utils/cli/include/cli_internal.h>
    
    /* Demo Include Files */
    #include "mss_mmw.h"
    #include "ini_cfg.h"
    //#include "cli.h"
    #include "ti/demo/xwr16xx/mmw/common/mmw_messages.h"
    
    /**************************************************************************
     *************************** Local Definitions ****************************
     **************************************************************************/
    /* CLI Extended Command Functions */
    /*static*/ int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[]);
    /*static*/ int32_t MmwDemo_CLIPeakGroupingCfg (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_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_CLISetDataLogger (int32_t argc, char* argv[]);
    
    
    /**************************************************************************
     *************************** Extern Definitions *******************************
     **************************************************************************/
    
    extern MmwDemo_MCB    gMmwMssMCB;
    extern int32_t MmwDemo_mboxWrite(MmwDemo_message     * message);
    
    
    
    /**************************************************************************
     *************************** CLI  Function Definitions **************************
     **************************************************************************/
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for the sensor start command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[])
    {
        bool doReconfig = true;
        if (argc==2)
        {
            doReconfig = (bool) atoi (argv[1]);
        }
        /* Post sensorSTart event to notify configuration is done */
        MmwDemo_notifySensorStart(doReconfig);
        /* Pend for completion */
        return (MmwDemo_waitSensorStartComplete());
    }
    
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for the sensor stop command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[])
    {
        /* Post sensorSTOP event to notify sensor stop command */
        MmwDemo_notifySensorStop();
        /* Pend for completion */
        MmwDemo_waitSensorStopComplete();
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for gui monitoring configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[])
    {
        MmwDemo_GuiMonSel   guiMonSel;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 7)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize the ADC Output configuration: */
        memset ((void *)&guiMonSel, 0, sizeof(MmwDemo_GuiMonSel));
    
        /* Populate configuration: */
        guiMonSel.detectedObjects           = atoi (argv[1]);
        guiMonSel.logMagRange               = atoi (argv[2]);
        guiMonSel.noiseProfile              = atoi (argv[3]);
        guiMonSel.rangeAzimuthHeatMap       = atoi (argv[4]);
        guiMonSel.rangeDopplerHeatMap       = atoi (argv[5]);
        guiMonSel.statsInfo                     = atoi (argv[6]);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.guiMonSel, (void *)&guiMonSel, sizeof(MmwDemo_GuiMonSel));
        
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_GUIMON_CFG;
        memcpy((void *)&message.body.guiMonSel, (void *)&guiMonSel, sizeof(MmwDemo_GuiMonSel));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for CFAR configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[])
    {
        MmwDemo_CfarCfg     cfarCfg;
        MmwDemo_message     message;
        uint32_t procDirection;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 8)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize configuration: */
        memset ((void *)&cfarCfg, 0, sizeof(MmwDemo_CfarCfg));
    
        /* Populate configuration: */
        procDirection             = (uint32_t) atoi (argv[1]);
        cfarCfg.averageMode       = (uint8_t) atoi (argv[2]);
        cfarCfg.winLen            = (uint8_t) atoi (argv[3]);
        cfarCfg.guardLen          = (uint8_t) atoi (argv[4]);
        cfarCfg.noiseDivShift     = (uint8_t) atoi (argv[5]);
        cfarCfg.cyclicMode        = (uint8_t) atoi (argv[6]);
        cfarCfg.thresholdScale    = (uint16_t) atoi (argv[7]);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.cfarCfg[procDirection], (void *)&cfarCfg, sizeof(MmwDemo_CfarCfg));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        if (procDirection == 0)
        {
            message.type = MMWDEMO_MSS2DSS_CFAR_RANGE_CFG;
        }
        else if (procDirection == 1)
        {
            message.type = MMWDEMO_MSS2DSS_CFAR_DOPPLER_CFG;
        }
        else
        {
            return -1;
        }
        memcpy((void *)&message.body.cfarCfg, (void *)&cfarCfg, sizeof(MmwDemo_CfarCfg));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;    
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for Peak grouping configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLIPeakGroupingCfg (int32_t argc, char* argv[])
    {
        MmwDemo_PeakGroupingCfg peakGroupingCfg;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 6)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize configuration: */
        memset ((void *)&peakGroupingCfg, 0, sizeof(MmwDemo_PeakGroupingCfg));
    
        /* Populate configuration: */
        peakGroupingCfg.scheme               = (uint8_t) atoi (argv[1]);
        peakGroupingCfg.inRangeDirectionEn   = (uint8_t) atoi (argv[2]);
        peakGroupingCfg.inDopplerDirectionEn = (uint8_t) atoi (argv[3]);
        peakGroupingCfg.minRangeIndex    = (uint8_t) atoi (argv[4]);
        peakGroupingCfg.maxRangeIndex    = (uint8_t) atoi (argv[5]);
    
        if (peakGroupingCfg.scheme != 1 && peakGroupingCfg.scheme != 2)
        {
            CLI_write ("Error: Invalid peak grouping scheme\n");
            return -1;
        }
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.peakGroupingCfg, (void *)&peakGroupingCfg, sizeof(MmwDemo_PeakGroupingCfg));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_PEAK_GROUPING_CFG;
        memcpy((void *)&message.body.peakGroupingCfg, (void *)&peakGroupingCfg, sizeof(MmwDemo_PeakGroupingCfg));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for multi object beam forming configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLIMultiObjBeamForming (int32_t argc, char* argv[])
    {
        MmwDemo_MultiObjBeamFormingCfg cfg;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 3)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize configuration: */
        memset ((void *)&cfg, 0, sizeof(MmwDemo_PeakGroupingCfg));
    
        /* Populate configuration: */
        cfg.enabled                     = (uint8_t) atoi (argv[1]);
        cfg.multiPeakThrsScal   = (float) atof (argv[2]);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.multiObjBeamFormingCfg, (void *)&cfg, sizeof(MmwDemo_MultiObjBeamFormingCfg));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_MULTI_OBJ_BEAM_FORM;
        memcpy((void *)&message.body.multiObjBeamFormingCfg, (void *)&cfg, sizeof(MmwDemo_MultiObjBeamFormingCfg));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    uint32_t log2Approx(uint32_t x)
    {
        uint32_t idx, detectFlag = 0;
    
        if ( x < 2)
        {
            return (0);
        }
    
        idx = 32U;
        while((detectFlag==0U) || (idx==0U))
        {
            if(x & 0x80000000U)
            {
                detectFlag = 1;
            }
            x <<= 1U;
            idx--;
        }
    
        if(x != 0)
        {
            idx = idx + 1;
        }
    
        return(idx);
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for DC range calibration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLICalibDcRangeSig (int32_t argc, char* argv[])
    {
        MmwDemo_CalibDcRangeSigCfg cfg;
        MmwDemo_message     message;
        uint32_t log2NumAvgChirps;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 5)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize configuration for DC range signature calibration */
        memset ((void *)&cfg, 0, sizeof(MmwDemo_CalibDcRangeSigCfg));
    
        /* Populate configuration: */
        cfg.enabled          = (uint16_t) atoi (argv[1]);
        cfg.negativeBinIdx   = (int16_t)  atoi (argv[2]);
        cfg.positiveBinIdx   = (int16_t)  atoi (argv[3]);
        cfg.numAvgChirps     = (uint16_t)  atoi (argv[4]);
    
        if (cfg.negativeBinIdx > 0)
        {
            CLI_write ("Error: Invalid negative bin index\n");
            return -1;
        }
        if ((cfg.positiveBinIdx - cfg.negativeBinIdx + 1) > DC_RANGE_SIGNATURE_COMP_MAX_BIN_SIZE)
        {
            CLI_write ("Error: Number of bins exceeds the limit\n");
            return -1;
        }
        log2NumAvgChirps = (uint32_t) log2Approx (cfg.numAvgChirps);
        if (cfg.numAvgChirps != (1 << log2NumAvgChirps))
        {
            CLI_write ("Error: Number of averaged chirps is not power of two\n");
            return -1;
        }
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.calibDcRangeSigCfg, (void *)&cfg, sizeof(MmwDemo_CalibDcRangeSigCfg));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_CALIB_DC_RANGE_SIG;
        memcpy((void *)&message.body.calibDcRangeSigCfg, (void *)&cfg, sizeof(MmwDemo_CalibDcRangeSigCfg));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for data logger set command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    /*static*/ int32_t MmwDemo_CLISetDataLogger (int32_t argc, char* argv[])
    {
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 2)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
    
        /* Save Configuration to use later */
        if (strcmp(argv[1], "mssLogger") == 0)  
            gMmwMssMCB.cfg.dataLogger = 0;
        else if (strcmp(argv[1], "dssLogger") == 0)  
            gMmwMssMCB.cfg.dataLogger = 1;
        else
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
           
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_SET_DATALOGGER;
        message.body.dataLogger = gMmwMssMCB.cfg.dataLogger;
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Execution Task
     *
     *  @retval
     *      Not Applicable.
     */
    void MmwDemo_CLIInit (void)
    {
        CLI_Cfg     cliCfg;
        char        demoBanner[256];
        uint32_t    cnt;
        /* Create Demo Banner to be printed out by CLI */
        sprintf(&demoBanner[0], 
                           "******************************************\n" \
                           "xWR16xx MMW Demo %02d.%02d.%02d.%02d\n"  \
                           "******************************************\n", 
                            MMWAVE_SDK_VERSION_MAJOR,
                            MMWAVE_SDK_VERSION_MINOR,
                            MMWAVE_SDK_VERSION_BUGFIX,
                            MMWAVE_SDK_VERSION_BUILD
                );
    
    
        /* Initialize the CLI configuration: */
        memset ((void *)&cliCfg, 0, sizeof(CLI_Cfg));
    
        /* Populate the CLI configuration: */
        cliCfg.cliPrompt                    = "mmwDemo:/>";
        cliCfg.cliBanner                    = demoBanner;
        cliCfg.cliUartHandle                = gMmwMssMCB.commandUartHandle;
        cliCfg.taskPriority                 = 3;
        cliCfg.mmWaveHandle                 = gMmwMssMCB.ctrlHandle;
        cliCfg.enableMMWaveExtension        = 1U;
        cliCfg.usePolledMode                = true;
        cnt=0;
        cliCfg.tableEntry[cnt].cmd            = "sensorStart";
        cliCfg.tableEntry[cnt].helpString     = "[doReconfig(optional, default:enabled)]";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLISensorStart;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "sensorStop";
        cliCfg.tableEntry[cnt].helpString     = "No arguments";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLISensorStop;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "guiMonitor";
        cliCfg.tableEntry[cnt].helpString     = "<detectedObjects> <logMagRange> <noiseProfile> <rangeAzimuthHeatMap> <rangeDopplerHeatMap> <statsInfo>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIGuiMonSel;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "cfarCfg";
        cliCfg.tableEntry[cnt].helpString     = "<procDirection> <averageMode> <winLen> <guardLen> <noiseDiv> <cyclicMode> <thresholdScale>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICfarCfg;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "peakGrouping";
        cliCfg.tableEntry[cnt].helpString     = "<groupingMode> <rangeDimEn> <dopplerDimEn> <startRangeIdx> <endRangeIdx>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIPeakGroupingCfg;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "dataLogger";
        cliCfg.tableEntry[cnt].helpString     = "<mssLogger | dssLogger>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLISetDataLogger;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "multiObjBeamForming";
        cliCfg.tableEntry[cnt].helpString     = "<enabled> <threshold>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIMultiObjBeamForming;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "calibDcRangeSig";
        cliCfg.tableEntry[cnt].helpString     = "<enabled> <negativeBinIdx> <positiveBinIdx> <numAvgFrames>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICalibDcRangeSig;
        cnt++;
    
    
        /* Open the CLI: */
        if (CLI_open (&cliCfg) < 0)
        {
            System_printf ("Error: Unable to open the CLI\n");
            return;
        }
        System_printf ("Debug: CLI is operational\n");
    
        //initial sensor configuration without CLI
        MmwDemo_IniRSSDSSCfg();
    
        return;
    }
    
    
    

  • Herman, Thanks for your very useful answer!

    Neha, As Herman mentioned, one way to hard-code the device configuration is to customize the mmWave Demo CLI (command line interface) code to use your desired settings instead of reading the parameters from a .cfg file. The other way would be to remove the CLI code and modify the device configuration API calls to use your desired parameters instead of the settings normally read from the .cfg file.

    Please mark the thread as answered if the issue is resolved or reply if more support is required.

    Regards,
    John
  • Neha,

    Would it be possible to mark the thread as answered if the issue is resolved or reply if more support is required?

    Regards,
    John

  • Hi! I tried following your method and was able to hard code the CLI parameters but i still couldn't figure out how to hard code ProfileCfg parameters and FrameCfg parameters. Any leads on that?
  • Neha,

    The ProfileCfg and FrameCfg parameters are part of the CLI parameters. They are specified on the "profileCfg" and "frameCfg" lines in the .cfg file. The individual parameters and their formats are described in the mmWave SDK user guide ("Configuration (.cfg) File Format" section).

    Please mark the thread as answered if the issue is resolved or reply if more support is required.

    Regards,
    John
  • There is an example of "profileCfg" and "frameCfg" being hardcoded in the ini_cfg.c

  • Neha,

    Would it be possible to mark the thread as answered if the issue is resolved or reply if more support is required?

    Regards,
    John