Browse Source

initial commit

master
Hannes 3 years ago
commit
df784d49bf

+ 40
- 0
.gitignore View File

@@ -0,0 +1,40 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Folder
.settings/
Debug/
.xdchelp
.ccsproject
.cproject
.project

+ 100
- 0
dss/c674x_linker.cmd View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
*/

#define L1P_CACHE_SIZE (4*1024)
#define L1D_CACHE_SIZE (16*1024)
#define MMWAVE_L3RAM_SIZE (MMWAVE_L3RAM_NUM_BANK*MMWAVE_SHMEM_BANK_SIZE - MMWAVE_MSSUSED_L3RAM_SIZE)

MEMORY
{
PAGE 0:

#if (L1P_CACHE_SIZE < 0x8000)
L1PSRAM: o = 0x00E00000, l = (0x00008000 - L1P_CACHE_SIZE)
#endif
#if (L1D_CACHE_SIZE < 0x8000)
L1DSRAM: o = 0x00F00000, l = (0x00008000 - L1D_CACHE_SIZE)
#endif
L2SRAM_UMAP1: o = 0x007E0000, l = 0x00020000
L2SRAM_UMAP0: o = 0x00800000, l = 0x00020000
L3SRAM: o = (0x20000000+MMWAVE_MSSUSED_L3RAM_SIZE), l = MMWAVE_L3RAM_SIZE
L3SRAMOVLY: o = 0x20000000, l = MMWAVE_MSSUSED_L3RAM_SIZE
HWA_RAM : o = 0x21030000, l = 0x00010000
HSRAM: o = 0x21080000, l = 0x8000

/* PAGEs 1 and onwards are for overlay purposes for memory optimization.
Some examples:
1. Overlay one-time only text with uninitialized data.
2. Overlay L1PSRAM data path processing fast code and use copy tables
to page in (before entering data path) and out of L1PSRAM (when entering
sleep/low power).
*/
PAGE 1:
L3SRAM: o = (0x20000000+MMWAVE_MSSUSED_L3RAM_SIZE), l = MMWAVE_L3RAM_SIZE
}

/* Set L1D, L1P and L2 Cache Sizes */
ti_sysbios_family_c64p_Cache_l1dSize = L1D_CACHE_SIZE;
ti_sysbios_family_c64p_Cache_l1pSize = L1P_CACHE_SIZE;
ti_sysbios_family_c64p_Cache_l2Size = 0;

SECTIONS
{
/* hard addresses forces vecs to be allocated there */
.vecs: {. = align(32); } > 0x007E0000

/* Allocate data preferentially in one UMAP and code (.text) in another,
this can improve performance due to simultaneous misses from L1P
and L1D caches to L2 SRAM, for more information see C674 Megamodule
User Guide section "Level 2 Memory Architecture".
The linker notation "X >> Y | Z" indicates section X is first allocated in Y
and allowed to overflow into Z and can be split from Y to Z.
The linker notation "X > Y | Z" indicates section X is first allocated in Y
and allowed to overflow into Z and cannot be split from Y to Z. Some sections
like bss are not allowed to be split so > notation is used for them */

.fardata: {} >> L2SRAM_UMAP0 | L2SRAM_UMAP1
.const: {} >> L2SRAM_UMAP0 | L2SRAM_UMAP1
.switch: {} >> L2SRAM_UMAP0 | L2SRAM_UMAP1
.cio: {} >> L2SRAM_UMAP0 | L2SRAM_UMAP1
.data: {} >> L2SRAM_UMAP0 | L2SRAM_UMAP1

.rodata: {} > L2SRAM_UMAP0 | L2SRAM_UMAP1
.bss: {} > L2SRAM_UMAP0 | L2SRAM_UMAP1
.neardata: {} > L2SRAM_UMAP0 | L2SRAM_UMAP1
.stack: {} > L2SRAM_UMAP0 | L2SRAM_UMAP1
.cinit: {} > L2SRAM_UMAP0 | L2SRAM_UMAP1
.far: {} > L2SRAM_UMAP0 | L2SRAM_UMAP1

.text: {} >> L2SRAM_UMAP1 | L2SRAM_UMAP0
}


+ 97
- 0
dss/copyTranspose.c View File

@@ -0,0 +1,97 @@
/*!
* \file copyTranspose.c
*
* \brief Copy with transpose function.
*
* Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
*
*
* 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 <common/src/dpu/capon3d/include/copyTranspose.h>

#if 0
uint32_t copyTranspose(uint32_t * src, uint32_t * dest, uint32_t size, int32_t offset, uint32_t stride, uint32_t pairs)
{
int32_t i, j, k;
j = 0;
for(i = 0; i < (int32_t)size; i++)
{
for (k = 0; k < (int32_t)pairs; k++)
{
dest[j+k+i*offset] = src[pairs * i + k];
}
j += (int32_t)stride;
}
return(1);
}
#else

// for optimization purposes specific for 3D capon people counting, will ignore offset and pair parameter.
uint32_t copyTranspose(uint32_t * RESTRICT src, uint32_t * RESTRICT dest, uint32_t size, int32_t offset, uint32_t stride, uint32_t pairs)
{
int32_t i;
int32_t sizeOver4;
uint64_t * RESTRICT input, lltemp1;
uint32_t * RESTRICT output;
uint32_t * RESTRICT input1;

sizeOver4 = (int32_t) (size >> 2);
input = (uint64_t *) src;
output = dest;

for(i = 0; i < sizeOver4; i++)
{
lltemp1 = _amem8(input++);
* output = _loll(lltemp1);
output += stride;
* output = _hill(lltemp1);
output += stride;
lltemp1 = _amem8(input++);
* output = _loll(lltemp1);
output += stride;
* output = _hill(lltemp1);
output += stride;
}

input1 = (uint32_t *) src;
i = i * 4;
for(; i < (int32_t)size; i++)
{
* output = input1[i];
output += stride;
}

return(1);
}

#endif


+ 832
- 0
dss/dss_main.c View File

@@ -0,0 +1,832 @@
/**
* @file dss_main.c
*
* @brief
* This is the main file which implements the 3D people counting Demo on DSS.
*
* \par
* NOTE:
* (C) Copyright 2019 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>
#include <math.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>
#include <ti/sysbios/utils/Load.h>
#include <ti/sysbios/family/c64p/Hwi.h>

/* mmWave SDK Include Files: */
#include <ti/common/sys_common.h>
#include <ti/control/dpm/dpm.h>
#include <ti/drivers/soc/soc.h>
#include <ti/drivers/esm/esm.h>
#include <ti/drivers/crc/crc.h>
#include <ti/drivers/osal/DebugP.h>

/* Data path Include Files */
#include <common/src/dpc/capon3d/objectdetection.h>

/* Demo Include Files */
#include <people_counting/68xx_3D_people_counting/src/common/pcount3D_output.h>
#include "pcount3D_dss.h"
#include <people_counting/68xx_3D_people_counting/src/common/pcount3D_hwres.h>

/* Demo Profiling Include Files */
#include <ti/utils/cycleprofiler/cycle_profiler.h>

/**
* @brief Task Priority settings:
*/
#define MMWDEMO_DPC_OBJDET_DPM_TASK_PRIORITY 5

#define DEBUG(_x) //_x
//#define BUILDFORMETHOD2


#ifdef BUILDFORMETHOD2
#define L2HEAPSIZE (0x1B000) // for method 2 and full FoV support of ODS
#define L3HEAPSIZE (0x2D000) // for method 2 and full FoV support of ODS
#else
#define L2HEAPSIZE (0x19600) // for method 1 ISK and +/- 20 degree elev FOV of ODS
#define L3HEAPSIZE (0x21000) // for method 1 ISK and +/- 20 degree elev FOV of ODS
#endif

#define L2SCRATCHSIZE (0x900)
#define L1SCRATCHSIZE (0x1200)
#define L1HEAPSIZE (0x2E00)
#pragma DATA_SECTION(memHeapL2, ".dpc_l2Heap")
uint8_t memHeapL2[L2HEAPSIZE];
#pragma DATA_SECTION(memHeapL3, ".l3data")
uint8_t memHeapL3[L3HEAPSIZE];
#pragma DATA_SECTION(l2ScratchMem, ".dpc_l2Heap")
uint8_t l2ScratchMem[L2SCRATCHSIZE];
#pragma DATA_SECTION(l1ScratchMem, ".dpc_l1Heap")
uint8_t l1ScratchMem[L1SCRATCHSIZE];
#pragma DATA_SECTION(l1HeapMem, ".dpc_l1Heap")
uint8_t l1HeapMem[L1HEAPSIZE];

#define DPC_OBJDET_DSP_INSTANCEID (0xDEEDDEED)

/**************************************************************************
*************************** Global Definitions ***************************
**************************************************************************/

/**
* @brief
* Global Variable for tracking information required by the mmw Demo
*/
Pcount3DDemo_DSS_MCB gPcount3DDssMCB;

/**
* @brief
* Global Variable for DPM result buffer
*/
DPM_Buffer resultBuffer;


/**************************************************************************
******************* Millimeter Wave Demo Functions Prototype *******************
**************************************************************************/
static void Pcount3DDemo_dssInitTask(UArg arg0, UArg arg1);
static void Pcount3DDemo_DPC_RadarProc_reportFxn
(
DPM_Report reportType,
uint32_t instanceId,
int32_t errCode,
uint32_t arg0,
uint32_t arg1
);
static void Pcount3DDemo_DPC_processFrameBeginCallBackFxn(uint8_t subFrameIndx);
static void Pcount3DDemo_DPC_processInterFrameBeginCallBackFxn(uint8_t subFrameIndx);
static void Pcount3DDemo_DPC_RadarProc_dpmTask(UArg arg0, UArg arg1);
static void Pcount3DDemo_sensorStopEpilog(void);


/* copy table related */
extern far COPY_TABLE _pcount3DDemo_fastCode_L1PSRAM_copy_table;
extern far COPY_TABLE _pcount3DDemo_configCode_HSRAM_copy_table;

static void MmwDemo_copyTable(EDMA_Handle handle, COPY_TABLE *tp);
static void MmwDemo_edmaBlockCopy(EDMA_Handle handle, uint32_t loadAddr, uint32_t runAddr, uint16_t size);


/**
* @b Description
* @n
* Performs linker generated copy table copy using EDMA. Currently this is
* used to page in fast code from L3 to L1PSRAM.
* @param[in] handle EDMA handle
* @param[in] tp Pointer to copy table
*
* @retval
* Not Applicable.
*/
static void MmwDemo_copyTable(EDMA_Handle handle, COPY_TABLE *tp)
{
uint16_t i;
COPY_RECORD crp;
uint32_t loadAddr;
uint32_t runAddr;

for (i = 0; i < tp->num_recs; i++)
{
crp = tp->recs[i];
loadAddr = (uint32_t)crp.load_addr;
runAddr = (uint32_t)crp.run_addr;

/* currently we use only one count of EDMA which is 16-bit so we cannot
handle tables bigger than 64 KB */
DebugP_assert(crp.size <= 65536U);

if (crp.size)
{
MmwDemo_edmaBlockCopy(handle, loadAddr, runAddr, crp.size);
}
}
}

/**
* @b Description
* @n
* Performs simple block copy using EDMA. Used for the purpose of copying
* linker table for L3 to L1PSRAM copy. memcpy cannot be used because there is
* no data bus access to L1PSRAM.
*
* @param[in] handle EDMA handle
* @param[in] loadAddr load address
* @param[in] runAddr run address
* @param[in] size size in bytes
*
* @retval
* Not Applicable.
*/
static void MmwDemo_edmaBlockCopy(EDMA_Handle handle, uint32_t loadAddr, uint32_t runAddr, uint16_t size)
{
EDMA_channelConfig_t config;
volatile bool isTransferDone;

config.channelId = EDMA_TPCC0_REQ_FREE_0;
config.channelType = (uint8_t)EDMA3_CHANNEL_TYPE_DMA;
config.paramId = (uint16_t)EDMA_TPCC0_REQ_FREE_0;
config.eventQueueId = 0;

config.paramSetConfig.sourceAddress = (uint32_t) SOC_translateAddress((uint32_t)loadAddr,
SOC_TranslateAddr_Dir_TO_EDMA, NULL);
config.paramSetConfig.destinationAddress = (uint32_t) SOC_translateAddress((uint32_t)runAddr,
SOC_TranslateAddr_Dir_TO_EDMA, NULL);

config.paramSetConfig.aCount = size;
config.paramSetConfig.bCount = 1U;
config.paramSetConfig.cCount = 1U;
config.paramSetConfig.bCountReload = 0U;

config.paramSetConfig.sourceBindex = 0U;
config.paramSetConfig.destinationBindex = 0U;

config.paramSetConfig.sourceCindex = 0U;
config.paramSetConfig.destinationCindex = 0U;

config.paramSetConfig.linkAddress = EDMA_NULL_LINK_ADDRESS;
config.paramSetConfig.transferType = (uint8_t)EDMA3_SYNC_A;
config.paramSetConfig.transferCompletionCode = (uint8_t) EDMA_TPCC0_REQ_FREE_0;
config.paramSetConfig.sourceAddressingMode = (uint8_t) EDMA3_ADDRESSING_MODE_LINEAR;
config.paramSetConfig.destinationAddressingMode = (uint8_t) EDMA3_ADDRESSING_MODE_LINEAR;

/* don't care because of linear addressing modes above */
config.paramSetConfig.fifoWidth = (uint8_t) EDMA3_FIFO_WIDTH_8BIT;

config.paramSetConfig.isStaticSet = false;
config.paramSetConfig.isEarlyCompletion = false;
config.paramSetConfig.isFinalTransferInterruptEnabled = true;
config.paramSetConfig.isIntermediateTransferInterruptEnabled = false;
config.paramSetConfig.isFinalChainingEnabled = false;
config.paramSetConfig.isIntermediateChainingEnabled = false;
config.transferCompletionCallbackFxn = NULL;
config.transferCompletionCallbackFxnArg = NULL;

if (EDMA_configChannel(handle, &config, false) != EDMA_NO_ERROR)
{
DebugP_assert(0);
}

if (EDMA_startDmaTransfer(handle, config.channelId) != EDMA_NO_ERROR)
{
DebugP_assert(0);
}

/* wait until transfer done */
do {
if (EDMA_isTransferComplete(handle,
config.paramSetConfig.transferCompletionCode,
(bool *)&isTransferDone) != EDMA_NO_ERROR)
{
DebugP_assert(0);
}
} while (isTransferDone == false);

/* make sure to disable channel so it is usable later */
EDMA_disableChannel(handle, config.channelId, config.channelType);
}


/**
* @b Description
* @n
* EDMA driver init
*
* @param[in] obj Pointer to data path object
*
* @retval
* Not Applicable.
*/
void MmwDemo_edmaInit(Pcount3DDemo_DataPathObj *obj, uint8_t instance)
{
int32_t errorCode;

errorCode = EDMA_init(instance);
if (errorCode != EDMA_NO_ERROR)
{
//System_printf ("Debug: EDMA instance %d initialization returned error %d\n", errorCode);
Pcount3DDemo_debugAssert (0);
return;
}

memset(&obj->EDMA_errorInfo, 0, sizeof(obj->EDMA_errorInfo));
memset(&obj->EDMA_transferControllerErrorInfo, 0, sizeof(obj->EDMA_transferControllerErrorInfo));
}

/**
* @b Description
* @n
* Call back function for EDMA CC (Channel controller) error as per EDMA API.
* Declare fatal error if happens, the output errorInfo can be examined if code
* gets trapped here.
*/
void MmwDemo_EDMA_errorCallbackFxn(EDMA_Handle handle, EDMA_errorInfo_t *errorInfo)
{
gPcount3DDssMCB.dataPathObj.EDMA_errorInfo = *errorInfo;
Pcount3DDemo_debugAssert(0);
}

/**
* @b Description
* @n
* Call back function for EDMA transfer controller error as per EDMA API.
* Declare fatal error if happens, the output errorInfo can be examined if code
* gets trapped here.
*/
void MmwDemo_EDMA_transferControllerErrorCallbackFxn(EDMA_Handle handle,
EDMA_transferControllerErrorInfo_t *errorInfo)
{
gPcount3DDssMCB.dataPathObj.EDMA_transferControllerErrorInfo = *errorInfo;
Pcount3DDemo_debugAssert(0);
}

/**
* @b Description
* @n
* Open EDMA driver instance
*
* @param[in] obj Pointer to data path object
* @param[in] instance EDMA instance
*
* @retval
* Not Applicable.
*/
static void MmwDemo_edmaOpen(Pcount3DDemo_DataPathObj *obj, uint8_t instance)
{
int32_t errCode;
EDMA_instanceInfo_t edmaInstanceInfo;
EDMA_errorConfig_t errorConfig;

obj->edmaHandle = EDMA_open(
instance,
&errCode,
&edmaInstanceInfo);
if (obj->edmaHandle == NULL)
{
Pcount3DDemo_debugAssert (0);
return;
}

errorConfig.isConfigAllEventQueues = true;
errorConfig.isConfigAllTransferControllers = true;
errorConfig.isEventQueueThresholdingEnabled = true;
errorConfig.eventQueueThreshold = EDMA_EVENT_QUEUE_THRESHOLD_MAX;
errorConfig.isEnableAllTransferControllerErrors = true;
errorConfig.callbackFxn = MmwDemo_EDMA_errorCallbackFxn;
errorConfig.transferControllerCallbackFxn = MmwDemo_EDMA_transferControllerErrorCallbackFxn;
if ((errCode = EDMA_configErrorMonitoring(obj->edmaHandle, &errorConfig)) != EDMA_NO_ERROR)
{
//System_printf("Error: EDMA_configErrorMonitoring() failed with errorCode = %d\n", errCode);
Pcount3DDemo_debugAssert (0);
return;
}
}

/**
* @b Description
* @n
* Close EDMA driver instance
*
* @param[in] obj Pointer to data path object
*
* @retval
* Not Applicable.
*/
void MmwDemo_edmaClose(Pcount3DDemo_DataPathObj *obj)
{
EDMA_close(obj->edmaHandle);
}


/**
* @b Description
* @n
* Epilog processing after sensor has stopped
*
* @retval None
*/
static void Pcount3DDemo_sensorStopEpilog(void)
{
Hwi_StackInfo stackInfo;
Task_Stat stat;
bool hwiStackOverflow;

DEBUG(System_printf("Data Path Stopped (last frame processing done)\n");)

/* Print DSS task statistics */
DEBUG(System_printf("DSS Task Stack Usage (Note: Task Stack Usage) ==========\n");)

Task_stat(gPcount3DDssMCB.initTaskHandle, &stat);
DEBUG(System_printf("%20s %12d %12d %12d\n", "initTask",
stat.stackSize,
stat.used,
stat.stackSize - stat.used);)

Task_stat(gPcount3DDssMCB.radarProcDpmTaskHandle, &stat);
DEBUG(System_printf("%20s %12s %12s %12s\n", "Task Name", "Size", "Used", "Free");)
DEBUG(System_printf("%20s %12d %12d %12d\n", "ObjDet DPM",
stat.stackSize,
stat.used,
stat.stackSize - stat.used);)

DEBUG(System_printf("HWI Stack (same as System Stack) Usage ============\n");)
hwiStackOverflow = Hwi_getStackInfo(&stackInfo, TRUE);
if (hwiStackOverflow == TRUE)
{
DEBUG(System_printf("DSS HWI Stack overflowed\n");)
Pcount3DDemo_debugAssert(0);
}
else
{
DEBUG(System_printf("%20s %12s %12s %12s\n", " ", "Size", "Used", "Free");)
DEBUG(System_printf("%20s %12d %12d %12d\n", " ",
stackInfo.hwiStackSize,
stackInfo.hwiStackPeak,
stackInfo.hwiStackSize - stackInfo.hwiStackPeak);)
}
}

/**
* @b Description
* @n
* DPM Registered Report Handler. The DPM Module uses this registered function to notify
* the application about DPM reports.
*
* @param[in] reportType
* Report Type
* @param[in] instanceId
* Instance Identifier which generated the report
* @param[in] errCode
* Error code if any.
* @param[in] arg0
* Argument 0 interpreted with the report type
* @param[in] arg1
* Argument 1 interpreted with the report type
*
* @retval
* Not Applicable.
*/
static void Pcount3DDemo_DPC_RadarProc_reportFxn
(
DPM_Report reportType,
uint32_t instanceId,
int32_t errCode,
uint32_t arg0,
uint32_t arg1
)
{

/* Only errors are logged on the console: */
if (errCode != 0)
{
/* Error: Detected log on the console and die all errors are FATAL currently. */
DEBUG(System_printf ("Error: DPM Report %d received with error:%d arg0:0x%x arg1:0x%x\n",
reportType, errCode, arg0, arg1);)
DebugP_assert (0);
}

/* Processing further is based on the reports received: This is the control of the profile
* state machine: */
switch (reportType)
{
case DPM_Report_IOCTL:
{
/*****************************************************************
* DPC has been configured without an error:
* - This is an indication that the profile configuration commands
* went through without any issues.
*****************************************************************/
DebugP_log1("DSSApp: DPM Report IOCTL, command = %d\n", arg0);
break;
}
case DPM_Report_DPC_STARTED:
{
/*****************************************************************
* DPC has been started without an error:
* - notify sensor management task that DPC is started.
*****************************************************************/
DebugP_log0("DSSApp: DPM Report start\n");
gPcount3DDssMCB.dpmStartEvents++;
break;
}
case DPM_Report_NOTIFY_DPC_RESULT:
{
/*****************************************************************
* DPC Results have been passed:
* - This implies that we have valid profile results which have
* been received from the profile.
*****************************************************************/

break;
}
case DPM_Report_NOTIFY_DPC_RESULT_ACKED:
{
/*****************************************************************
* DPC Results have been acked:
* - This implies that MSS received the results.
*****************************************************************/

break;
}
case DPM_Report_DPC_ASSERT:
{
DPM_DPCAssert* ptrAssert;

/*****************************************************************
* DPC Fault has been detected:
* - This implies that the DPC has crashed.
* - The argument0 points to the DPC assertion information
*****************************************************************/
ptrAssert = (DPM_DPCAssert*)arg0;
System_printf ("DSS Exception: %s, line %d.\n", ptrAssert->fileName,
ptrAssert->lineNum);
break;
}
case DPM_Report_DPC_STOPPED:
{
/*****************************************************************
* DPC has been stopped without an error:
* - This implies that the DPC can either be reconfigured or
* restarted.
*****************************************************************/
DebugP_log0("DSSApp: DPM Report stop\n");
gPcount3DDssMCB.dpmStopEvents++;
if (gPcount3DDssMCB.dpmStopEvents % 2 == 1) {
Pcount3DDemo_sensorStopEpilog();
}
break;
}
case DPM_Report_DPC_INFO:
{
/* Currently chain does not use this feature. */
break;
}
default:
{
DebugP_assert (0);
break;
}
}
return;
}

/**
* @b Description
* @n
* Call back function that was registered during config time and is going
* to be called in DPC processing at the beginning of frame/sub-frame processing.
* Note: In this demo objdetdsp DPC only have inter-frame processing, hence this
* callback function won't be called.
*
* @param[in] subFrameIndx Sub-frame index of the sub-frame during which processing
* this function was called.
*
* @retval None
*/
static void Pcount3DDemo_DPC_processFrameBeginCallBackFxn(uint8_t subFrameIndx)
{
/* Empty function */
}

/**
* @b Description
* @n
* Call back function that was registered during config time and is going
* to be called in DPC processing at the beginning of inter-frame/inter-sub-frame processing,
* we use this to issue BIOS calls for computing CPU load during active frame (chirping)
*
* @param[in] subFrameIndx Sub-frame index of the sub-frame during which processing
* this function was called.
*
* @retval None
*/
static void Pcount3DDemo_DPC_processInterFrameBeginCallBackFxn(uint8_t subFrameIndx)
{
Load_update();
gPcount3DDssMCB.dataPathObj.subFrameStats[subFrameIndx].interFrameCPULoad = Load_getCPULoad();
}


/**
* @b Description
* @n
* DPM Execution Task. DPM execute results are processed here:
* a) Update states based on timestamp from DPC.
* b) Copy results to shared memory to be shared with MSS.
* c) Send Results to MSS by calling DPM_sendResult()
*
* @retval
* Not Applicable.
*/
static void Pcount3DDemo_DPC_RadarProc_dpmTask(UArg arg0, UArg arg1)
{
int32_t retVal;
//DPC_ObjectDetection_ExecuteResult *result;
volatile uint32_t startTime;

while (1)
{
/* Execute the DPM module: */
//DebugP_log0("DSS main: Pcount3DDemo_DPC_RadarProc_dpmTask\n");
retVal = DPM_execute (gPcount3DDssMCB.dataPathObj.radarProcDpmHandle, &resultBuffer);
if (retVal < 0) {
DEBUG(System_printf ("Error: DPM execution failed [Error code %d]\n", retVal);)
Pcount3DDemo_debugAssert (0);
}
else
{
if ((resultBuffer.size[0] == sizeof(DPC_ObjectDetection_ExecuteResult)))
{

retVal = DPM_sendResult (gPcount3DDssMCB.dataPathObj.radarProcDpmHandle, true, &resultBuffer);
if (retVal < 0)
{
DEBUG(System_printf ("Error: Failed to send results [Error: %d] to remote\n", retVal);)
}

}
}
//writeback all the data shared with R4 in L3, and prepare cache for next frames radar cube from R4.
cache_wbInvAllL2Wait();
}
}

/**
* @b Description
* @n
* System Initialization Task which initializes the various
* components in the system.
*
* @retval
* Not Applicable.
*/
static void Pcount3DDemo_dssInitTask(UArg arg0, UArg arg1)
{
int32_t errCode;
Task_Params taskParams;
DPM_InitCfg dpmInitCfg;
DPC_ObjectDetection_InitParams objDetInitParams;

/*****************************************************************************
* Driver Init:
*****************************************************************************/

/*****************************************************************************
* Driver Open/Configuraiton:
*****************************************************************************/
/* Initialize EDMA */
MmwDemo_edmaInit(&gPcount3DDssMCB.dataPathObj, DPC_OBJDET_DSP_EDMA_INSTANCE);

/* Use instance 1 on DSS */
MmwDemo_edmaOpen(&gPcount3DDssMCB.dataPathObj, DPC_OBJDET_DSP_EDMA_INSTANCE);

/* Copy code from L3 to L1PSRAM, this code related to data path processing */
MmwDemo_copyTable(gPcount3DDssMCB.dataPathObj.edmaHandle, &_pcount3DDemo_fastCode_L1PSRAM_copy_table);
MmwDemo_copyTable(gPcount3DDssMCB.dataPathObj.edmaHandle, &_pcount3DDemo_configCode_HSRAM_copy_table);

/* Initialize the Mailbox */
Mailbox_init(MAILBOX_TYPE_DSS);


/*****************************************************************************
* Initialization of the DPM Module:
*****************************************************************************/
DebugP_log0("DSS main: Pcount3DDemo_dssInitTask\n");

memset ((void *)&objDetInitParams, 0, sizeof(DPC_ObjectDetection_InitParams));
/*Set up init params for memory osal*/
objDetInitParams.L3HeapCfg.addr = (void *) &memHeapL3[0];
objDetInitParams.L3HeapCfg.size = L3HEAPSIZE;
objDetInitParams.L3ScratchCfg.addr = (void *) NULL;
objDetInitParams.L3ScratchCfg.size = 0;
objDetInitParams.CoreL2HeapCfg.addr = (void *) &memHeapL2[0];
objDetInitParams.CoreL2HeapCfg.size = L2HEAPSIZE;
objDetInitParams.CoreL2ScratchCfg.addr = (void *) &l2ScratchMem[0];
objDetInitParams.CoreL2ScratchCfg.size = L2SCRATCHSIZE;
objDetInitParams.CoreL1HeapCfg.addr = (void *) &l1HeapMem[0];
objDetInitParams.CoreL1HeapCfg.size = L1HEAPSIZE;
objDetInitParams.CoreL1ScratchCfg.addr = (void *) &l1ScratchMem[0];
objDetInitParams.CoreL1ScratchCfg.size = L1SCRATCHSIZE;

/* DPC Call-back config */
objDetInitParams.processCallBackCfg.processFrameBeginCallBackFxn =
Pcount3DDemo_DPC_processFrameBeginCallBackFxn;
objDetInitParams.processCallBackCfg.processInterFrameBeginCallBackFxn =
Pcount3DDemo_DPC_processInterFrameBeginCallBackFxn;

memset ((void *)&dpmInitCfg, 0, sizeof(DPM_InitCfg));

/* Setup the configuration: */
dpmInitCfg.socHandle = gPcount3DDssMCB.socHandle;
dpmInitCfg.ptrProcChainCfg = &gDPC_ObjectDetectionCfg;
dpmInitCfg.instanceId = DPC_OBJDET_DSP_INSTANCEID;
dpmInitCfg.domain = DPM_Domain_DISTRIBUTED;
dpmInitCfg.reportFxn = Pcount3DDemo_DPC_RadarProc_reportFxn;
dpmInitCfg.arg = &objDetInitParams;
dpmInitCfg.argSize = sizeof(DPC_ObjectDetection_InitParams);

/* Initialize the DPM Module: */
gPcount3DDssMCB.dataPathObj.radarProcDpmHandle = DPM_init (&dpmInitCfg, &errCode);
if (gPcount3DDssMCB.dataPathObj.radarProcDpmHandle == NULL)
{
DEBUG(System_printf ("Error: Unable to initialize the DPM Module [Error: %d]\n", errCode);)
Pcount3DDemo_debugAssert (0);
return;
}

/* Synchronization: This will synchronize the execution of the control module
* between the domains. This is a prerequiste and always needs to be invoked. */
while (1)
{
int32_t syncStatus;

/* Get the synchronization status: */
syncStatus = DPM_synch (gPcount3DDssMCB.dataPathObj.radarProcDpmHandle, &errCode);
if (syncStatus < 0)
{
/* Error: Unable to synchronize the framework */
DEBUG(System_printf ("Error: DPM Synchronization failed [Error code %d]\n", errCode);)
Pcount3DDemo_debugAssert (0);
return;
}
if (syncStatus == 1)
{
/* Synchronization acheived: */
break;
}
/* Sleep and poll again: */
Task_sleep(1);
}
System_printf ("Debug: DPM Module Sync is done\n");

/* Launch the DPM Task */
Task_Params_init(&taskParams);
taskParams.priority = MMWDEMO_DPC_OBJDET_DPM_TASK_PRIORITY;
taskParams.stackSize = 3*1024;
gPcount3DDssMCB.radarProcDpmTaskHandle = Task_create(Pcount3DDemo_DPC_RadarProc_dpmTask, &taskParams, NULL);

return;
}

/**
* @b Description
* @n
* Function to sleep the DSP using IDLE instruction.
* When DSP has no work left to do,
* the BIOS will be in Idle thread and will call this function.
*
* @retval
* Not Applicable.
*/
void Pcount3DDemo_sleep(void)
{
/* issue WFI (Wait For Interrupt) instruction */
asm(" IDLE ");
}

/**
* @b Description
* @n
* Entry point into the Millimeter Wave Demo
*
* @retval
* Not Applicable.
*/
int main (void)
{
Task_Params taskParams;
int32_t errCode;
SOC_Handle socHandle;
SOC_Cfg socCfg;

// set cache state for l3 and hsram
cache_setMar((unsigned int *)0x20000000, 0xC0000, Cache_PC | Cache_PFX);
//cache_setMar((unsigned int *)0x21080000, 0x8000, Cache_PC | Cache_PFX);


/* Initialize and populate the demo MCB */
memset ((void*)&gPcount3DDssMCB, 0, sizeof(Pcount3DDemo_DSS_MCB));

/* Initialize the SOC confiugration: */
memset ((void *)&socCfg, 0, sizeof(SOC_Cfg));

/* Populate the SOC configuration: */
socCfg.clockCfg = SOC_SysClock_BYPASS_INIT;

/* Initialize the SOC Module: This is done as soon as the application is started
* to ensure that the MPU is correctly configured. */
socHandle = SOC_init (&socCfg, &errCode);
if (socHandle == NULL)
{
DEBUG(System_printf ("Error: SOC Module Initialization failed [Error code %d]\n", errCode);)
Pcount3DDemo_debugAssert (0);
return -1;
}

gPcount3DDssMCB.socHandle = socHandle;

/* Initialize the Task Parameters. */
Task_Params_init(&taskParams);
taskParams.stackSize = 1536;
gPcount3DDssMCB.initTaskHandle = Task_create(Pcount3DDemo_dssInitTask, &taskParams, NULL);

/* Start BIOS */
BIOS_start();
return 0;
}

+ 910
- 0
dss/objectdetection.c View File

@@ -0,0 +1,910 @@
/*
* @file objectdetection.c
*
* @brief
* Object Detection DPC implementation using DSP.
*
* \par
* NOTE:
* (C) Copyright 2019 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 ********************************
**************************************************************************/
#include <stdint.h>
#include <string.h>
#include <stdio.h>

/* mmWave SDK Include Files: */
#include <ti/drivers/soc/soc.h>
#include <ti/common/sys_common.h>
#include <ti/drivers/osal/DebugP.h>
#include <ti/drivers/osal/MemoryP.h>
#include <ti/utils/mathutils/mathutils.h>
#include <ti/utils/cycleprofiler/cycle_profiler.h>
#include <ti/control/dpm/dpm.h>
#include <xdc/runtime/System.h>

/* C674x mathlib */
/* Suppress the mathlib.h warnings
* #48-D: incompatible redefinition of macro "TRUE"
* #48-D: incompatible redefinition of macro "FALSE"
*/
//#pragma diag_push
//#pragma diag_suppress 48
//#include <ti/mathlib/mathlib.h>
//#pragma diag_pop

/*! This is supplied at command line when application builds this file. This file
* is owned by the application and contains all resource partitioning, an
* application may include more than one DPC and also use resources outside of DPCs.
* The resource definitions used by this object detection DPC are prefixed by DPC_OBJDET_ */
#include APP_RESOURCE_FILE

#include <ti/control/mmwavelink/mmwavelink.h>

/* Obj Det instance etc */
#include <common/src/dpc/capon3d/include/objectdetectioninternal.h>
#include <common/src/dpc/capon3d/objectdetection.h>


//#define DBG_DPC_OBJDET

#ifdef DBG_DPC_OBJDET
ObjDetObj *gObjDetObj;
#endif

/**************************************************************************
************************** Local Definitions **********************************
**************************************************************************/

/**
@}
*/
/*! Maximum Number of objects that can be detected in a frame */
#define DPC_OBJDET_MAX_NUM_OBJECTS DOA_OUTPUT_MAXPOINTS

/**************************************************************************
************************** Local Functions Prototype **************************
**************************************************************************/

static DPM_DPCHandle DPC_ObjectDetection_init
(
DPM_Handle dpmHandle,
DPM_InitCfg* ptrInitCfg,
int32_t* errCode
);

static int32_t DPC_ObjectDetection_execute
(
DPM_DPCHandle handle,
DPM_Buffer* ptrResult
);

static int32_t DPC_ObjectDetection_ioctl
(
DPM_DPCHandle handle,
uint32_t cmd,
void* arg,
uint32_t argLen
);

static int32_t DPC_ObjectDetection_start (DPM_DPCHandle handle);
static int32_t DPC_ObjectDetection_stop (DPM_DPCHandle handle);
static int32_t DPC_ObjectDetection_deinit (DPM_DPCHandle handle);
static void DPC_ObjectDetection_frameStart (DPM_DPCHandle handle);
int32_t DPC_ObjectDetection_dataInjection(DPM_DPCHandle handle, DPM_Buffer* ptrBuffer);

/**************************************************************************
************************** Local Functions *******************************
**************************************************************************/

/**
* @b Description
* @n
* Sends Assert
*
* @retval
* Not Applicable.
*/
void _DPC_Objdet_Assert(DPM_Handle handle, int32_t expression,
const char *file, int32_t line)
{
DPM_DPCAssert fault;

if (!expression)
{
fault.lineNum = (uint32_t)line;
fault.arg0 = 0U;
fault.arg1 = 0U;
strncpy (fault.fileName, file, (DPM_MAX_FILE_NAME_LEN-1));

/* Report the fault to the DPM entities */
DPM_ioctl (handle,
DPM_CMD_DPC_ASSERT,
(void*)&fault,
sizeof(DPM_DPCAssert));
}
}


/**
* @b Description
* @n
* DPC data injection function registered with DPM. This is invoked on reception
* of the data injection from DPM.
*
* @param[in] handle DPM's DPC handle
* @param[in] ptrBuffer Buffer for data injected
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Not applicable
*/
int32_t DPC_ObjectDetection_dataInjection(DPM_DPCHandle handle, DPM_Buffer* ptrBuffer)
{
ObjDetObj *objDetObj = (ObjDetObj *) handle;

/* Notify the DPM Module that the DPC is ready for execution */

//DebugP_log1("ObjDet DPC: DPC_ObjectDetection_dataInjection, handle = 0x%x\n", (uint32_t)handle);
DebugP_assert (DPM_notifyExecute (objDetObj->dpmHandle, handle, true) == 0);

return 0;
}

/**
* @b Description
* @n
* Sub-frame reconfiguration, used when switching sub-frames. Invokes the
* DPU configuration using the configuration that was stored during the
* pre-start configuration so reconstruction time is saved because this will
* happen in real-time.
* @param[in] objDetObj Pointer to DPC object
* @param[in] subFrameIndx Sub-frame index.
*
* @retval
* Success - 0
* @retval
* Error - <0
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*/
static int32_t DPC_ObjDetDSP_reconfigSubFrame(ObjDetObj *objDetObj, uint8_t subFrameIndx)
{
int32_t retVal = 0;
//SubFrameObj *subFrmObj;

//subFrmObj = &objDetObj->subFrameObj[subFrameIndx];

//retVal = DPU_CFARCAProcDSP_config(subFrmObj->dpuCFARCAObj, &subFrmObj->dpuCfg.cfarCfg);
if (retVal != 0)
{
goto exit;
}

exit:
return(retVal);
}

/**
* @b Description
* @n
* Function to initialize all DPUs used in the DPC chain
*
* @param[in] objDetObj Pointer to sub-frame object
* @param[in] numSubFrames Number of sub-frames
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static inline int32_t DPC_ObjDetDSP_initDPU
(
ObjDetObj *objDetObj,
uint8_t numSubFrames
)
{
int32_t retVal = 0;

return(retVal);
}

/**
* @b Description
* @n
* Function to de-initialize all DPUs used in the DPC chain
*
* @param[in] objDetObj Pointer to sub-frame object
* @param[in] numSubFrames Number of sub-frames
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static inline int32_t DPC_ObjDetDSP_deinitDPU
(
ObjDetObj *objDetObj,
uint8_t numSubFrames
)
{
int32_t retVal = 0;

radarOsal_memDeInit();

return(retVal);
}

/**
* @b Description
* @n
* Performs processing related to pre-start configuration, which is per sub-frame,
* by configuring each of the DPUs involved in the processing chain.
* Memory management notes:
* 1. Core Local Memory that needs to be preserved across sub-frames (such as range DPU's calib DC buffer)
* will be allocated using MemoryP_alloc.
* 2. Core Local Memory that needs to be preserved within a sub-frame across DPU calls
* (the DPIF * type memory) or for intermediate private scratch memory for
* DPU (i.e no preservation is required from process call to process call of the DPUs
* within the sub-frame) will be allocated from the Core Local RAM configuration supplied in
* @ref DPC_ObjectDetection_InitParams given to @ref DPC_ObjectDetection_init API
* 3. L3 memory will only be allocated from the L3 RAM configuration supplied in
* @ref DPC_ObjectDetection_InitParams given to @ref DPC_ObjectDetection_init API
* No L3 buffers are presently required that need to be preserved across sub-frames
* (type described in #1 above), neither are L3 scratch buffers required for
* intermediate processing within DPU process call.
*
* @param[in] subFrameObj Pointer to sub-frame object
* @param[in] commonCfg Pointer to pre-start common configuration
* @param[in] preStartCfg Pointer to pre-start configuration of the sub-frame
* @param[in] edmaHandle Pointer to array of EDMA handles for the device, this
* can be distributed among the DPUs, the actual EDMA handle used
* in DPC is determined by definition in application resource file
* @param[in] L3ramObj Pointer to L3 RAM memory pool object
* @param[in] CoreL2RamObj Pointer to Core Local L2 memory pool object
* @param[in] CoreL1RamObj Pointer to Core Local L1 memory pool object
* @param[out] L3RamUsage Net L3 RAM memory usage in bytes as a result of allocation
* by the DPUs.
* @param[out] CoreL2RamUsage Net Local L2 RAM memory usage in bytes
* @param[out] CoreL1RamUsage Net Core L1 RAM memory usage in bytes
*
* @retval
* Success - 0
* @retval
* Error - <0
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*/
static int32_t DPC_ObjDetDSP_preStartConfig
(
SubFrameObj *subFrameObj,
DPC_ObjectDetection_PreStartCfg *preStartCfg
)
{
int32_t retVal = 0;
DPC_ObjectDetection_DynCfg *dynCfg;
DPIF_RadarCube radarCube;
DPU_ProcessErrorCodes procErrorCode;

dynCfg = &preStartCfg->dynCfg;

/* Save configs to object. We need to pass this stored config (instead of
the input arguments to this function which will be in stack) to
the DPU config functions inside of this function because the DPUs
have pointers to dynamic configurations which are later going to be
reused during re-configuration (intra sub-frame or inter sub-frame)
*/
subFrameObj->dynCfg = * dynCfg;

/* L3 allocations */
/* L3 - radar cube */
radarCube.dataSize = dynCfg->caponChainCfg.numRangeBins * dynCfg->caponChainCfg.numChirpPerFrame *
dynCfg->caponChainCfg.numAntenna * sizeof(cplx16_t);
DebugP_log1("ObjDet DPC: DPC_ObjDetDSP_preStartConfig, radarCubeFormat = %d\n", dynCfg->radarCubeFormat);
if(preStartCfg->shareMemCfg.shareMemEnable == true)
{
if((preStartCfg->shareMemCfg.radarCubeMem.addr != NULL) &&
(preStartCfg->shareMemCfg.radarCubeMem.size == radarCube.dataSize))
{
/* Use assigned radar cube address */
radarCube.data = preStartCfg->shareMemCfg.radarCubeMem.addr;
}
else
{
retVal = DPC_OBJECTDETECTION_EINVAL__COMMAND;
goto exit;
}
#ifdef RADARDEMO_AOARADARCUDE_RNGCHIRPANT
if (subFrameObj->dynCfg.radarCubeFormat != DPIF_RADARCUBE_FORMAT_2)
{
retVal = DPC_OBJECTDETECTION_EINVAL_CUBE;
goto exit;
}
#endif
}
else
{
retVal = DPC_OBJECTDETECTION_EINVAL_CUBE;
goto exit;
}

/* Only supported radar Cube format in this DPC */
radarCube.datafmt = DPIF_RADARCUBE_FORMAT_3;
subFrameObj->dataIn = radarCube.data;
subFrameObj->dpuCaponObj = DPU_radarProcess_init(&subFrameObj->dynCfg.caponChainCfg, &procErrorCode);
if (procErrorCode > PROCESS_OK)
{
retVal = DPC_OBJECTDETECTION_EINTERNAL;
DebugP_log1("DPC config error %d\n", procErrorCode);
goto exit;
}

//printf("DPC configuration done!\n");
DebugP_log0("DPC config done\n");
/* Report RAM usage */
radarOsal_printHeapStats();

exit:
return retVal;
}

/**
* @b Description
* @n
* DPC frame start function registered with DPM. This is invoked on reception
* of the frame start ISR from the RF front-end. This API is also invoked
* when application issues @ref DPC_OBJDET_IOCTL__TRIGGER_FRAME to simulate
* a frame trigger (e.g for unit testing purpose).
*
* @param[in] handle DPM's DPC handle
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Not applicable
*/
static void DPC_ObjectDetection_frameStart (DPM_DPCHandle handle)
{
ObjDetObj *objDetObj = (ObjDetObj *) handle;

objDetObj->stats->frameStartTimeStamp = Cycleprofiler_getTimeStamp();

//DebugP_log2("ObjDet DPC: Frame Start, frameIndx = %d, subFrameIndx = %d\n",
// objDetObj->stats.frameStartIntCounter, objDetObj->subFrameIndx);

/* Check if previous frame (sub-frame) processing has completed */
DPC_Objdet_Assert(objDetObj->dpmHandle, (objDetObj->interSubFrameProcToken == 0));
objDetObj->interSubFrameProcToken++;

/* Increment interrupt counter for debugging purpose */
if (objDetObj->subFrameIndx == 0)
{
objDetObj->stats->frameStartIntCounter++;
}

return;
}

/**
* @b Description
* @n
* DPC's (DPM registered) start function which is invoked by the
* application using DPM_start API.
*
* @param[in] handle DPM's DPC handle
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static int32_t DPC_ObjectDetection_start (DPM_DPCHandle handle)
{
ObjDetObj *objDetObj;
int32_t retVal = 0;

objDetObj = (ObjDetObj *) handle;
DebugP_assert (objDetObj != NULL);

objDetObj->stats->frameStartIntCounter = 0;

/* Start marks consumption of all pre-start configs, reset the flag to check
* if pre-starts were issued only after common config was issued for the next
* time full configuration happens between stop and start */
objDetObj->isCommonCfgReceived = false;

/* App must issue export of last frame after stop which will switch to sub-frame 0,
* so start should always see sub-frame indx of 0, check */
DebugP_assert(objDetObj->subFrameIndx == 0);

if(objDetObj->numSubframes > 1U)
{
/* Pre-start cfgs for sub-frames may have come in any order, so need
* to ensure we reconfig for the current (0) sub-frame before starting */
DPC_ObjDetDSP_reconfigSubFrame(objDetObj, objDetObj->subFrameIndx);
}
DebugP_log0("ObjDet DPC: Start done\n");
return(retVal);
}

/**
* @b Description
* @n
* DPC's (DPM registered) stop function which is invoked by the
* application using DPM_stop API.
*
* @param[in] handle DPM's DPC handle
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static int32_t DPC_ObjectDetection_stop (DPM_DPCHandle handle)
{
ObjDetObj *objDetObj;

objDetObj = (ObjDetObj *) handle;
DebugP_assert (objDetObj != NULL);

/* We can be here only after complete frame processing is done, which means
* processing token must be 0 and subFrameIndx also 0 */
DebugP_assert((objDetObj->interSubFrameProcToken == 0) && (objDetObj->subFrameIndx == 0));

DebugP_log0("ObjDet DPC: Stop done\n");
return(0);
}

/**
* @b Description
* @n
* DPC's (DPM registered) execute function which is invoked by the application
* in the DPM's execute context when the DPC issues DPM_notifyExecute API from
* its registered @ref DPC_ObjectDetection_frameStart API that is invoked every
* frame interrupt.
*
* @param[in] handle DPM's DPC handle
* @param[out] ptrResult Pointer to the result
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
int32_t DPC_ObjectDetection_execute
(
DPM_DPCHandle handle,
DPM_Buffer* ptrResult
)
{
ObjDetObj *objDetObj;
SubFrameObj *subFrmObj;
DPC_ObjectDetection_ProcessCallBackCfg *processCallBack;
int32_t procErrorCode;

radarProcessOutput *result;
int32_t retVal = 0;
volatile uint32_t startTime;
int32_t i;

objDetObj = (ObjDetObj *) handle;
DebugP_assert (objDetObj != NULL);
DebugP_assert (ptrResult != NULL);

DebugP_log1("ObjDet DPC: Processing sub-frame %d\n", objDetObj->subFrameIndx);

processCallBack = &objDetObj->processCallBackCfg;

objDetObj->executeResult->subFrameIdx = objDetObj->subFrameIndx;
result = &objDetObj->executeResult->objOut;

subFrmObj = &objDetObj->subFrameObj[objDetObj->subFrameIndx];

if (processCallBack->processInterFrameBeginCallBackFxn != NULL)
{
(*processCallBack->processInterFrameBeginCallBackFxn)(objDetObj->subFrameIndx);
}

//DebugP_log0("ObjDet DPC: Range Proc Output Ready\n");

startTime = Cycleprofiler_getTimeStamp();
DPU_radarProcess_process(subFrmObj->dpuCaponObj, subFrmObj->dataIn, result, &procErrorCode);
if (procErrorCode > PROCESS_OK)
{
retVal = -1;
goto exit;
}

DebugP_log0("ObjDet DPC: Frame Proc Done\n");

objDetObj->stats->interFrameEndTimeStamp = Cycleprofiler_getTimeStamp();
memcpy(&(objDetObj->stats->subFrbenchmarkDetails), result->benchmarkOut, sizeof(radarProcessBenchmarkElem));
objDetObj->stats->interFrameExecTimeInUsec = (uint32_t)((float)(objDetObj->stats->interFrameEndTimeStamp - objDetObj->stats->frameStartTimeStamp) * _rcpsp((float)DSP_CLOCK_MHZ));
objDetObj->stats->activeFrameProcTimeInUsec = (uint32_t)((float)(objDetObj->stats->interFrameEndTimeStamp - startTime) * _rcpsp((float)DSP_CLOCK_MHZ));


/* populate DPM_resultBuf - first pointer and size are for results of the processing */
ptrResult->ptrBuffer[0] = (uint8_t *)objDetObj->executeResult;
ptrResult->size[0] = sizeof(DPC_ObjectDetection_ExecuteResult);

ptrResult->ptrBuffer[1] = (uint8_t *)objDetObj->stats;
ptrResult->size[1] = sizeof(DPC_ObjectDetection_Stats);



/* clear rest of the result */
for (i = 2; i < DPM_MAX_BUFFER; i++)
{
ptrResult->ptrBuffer[i] = NULL;
ptrResult->size[i] = 0;
}

exit:

return retVal;
}


/**
* @b Description
* @n
* DPC IOCTL commands configuration API which will be invoked by the
* application using DPM_ioctl API
*
* @param[in] handle DPM's DPC handle
* @param[in] cmd Capture DPC specific commands
* @param[in] arg Command specific arguments
* @param[in] argLen Length of the arguments which is also command specific
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static int32_t DPC_ObjectDetection_ioctl
(
DPM_DPCHandle handle,
uint32_t cmd,
void* arg,
uint32_t argLen
)
{
ObjDetObj *objDetObj;
SubFrameObj *subFrmObj;
int32_t retVal = 0;

/* Get the DSS MCB: */
objDetObj = (ObjDetObj *) handle;
DebugP_assert(objDetObj != NULL);


/* Process the commands. Process non sub-frame specific ones first
* so the sub-frame specific ones can share some code. */
if((cmd < DPC_OBJDET_IOCTL__STATIC_PRE_START_CFG) || (cmd > DPC_OBJDET_IOCTL__MAX))
{
retVal = DPM_EINVCMD;
}
else if (cmd == DPC_OBJDET_IOCTL__TRIGGER_FRAME)
{
DPC_ObjectDetection_frameStart(handle);
}
else if (cmd == DPC_OBJDET_IOCTL__STATIC_PRE_START_COMMON_CFG)
{
objDetObj->numSubframes = *(uint8_t *)arg;
objDetObj->isCommonCfgReceived = true;
//DebugP_log1("ObjDet DPC: Pre-start Config IOCTL processed common config (numSubframes = %d)\n", objDetObj->numSubframes);
}
else if (cmd == DPC_OBJDET_IOCTL__DYNAMIC_EXECUTE_RESULT_EXPORTED)
{
DPC_ObjectDetection_ExecuteResultExportedInfo *inp;

DebugP_assert(argLen == sizeof(DPC_ObjectDetection_ExecuteResultExportedInfo));

inp = (DPC_ObjectDetection_ExecuteResultExportedInfo *)arg;

/* input sub-frame index must match current sub-frame index */
DebugP_assert(inp->subFrameIdx == objDetObj->subFrameIndx);

/* Reconfigure all DPUs resources for next sub-frame as EDMA and scrach buffer
* resources overlap across sub-frames */
if (objDetObj->numSubframes > 1)
{
/* Next sub-frame */
objDetObj->subFrameIndx++;
if (objDetObj->subFrameIndx == objDetObj->numSubframes)
{
objDetObj->subFrameIndx = 0;
}

DPC_ObjDetDSP_reconfigSubFrame(objDetObj, objDetObj->subFrameIndx);
}
DebugP_log0("ObjDet DPC: received ack from MSS for output data\n");

/* mark end of processing of the frame/sub-frame by the DPC and the app */
objDetObj->interSubFrameProcToken--;
}
else
{
uint8_t subFrameNum;

/* First argument is sub-frame number */
DebugP_assert(arg != NULL);
subFrameNum = *(uint8_t *)arg;
subFrmObj = &objDetObj->subFrameObj[subFrameNum];

switch (cmd)
{
/* Related to pre-start configuration */
case DPC_OBJDET_IOCTL__STATIC_PRE_START_CFG:
{
DPC_ObjectDetection_PreStartCfg *cfg;

/* Pre-start common config must be received before pre-start configs
* are received. */
if (objDetObj->isCommonCfgReceived == false)
{
//DebugP_log0("ObjDet DPC IOCTL: false isCommonCfgReceived\n");
retVal = DPC_OBJECTDETECTION_PRE_START_CONFIG_BEFORE_PRE_START_COMMON_CONFIG;
goto exit;
}

DebugP_assert(argLen == sizeof(DPC_ObjectDetection_PreStartCfg));

cfg = (DPC_ObjectDetection_PreStartCfg*)arg;


//DebugP_log4("ObjDet DPC IOCTL: function called with cfg = 0x%x, subFrmObj = 0x%x, cmd = %d, subFrameNum = %d\n", (uint32_t )arg, (uint32_t )subFrmObj, cmd, *(uint8_t *)arg);
retVal = DPC_ObjDetDSP_preStartConfig(subFrmObj,
cfg);
if (retVal != 0)
{
goto exit;
}


DebugP_log1("ObjDet DPC: Pre-start Config IOCTL processed (subFrameIndx = %d)\n", subFrameNum);
break;
}

default:
{
/* Error: This is an unsupported command */
retVal = DPM_EINVCMD;
break;
}
}
}

exit:
return retVal;
}

/**
* @b Description
* @n
* DPC's (DPM registered) initialization function which is invoked by the
* application using DPM_init API. Among other things, this API allocates DPC instance
* and DPU instances (by calling DPU's init APIs) from the MemoryP osal
* heap. If this API returns an error of any type, the heap is not guaranteed
* to be in the same state as before calling the API (i.e any allocations
* from the heap while executing the API are not guaranteed to be deallocated
* in case of error), so any error from this API should be considered fatal and
* if the error is of _ENOMEM type, the application will
* have to be built again with a bigger heap size to address the problem.
*
* @param[in] dpmHandle DPM's DPC handle
* @param[in] ptrInitCfg Handle to the framework semaphore
* @param[out] errCode Error code populated on error
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static DPM_DPCHandle DPC_ObjectDetection_init
(
DPM_Handle dpmHandle,
DPM_InitCfg* ptrInitCfg,
int32_t* errCode
)
{
ObjDetObj *objDetObj = NULL;
DPC_ObjectDetection_InitParams *dpcInitParams;
radarOsal_heapConfig heapconfig[3];

*errCode = 0;

//DebugP_log0("DPC: DPC_ObjectDetection_init\n");
if ((ptrInitCfg == NULL) || (ptrInitCfg->arg == NULL))
{
*errCode = DPC_OBJECTDETECTION_EINVAL;
goto exit;
}

if (ptrInitCfg->argSize != sizeof(DPC_ObjectDetection_InitParams))
{
*errCode = DPC_OBJECTDETECTION_EINVAL__INIT_CFG_ARGSIZE;
goto exit;
}

dpcInitParams = (DPC_ObjectDetection_InitParams *) ptrInitCfg->arg;
/*Set up heap and mem osal*/
{
memset(heapconfig, 0, sizeof(heapconfig));
heapconfig[RADARMEMOSAL_HEAPTYPE_DDR_CACHED].heapType = RADARMEMOSAL_HEAPTYPE_DDR_CACHED;
heapconfig[RADARMEMOSAL_HEAPTYPE_DDR_CACHED].heapAddr = (int8_t *) dpcInitParams->L3HeapCfg.addr;
heapconfig[RADARMEMOSAL_HEAPTYPE_DDR_CACHED].heapSize = dpcInitParams->L3HeapCfg.size;
heapconfig[RADARMEMOSAL_HEAPTYPE_DDR_CACHED].scratchAddr= (int8_t *) dpcInitParams->L3ScratchCfg.addr;
heapconfig[RADARMEMOSAL_HEAPTYPE_DDR_CACHED].scratchSize= dpcInitParams->L3ScratchCfg.size;

heapconfig[RADARMEMOSAL_HEAPTYPE_LL2].heapType = RADARMEMOSAL_HEAPTYPE_LL2;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL2].heapAddr = (int8_t *) dpcInitParams->CoreL2HeapCfg.addr;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL2].heapSize = dpcInitParams->CoreL2HeapCfg.size;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL2].scratchAddr = (int8_t *) dpcInitParams->CoreL2ScratchCfg.addr;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL2].scratchSize = dpcInitParams->CoreL2ScratchCfg.size;

heapconfig[RADARMEMOSAL_HEAPTYPE_LL1].heapType = RADARMEMOSAL_HEAPTYPE_LL1;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL1].heapAddr = (int8_t *) dpcInitParams->CoreL1HeapCfg.addr;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL1].heapSize = dpcInitParams->CoreL1HeapCfg.size;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL1].scratchAddr = (int8_t *) dpcInitParams->CoreL1ScratchCfg.addr;
heapconfig[RADARMEMOSAL_HEAPTYPE_LL1].scratchSize = dpcInitParams->CoreL1ScratchCfg.size;
if(radarOsal_memInit(&heapconfig[0], 3) == RADARMEMOSAL_FAIL)
{
*errCode = DPC_OBJECTDETECTION_MEMINITERR;
goto exit;
}
}
objDetObj = MemoryP_ctrlAlloc(sizeof(ObjDetObj), 0);

#ifdef DBG_DPC_OBJDET
gObjDetObj = objDetObj;
#endif

System_printf("ObjDet DPC: objDetObj address = (ObjDetObj *) 0x%x\n", (uint32_t) objDetObj);

if(objDetObj == NULL)
{
*errCode = DPC_OBJECTDETECTION_ENOMEM;
goto exit;
}

/* Initialize memory */
memset((void *)objDetObj, 0, sizeof(ObjDetObj));

/* Copy over the DPM configuration: */
memcpy ((void*)&objDetObj->dpmInitCfg, (void*)ptrInitCfg, sizeof(DPM_InitCfg));

objDetObj->dpmHandle = dpmHandle;
objDetObj->socHandle = ptrInitCfg->socHandle;

objDetObj->processCallBackCfg = dpcInitParams->processCallBackCfg;

objDetObj->executeResult = (DPC_ObjectDetection_ExecuteResult *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, sizeof(DPC_ObjectDetection_ExecuteResult), 1);
objDetObj->stats = (DPC_ObjectDetection_Stats *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, sizeof(DPC_ObjectDetection_Stats), 1);

*errCode = DPC_ObjDetDSP_initDPU(objDetObj, RL_MAX_SUBFRAMES);
//printf ("DPC init done!\n");

exit:
if(*errCode != 0)
{
if(objDetObj != NULL)
{
MemoryP_ctrlFree(objDetObj, sizeof(ObjDetObj));
objDetObj = NULL;
}
}

return ((DPM_DPCHandle)objDetObj);
}

/**
* @b Description
* @n
* DPC's (DPM registered) de-initialization function which is invoked by the
* application using DPM_deinit API.
*
* @param[in] handle DPM's DPC handle
*
* \ingroup DPC_OBJDET__INTERNAL_FUNCTION
*
* @retval
* Success - 0
* @retval
* Error - <0
*/
static int32_t DPC_ObjectDetection_deinit (DPM_DPCHandle handle)
{
ObjDetObj *objDetObj = (ObjDetObj *) handle;
int32_t retVal = 0;

if (handle == NULL)
{
retVal = DPC_OBJECTDETECTION_EINVAL;
goto exit;
}

retVal = DPC_ObjDetDSP_deinitDPU(objDetObj, RL_MAX_SUBFRAMES);

MemoryP_ctrlFree(handle, sizeof(ObjDetObj));

exit:
return (retVal);
}

/**************************************************************************
************************* Global Declarations ****************************
**************************************************************************/

/** @addtogroup DPC_OBJDET__GLOBAL
@{ */

/**
* @brief Global used to register Object Detection DPC in DPM
*/
DPM_ProcChainCfg gDPC_ObjectDetectionCfg =
{
DPC_ObjectDetection_init, /* Initialization Function: */
DPC_ObjectDetection_start, /* Start Function: */
DPC_ObjectDetection_execute, /* Execute Function: */
DPC_ObjectDetection_ioctl, /* Configuration Function: */
DPC_ObjectDetection_stop, /* Stop Function: */
DPC_ObjectDetection_deinit, /* Deinitialization Function: */
DPC_ObjectDetection_dataInjection, /* Inject Data Function: */
NULL, /* Chirp Available Function: */
DPC_ObjectDetection_frameStart /* Frame Start Function: */
};

/* @} */


+ 109
- 0
dss/pcount3D_dss.cfg View File

@@ -0,0 +1,109 @@
/*
* Copyright 2011 by Texas Instruments Incorporated.
*
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
environment['xdc.cfg.check.fatal'] = 'false';

/********************************************************************
************************** BIOS Modules ****************************
********************************************************************/
var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Error = xdc.useModule('xdc.runtime.Error');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');
var Memory = xdc.useModule('xdc.runtime.Memory');
var SysStd = xdc.useModule('xdc.runtime.SysStd');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var SEM = xdc.useModule('ti.sysbios.knl.Semaphore');
var Event = xdc.useModule('ti.sysbios.knl.Event');
var Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi');
var EventCombiner = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
var Load = xdc.useModule('ti.sysbios.utils.Load');

System.SupportProxy = SysStd;

/* Default Heap Creation: Local L2 memory */
var heapMemParams = new HeapMem.Params();
heapMemParams.size = 11*1024;
heapMemParams.sectionName = "systemHeap";
Program.global.heap0 = HeapMem.create(heapMemParams);
Memory.defaultHeapInstance = Program.global.heap0;
/*
* Enable Event Groups here and registering of ISR for specific GEM INTC is done
* using EventCombiner_dispatchPlug() and Hwi_eventMap() APIs
*/
EventCombiner.eventGroupHwiNum[0] = 7;
EventCombiner.eventGroupHwiNum[1] = 8;
EventCombiner.eventGroupHwiNum[2] = 9;
EventCombiner.eventGroupHwiNum[3] = 10;

/* Enable BIOS Task Scheduler */
BIOS.taskEnabled = true;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x800;

Task.idleTaskStackSize = 800;

/* do not call update for load - Application will call it at inter-frame boundary */
Load.updateInIdle = false;

/* Install idle function to sleep. Note above
Load.updateInIdle is false which allows to sleep in idle.
Also, no other book-keeping etc functions should be installed in the idle thread */
Idle.addFunc('&Pcount3DDemo_sleep');

/*
* Build a custom BIOS library. The custom library will be smaller than the
* pre-built "instrumented" (default) and "non-instrumented" libraries.
*
* The BIOS.logsEnabled parameter specifies whether the Logging is enabled
* within BIOS for this custom build. These logs are used by the RTA and
* UIA analysis tools.
*
* The BIOS.assertsEnabled parameter specifies whether BIOS code will
* include Assert() checks. Setting this parameter to 'false' will generate
* smaller and faster code, but having asserts enabled is recommended for
* early development as the Assert() checks will catch lots of programming
* errors (invalid parameters, etc.)
*/
BIOS.libType = BIOS.LibType_Custom;
BIOS.logsEnabled = false;
BIOS.assertsEnabled = true;

/* Make sure libraries are built with 32-bit enum types to be compatible with DSP enum types*/
BIOS.includeXdcRuntime = true;
BIOS.customCCOpts += " --enum_type=int ";

/********************************************************************
* Enabling DebugP Log Support
********************************************************************/
var Log = xdc.useModule('xdc.runtime.Log');
var Main = xdc.useModule('xdc.runtime.Main');
var Diags = xdc.useModule('xdc.runtime.Diags');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

/* Configure the Logger Buffer: */
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.bufType = LoggerBuf.BufType_CIRCULAR;
loggerBufParams.exitFlush = false;
loggerBufParams.instance.name = "_logInfo";
loggerBufParams.numEntries = 200;

/* Create the Logger and attach this to the application */
MyAppLogger = LoggerBuf.create(loggerBufParams);
Main.common$.logger = MyAppLogger;
Main.common$.diags_USER1 = Diags.RUNTIME_ON;
//Task.common$.diags_USER1 = Diags.RUNTIME_ON;
Task.common$.diags_USER1 = Diags.ALWAYS_ON;
Task.common$.diags_USER2 = Diags.ALWAYS_ON;


+ 134
- 0
dss/pcount3D_dss.h View File

@@ -0,0 +1,134 @@
/**
* @file pcount3D_dss.h
*
* @brief
* This is the main header file for the 3D people counting Demo on DSS.
*
* \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.
*/
#ifndef PCOUNT3D_DSS_H
#define PCOUNT3D_DSS_H

#include <ti/drivers/edma/edma.h>
#include <cpy_tbl.h>

#include <ti/sysbios/knl/Task.h>

#include <ti/common/mmwave_error.h>
#include <ti/drivers/soc/soc.h>
#include <ti/drivers/soc/soc.h>
#include <ti/drivers/mailbox/mailbox.h>
#include <ti/drivers/hwa/hwa.h>
#include <ti/drivers/osal/DebugP.h>

#include <people_counting/68xx_3D_people_counting/src/common/pcount3D_output.h>
#include <people_counting/68xx_3D_people_counting/src/common/pcount3D_config.h>
#include <common/src/dpu/capon3d/radarProcess.h>
#include <common/src/dpu/capon3d/modules/utilities/cycle_measure.h>

/* This is used to resolve RL_MAX_SUBFRAMES, TODO: wired */
#include <ti/control/mmwavelink/mmwavelink.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct Pcount3DDemo_DataPathObj_t
{
/*! @brief dpm Handle */
DPM_Handle radarProcDpmHandle;

/*! @brief Handle of the EDMA driver. */
EDMA_Handle edmaHandle;

/*! @brief EDMA error Information when there are errors like missing events */
EDMA_errorInfo_t EDMA_errorInfo;

/*! @brief EDMA transfer controller error information. */
EDMA_transferControllerErrorInfo_t EDMA_transferControllerErrorInfo;

/*! @brief Processing Stats */
Pcount3DDemo_output_message_stats subFrameStats[RL_MAX_SUBFRAMES];
} Pcount3DDemo_DataPathObj;

/**
* @brief
* Millimeter Wave Demo MCB
*
* @details
* The structure is used to hold all the relevant information for the
* Millimeter Wave demo
*/
typedef struct Pcount3DDemo_DSS_MCB_t
{
/*! * @brief Handle to the SOC Module */
SOC_Handle socHandle;

/*! @brief DPM Handle */
Task_Handle radarProcDpmTaskHandle;

/*! @brief init Task Handle */
Task_Handle initTaskHandle;

/*! @brief Data Path object */
Pcount3DDemo_DataPathObj dataPathObj;

/*! @brief Counter which tracks the number of dpm stop events received
The event is triggered by DPM_Report_DPC_STOPPED from DPM */
uint32_t dpmStopEvents;

/*! @brief Counter which tracks the number of dpm start events received
The event is triggered by DPM_Report_DPC_STARTED from DPM */
uint32_t dpmStartEvents;
} Pcount3DDemo_DSS_MCB;


/**************************************************************************
*************************** Extern Definitions ***************************
**************************************************************************/
extern void Pcount3DDemo_dataPathInit(Pcount3DDemo_DataPathObj *obj);
extern void Pcount3DDemo_dataPathOpen(Pcount3DDemo_DataPathObj *obj);
extern void Pcount3DDemo_dataPathClose(Pcount3DDemo_DataPathObj *obj);

/* Sensor Management Module Exported API */
extern void _Pcount3DDemo_debugAssert(int32_t expression, const char *file, int32_t line);
#define Pcount3DDemo_debugAssert(expression) { \
DebugP_assert(expression); \
}
#ifdef __cplusplus
}
#endif

#endif /* PCOUNT3D_DSS_H */


+ 169
- 0
dss/pcount3D_dss_linker.cmd View File

@@ -0,0 +1,169 @@
/*----------------------------------------------------------------------------*/
/* Linker Settings */
--retain="*(.intvecs)"

/*----------------------------------------------------------------------------*/
/* Include Libraries */
-llibdpm_xwr68xx.ae674
-llibmailbox_xwr68xx.ae674
-llibsoc_xwr68xx.ae674
-llibosal_xwr68xx.ae674
-ldsplib.ae674
//-opcount3D_dss_pe674.oe674
/* Section Configuration */
SECTIONS
{
systemHeap : {} >> L2SRAM_UMAP0 | L2SRAM_UMAP1
//.l3ram: {} >> L3SRAM
.dpc_l1Heap : { } > L1DSRAM
.dpc_l2Heap: { } >> L2SRAM_UMAP0 | L2SRAM_UMAP1
.ovly > L2SRAM_UMAP0 | L2SRAM_UMAP1
/* L3SRAM has code that is overlaid with data, so data must be
marked uninitialized. Application can initialize this section
using _L3data_* symbols defined below. Code should be written carefully as
these are linker symbols (see for example http://e2e.ti.com/support/development_tools/compiler/f/343/t/92002 ):
extern far uint8_t _L3data_start; // the type here does not matter
extern far uint8_t _L3data_size; // the type here does not matter

memset((void *)_symval(&_L3data_start), 0, (uint32_t) _symval(&_L3data_size));
*/
.l3data: type=NOINIT, start(_L3data_start), size(_L3data_size), load=L3SRAM PAGE 1
.fastCode:
{
RADARDEMO_detectionCFAR_priv.oe674 (.text:RADARDEMO_detectionCFAR_raCAAll)
RADARDEMO_aoaEst2DCaponBF_heatmapEst.oe674 (.text:RADARDEMO_aoaEst2DCaponBF_raHeatmap)
RADARDEMO_aoaEst2DCaponBF_rnEstInv.oe674 (.text:RADARDEMO_aoaEst2DCaponBF_covInv)
MATRIX_cholesky.oe674 (.text:MATRIX_cholesky_flp_inv)
RADARDEMO_aoaEst2DCaponBF_staticRemoval.oe674 (.text:RADARDEMO_aoaEst2DCaponBF_clutterRemoval)
copyTranspose.oe674 (.text:copyTranspose)
//dsplib.ae674<*.obj>(.text)
} load=L3SRAM PAGE 0 , run=L1PSRAM PAGE 0, table(_pcount3DDemo_fastCode_L1PSRAM_copy_table, compression=off)

.hsramCode:
{
libdpm_xwr68xx.ae674 (.text:DPM_deinit)
libmailbox_xwr68xx.ae674 (.text:Mailbox_close)
libdpm_xwr68xx.ae674 (.text:DPM_pipeDeinit)
dss_main.oe674 (.text:Pcount3DDemo_sensorStopEpilog)
rts*.lib (.text:_outc)
rts*.lib (.text:_outs)
rts*.lib (.text:printf)
rts*.lib (.text:_ltostr)
rts*.lib (.text:__c6xabi_isnan)
rts*.lib (.text:_ecpy)
rts*.lib (.text:_mcpy)
rts*.lib (.text:_pconv_g)
rts*.lib (.text:fcvt)
rts*.lib (.text:_pconv_f)
rts*.lib (.text:_pconv_e)
rts*.lib (.text:_pconv_a)
rts*.lib (.text:__TI_printfi)
rts*.lib (.text:fputs)
rts*.lib (.text:fputc)
rts*.lib (.text:__c6xabi_divul)
rts*.lib (.text:__c6xabi_divd)
rts*.lib (.text:frexp)
rts*.lib (.text:ldexp)
} load=L3SRAM PAGE 0, run=HSRAM PAGE 0, table(_pcount3DDemo_configCode_HSRAM_copy_table, compression=off)

.overlaidCode:
{
RADARDEMO_aoaEst2DCaponBF.oe674 (.text:RADARDEMO_aoaEst2DCaponBF_create)
RADARDEMO_detectionCFAR.oe674 (.text:RADARDEMO_detectionCFAR_create)
RADARDEMO_aoaEst2DCaponBF_utils.oe674 (.text:tw_gen_float)
radarProcess.oe674 (.text:DPU_radarProcess_init)
objectdetection.oe674 (.text:DPC_ObjectDetection_deinit)
radarOsal_malloc.oe674 (.text:radarOsal_memAlloc)
radarOsal_malloc.oe674 (.text:radarOsal_memInit)
radarOsal_malloc.oe674 (.text:radarOsal_memDeInit)
radarOsal_malloc.oe674 (.text:radarOsal_printHeapStats)
objectdetection.oe674 (.text:DPC_ObjectDetection_init)
RADARDEMO_aoaEst2DCaponBF_utils.oe674 (.text:cosdp_i)

RADARDEMO_aoaEst2DCaponBF_angleEst.oe674 (.text:RADARDEMO_aoaEst2DCaponBF_aeEstElevAzim)
libedma_xwr68xx.ae674<*.oe674>(.text)
dss_main.oe674 (.text:MmwDemo_edmaOpen)
dss_main.oe674 (.text:MmwDemo_edmaInit)
dss_main.oe674 (.text:MmwDemo_edmaBlockCopy)
dss_main.oe674 (.text:MmwDemo_copyTable)
cycle_measure.oe674 (.text:cache_setMar)
dss_main.oe674 (.text:MmwDemo_EDMA_errorCallbackFxn)
dss_main.oe674 (.text:MmwDemo_EDMA_transferControllerErrorCallbackFxn)
libedma_xwr68xx.ae674 (.far:EDMA_object)

dss_main.oe674 (.text:main)
dss_main.oe674 (.text:Pcount3DDemo_dssInitTask)
} load=L3SRAM PAGE 0

.unUsedCode:
{
RADARDEMO_detectionCFAR_priv.oe674 (.text:RADARDEMO_detectionCFAR_CAAll)
RADARDEMO_detectionCFAR_priv.oe674 (.text:RADARDEMO_detectionCFAR_OS)
} load=L3SRAM PAGE 0
.slowCode:
{
libmailbox_xwr68xx.ae674 (.text:Mailbox_init)
libdpm_xwr68xx.ae674 (.text:DPM_init)
libmailbox_xwr68xx.ae674 (.text:Mailbox_open)
libsoc_xwr68xx.ae674 (.text:SOC_deviceInit)
libdpm_xwr68xx.ae674 (.text:DPM_mboxInit)
libosal_xwr68xx.ae674 (.text:SemaphoreP_create)
libdpm_xwr68xx.ae674 (.text:DPM_pipeInit)
libsoc_xwr68xx.ae674 (.text:SOC_init)

objectdetection.oe674 (.text:DPC_ObjDetDSP_preStartConfig)
//pcount3D_dss_pe674.oe674 (.text:xdc_runtime_System_printfExtend__I)
//rts*.lib (.text:__TI_tls_init) //not copied to HSRAM, but moved to L3
rts*.lib (.text:__c6xabi_divf)
rts*.lib (.text:setvbuf)
rts*.lib (.text:HOSTrename)
rts*.lib (.text:getdevice)
rts*.lib (.text:__TI_closefile)
rts*.lib (.text:atoi)
rts*.lib (.text:fflush)
rts*.lib (.text:fseek)
rts*.lib (.text:HOSTlseek)
rts*.lib (.text:HOSTopen)
rts*.lib (.text:HOSTwrite)
rts*.lib (.text:__TI_ltoa)
rts*.lib (.text:__TI_wrt_ok)
rts*.lib (.text:close)
rts*.lib (.text:HOSTread)
rts*.lib (.text:HOSTunlink)
rts*.lib (.text:__TI_doflush)
rts*.lib (.text:__divu)
rts*.lib (.text:modf)
rts*.lib (.text:HOSTclose)

rts*.lib (.text:__TI_cleanup)
rts*.lib (.text:__c6xabi_fixfu)
rts*.lib (.text:__remu)
rts*.lib (.text:finddevice)
rts*.lib (.text:__TI_readmsg)
rts*.lib (.text:__c6xabi_fixdu)
rts*.lib (.text:__c6xabi_llshl)
rts*.lib (.text:unlink)
rts*.lib (.text:__TI_writemsg)
rts*.lib (.text:__c6xabi_llshru)
rts*.lib (.text:_subcull)
rts*.lib (.text:lseek)
rts*.lib (.text:write)
rts*.lib (.text:__TI_frcmpyd_div)
rts*.lib (.text:__c6xabi_isinf)
rts*.lib (.text:wcslen)
} load=L3SRAM PAGE 0 (HIGH)
}
/*----------------------------------------------------------------------------*/


+ 679
- 0
dss/radarProcess.c View File

@@ -0,0 +1,679 @@
/*!
* \file radarProcess.c
*
* \brief radar signal processing chain.
*
* Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
*
*
* 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 <common/src/dpu/capon3d/include/radarProcess_internal.h>
#include <math.h>
#include <common/src/dpu/capon3d/modules/utilities/cycle_measure.h>
#include <common/src/dpu/capon3d/modules/utilities/radarOsal_malloc.h>
#include <common/src/dpu/capon3d/modules/utilities/radar_c674x.h>

#if (defined SOC_XWR16XX) || (defined SOC_XWR68XX)
#include <xdc/runtime/System.h>
#endif

#define ONEOVERFACTORIAL3 (1.f/6.f)
#define ONEOVERFACTORIAL5 (1.f/230.f)
#define ONEOVERFACTORIAL7 (1.f/5040.f)
#define MAXANT (12)
#define MAXWIN1DSize (128)
//user input configuration parameters

/***************************************************************************
*************************** External API Functions ************************
**************************************************************************/
/**
* @b Description
* @n
* The function is radarProcess DPU init function. It allocates memory to store
* its internal data object and returns a handle if it executes successfully.
*
* @param[in] initParams radarProcess initialization parameters.
* @param[in] errCode Pointer to errCode generates from the API
*
*
* @retval
* Success - valid radarProcess handle
* @retval
* Error - NULL
*/
DPU_radarProcess_Handle DPU_radarProcess_init
(
DPU_radarProcessConfig_t * initParams,
DPU_ProcessErrorCodes * errCode
)
{
radarProcessInstance_t * inst;
int32_t i;
int32_t itemp, perRngbinHeatmapLen;
DPU_ProcessErrorCodes errorCode = PROCESS_OK;
inst = (radarProcessInstance_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, sizeof(radarProcessInstance_t), 8);

itemp = initParams->numChirpPerFrame;
if ((1 << (30 - _norm(itemp))) == itemp)
inst->DopplerFFTSize = itemp;
else
inst->DopplerFFTSize = 1 << (31 - _norm(itemp));

inst->dopplerOversampleFactor = 1;
inst->scaleDopCfarOutCFAR = 1;
inst->nRxAnt = initParams->numAntenna;
inst->numChirpsPerFrame = initParams->numChirpPerFrame;


itemp = initParams->numAdcSamplePerChirp;
if ((1 << (30 - _norm(itemp))) == itemp)
inst->numRangeBins = itemp;
else
inst->numRangeBins = 1 << (31 - _norm(itemp));
initParams->numRangeBins = inst->numRangeBins;

//update the interbin resolution for range and Doppler
initParams->dynamicCfarConfig.rangeRes = divsp_i(initParams->dynamicCfarConfig.rangeRes * (float)initParams->numAdcSamplePerChirp, (float)inst->numRangeBins);
inst->rangeRes = initParams->dynamicCfarConfig.rangeRes;
initParams->dynamicCfarConfig.dopplerRes= divsp_i(initParams->dynamicCfarConfig.dopplerRes * (float)initParams->numChirpPerFrame, (float)inst->DopplerFFTSize);
inst->dopplerRes = initParams->dynamicCfarConfig.dopplerRes;


/* rearrange phase compensation coeff from OOB to be able to use in 2D capon chain */
{
cplxf_t * tempCmpVec;
float tempRe, tempIm, tempP, invsqrt, errorLimit;
int32_t compFlag;

tempCmpVec = (cplxf_t *)&(initParams->doaConfig.phaseCompVect[0]);
//check whether we need to compensate
compFlag = 0;
errorLimit = 0.0001f;
for (i = 0; i < initParams->numAntenna; i++)
{
if (((_fabs(tempCmpVec[i].real) - 1.f) > errorLimit) || (_fabs(tempCmpVec[i].imag) > errorLimit))
compFlag = 1;
}
if (compFlag)
{
for (i = 0; i < initParams->numAntenna; i++)
{
tempRe = tempCmpVec[i].real;
tempIm = tempCmpVec[i].imag;
tempP = tempRe * tempRe + tempIm * tempIm;
invsqrt = _rsqrsp(tempP);
invsqrt = invsqrt * (1.5f - 0.5f * tempP * invsqrt * invsqrt);
invsqrt = invsqrt * (1.5f - 0.5f * tempP * invsqrt * invsqrt);
tempCmpVec[i].real = tempRe * invsqrt * (float)(initParams->doaConfig.phaseRot[i]);
tempCmpVec[i].imag = -tempIm * invsqrt * (float)(initParams->doaConfig.phaseRot[i]);
}
}
}


inst->perRangeBinMax = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, inst->numRangeBins * sizeof(float), 8);
/* 2D Capon DoA init and config */
{
int32_t heatmapSize, maxNumAngleEst;

initParams->doaConfig.numInputRangeBins = inst->numRangeBins;
initParams->doaConfig.numInputChirps = initParams->numChirpPerFrame;
initParams->doaConfig.dopperFFTSize = inst->DopplerFFTSize;
initParams->doaConfig.nRxAnt = inst->nRxAnt;

inst->aoaInstance = (void *) RADARDEMO_aoaEst2DCaponBF_create(&initParams->doaConfig, &inst->aoaBFErrorCode);
if (inst->aoaBFErrorCode > RADARDEMO_AOACAPONBF_NO_ERROR)
{
errorCode = PROCESS_ERROR_DOAPROC_INIT_FAILED;
}

inst->numDynAngleBin = initParams->doaConfig.numRAangleBin;
inst->aoaInput = (RADARDEMO_aoaEst2DCaponBF_input *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, sizeof(RADARDEMO_aoaEst2DCaponBF_input), 1);
inst->aoaOutput = (RADARDEMO_aoaEst2DCaponBF_output *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, sizeof(RADARDEMO_aoaEst2DCaponBF_output), 1);

heatmapSize = (int32_t)ceil(divsp_i ((float)initParams->doaConfig.numAzimBins, (float)initParams->doaConfig.staticEstCfg.staticAzimStepDeciFactor))
* (int32_t)ceil(divsp_i ((float)initParams->doaConfig.numElevBins, (float)initParams->doaConfig.staticEstCfg.staticElevStepDeciFactor))
* initParams->doaConfig.numInputRangeBins;
if (heatmapSize < initParams->doaConfig.numRAangleBin * initParams->doaConfig.numInputRangeBins)
heatmapSize = initParams->doaConfig.numRAangleBin * initParams->doaConfig.numInputRangeBins;
if ( heatmapSize < initParams->doaConfig.numAzimBins * initParams->doaConfig.numElevBins)
heatmapSize = initParams->doaConfig.numAzimBins * initParams->doaConfig.numElevBins;
inst->localHeatmap = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, heatmapSize *sizeof(float), 8);
initParams->heatMapMemSize = heatmapSize;
inst->heatMapMemSize = heatmapSize;

if (initParams->doaConfig.rangeAngleCfg.detectionMethod <= 1)
maxNumAngleEst = initParams->doaConfig.angle2DEst.azimElevAngleEstCfg.maxNpeak2Search * (initParams->doaConfig.angle2DEst.azimElevAngleEstCfg.peakExpSamples * 2 + 1) * (initParams->doaConfig.angle2DEst.azimElevAngleEstCfg.peakExpSamples * 2 + 1);
else
maxNumAngleEst = (initParams->doaConfig.angle2DEst.azimElevZoominCfg.peakExpSamples * 2 + 1) * (initParams->doaConfig.angle2DEst.azimElevZoominCfg.peakExpSamples * 2 + 1);

inst->aoaOutput->azimEst = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * sizeof(float), 1);
inst->aoaOutput->elevEst = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * sizeof(float), 1);
inst->aoaOutput->peakPow = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * sizeof(float), 1);
inst->aoaOutput->bwFilter = (cplxf_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * initParams->doaConfig.nRxAnt * sizeof(cplxf_t), 8);
//inst->aoaOutput->malValPerRngBin = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, initParams->doaConfig.numInputRangeBins * sizeof(float), 1);
inst->aoaOutput->static_information = (cplxf_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, initParams->doaConfig.numInputRangeBins * initParams->doaConfig.nRxAnt * sizeof(cplxf_t), 8);
inst->aoaOutput->malValPerRngBin = inst->perRangeBinMax;

inst->aoaOutput->invRnMatrices = (cplxf_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, initParams->doaConfig.numInputRangeBins * (initParams->doaConfig.nRxAnt >> 1) * (initParams->doaConfig.nRxAnt + 1) * sizeof(cplxf_t), 8);
if (initParams->doaConfig.rangeAngleCfg.dopplerEstMethod == 1)
{
inst->aoaOutput->dopplerIdx = (uint16_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * MAX_DOPCFAR_DET * sizeof(uint16_t), 1);
inst->aoaOutput->dopplerDetSNR = (float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * MAX_DOPCFAR_DET * sizeof(float), 1);
}
else
{
inst->aoaOutput->dopplerIdx = (uint16_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, maxNumAngleEst * sizeof(uint16_t), 1);
}
#ifdef CAPON2DMODULEDEBUG
inst->aoaOutput->cyclesLog = (RADARDEMO_aoaEst2DCaponBF_moduleCycles *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, sizeof(RADARDEMO_aoaEst2DCaponBF_moduleCycles), 8);
memset(inst->aoaOutput->cyclesLog, 0, sizeof(RADARDEMO_aoaEst2DCaponBF_moduleCycles));
#endif

if ((inst->aoaOutput == NULL) || (inst->aoaInput == NULL))
{
errorCode = PROCESS_ERROR_DOAPROC_INOUTALLOC_FAILED;
}
}


/* dynamic Detection CFAR init and config */
{
inst->cfarRangeSkipLeft = initParams->dynamicCfarConfig.leftSkipSize;
inst->cfarRangeSkipRight = initParams->dynamicCfarConfig.rightSkipSize;
initParams->dynamicCfarConfig.fft2DSize = initParams->doaConfig.numRAangleBin;
initParams->dynamicCfarConfig.fft1DSize = inst->numRangeBins;
initParams->dynamicCfarConfig.maxNumDetObj = MAX_DYNAMIC_CFAR_PNTS;
initParams->dynamicCfarConfig.angleDim1 = initParams->doaConfig.numAzimBins; // not used, hardcoded to 0
initParams->dynamicCfarConfig.angleDim2 = initParams->doaConfig.numElevBins; // not used, hardcoded to 0

inst->dynamicCFARInstance = (void *) RADARDEMO_detectionCFAR_create(&initParams->dynamicCfarConfig, &inst->cfarErrorCode);
if (inst->cfarErrorCode > RADARDEMO_DETECTIONCFAR_NO_ERROR)
{
errorCode = PROCESS_ERROR_CFARPROC_INIT_FAILED;
}

inst->maxNumDetObj = initParams->maxNumDetObj;
inst->detectionCFAROutput = (RADARDEMO_detectionCFAR_output *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, sizeof(RADARDEMO_detectionCFAR_output), 1);
inst->detectionCFAROutput->rangeInd = (uint16_t *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, initParams->dynamicCfarConfig.maxNumDetObj * sizeof(uint16_t), 1);
inst->detectionCFAROutput->dopplerInd = (uint16_t *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, initParams->dynamicCfarConfig.maxNumDetObj * sizeof(uint16_t), 1);
inst->detectionCFAROutput->snrEst = (float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, initParams->dynamicCfarConfig.maxNumDetObj * sizeof(float), 1);
inst->detectionCFAROutput->noise = (float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, initParams->dynamicCfarConfig.maxNumDetObj * sizeof(float), 1);

inst->detectionCFARInput = (RADARDEMO_detectionCFAR_input *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, sizeof(RADARDEMO_detectionCFAR_input), 1);
inst->dynamicHeatmapPtr = (float **) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, initParams->dynamicCfarConfig.fft2DSize * sizeof(float *), 1);
inst->dynamicSideLobeThr = initParams->dynamicSideLobeThr;
inst->dynamicSideLobeThr = initParams->dynamicSideLobeThr;
for (i = 0; i < (int32_t)initParams->dynamicCfarConfig.fft2DSize; i++ )
{
inst->dynamicHeatmapPtr[i] = (float *) &inst->localHeatmap[i * initParams->dynamicCfarConfig.fft1DSize];
}

if ( (inst->detectionCFAROutput == NULL)
|| (inst->detectionCFAROutput->rangeInd == NULL)
|| (inst->detectionCFAROutput->dopplerInd == NULL)
|| (inst->detectionCFAROutput->snrEst == NULL)
|| (inst->detectionCFAROutput->noise == NULL))
{
errorCode = PROCESS_ERROR_CFARPROC_INOUTALLOC_FAILED;
}

}

inst->staticProcEnabled = initParams->doaConfig.staticEstCfg.staticProcEnabled;
perRngbinHeatmapLen = inst->numDynAngleBin;
/* static Detection CFAR init and config */
if (inst->staticProcEnabled)
{

inst->numStaticAngleBin = (int32_t)(ceil(divsp_i ((float)initParams->doaConfig.numAzimBins, (float)initParams->doaConfig.staticEstCfg.staticAzimStepDeciFactor))
* ceil(divsp_i ((float)initParams->doaConfig.numElevBins, (float)initParams->doaConfig.staticEstCfg.staticElevStepDeciFactor)));

perRngbinHeatmapLen = inst->numStaticAngleBin;
if ( perRngbinHeatmapLen < inst->numStaticAngleBin )
perRngbinHeatmapLen = inst->numStaticAngleBin;

initParams->staticCfarConfig.fft2DSize = inst->numStaticAngleBin;
initParams->staticCfarConfig.fft1DSize = inst->numRangeBins;
initParams->staticCfarConfig.maxNumDetObj = MAX_STATIC_CFAR_PNTS;
initParams->staticCfarConfig.angleDim2 = (uint32_t)ceil(divsp_i ((float)initParams->doaConfig.numAzimBins, (float)initParams->doaConfig.staticEstCfg.staticAzimStepDeciFactor));
initParams->staticCfarConfig.angleDim1 = (uint32_t)ceil(divsp_i ((float)initParams->doaConfig.numElevBins, (float)initParams->doaConfig.staticEstCfg.staticElevStepDeciFactor));
initParams->staticCfarConfig.leftSkipSize = inst->cfarRangeSkipLeft; //set the skip range bins the same as the dynamic scene
initParams->staticCfarConfig.rightSkipSize = inst->cfarRangeSkipRight; //set the skip range bins the same as the dynamic scene

inst->staticCFARInstance = (void *) RADARDEMO_detectionCFAR_create(&initParams->staticCfarConfig, &inst->cfarErrorCode);
if (inst->cfarErrorCode > RADARDEMO_DETECTIONCFAR_NO_ERROR)
{
errorCode = PROCESS_ERROR_CFARPROC_INIT_FAILED;
}

inst->staticSideLobeThr = initParams->staticSideLobeThr;
inst->staticHeatmapPtr = (float **) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL1, 0, initParams->dynamicCfarConfig.fft2DSize * sizeof(float *), 1);
for (i = 0; i < (int32_t)initParams->staticCfarConfig.fft2DSize; i++ )
{
inst->staticHeatmapPtr[i] = (float *) &inst->localHeatmap[i * initParams->staticCfarConfig.fft1DSize];
}

}
inst->tempHeatMapOut = (float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, perRngbinHeatmapLen * sizeof(float), 8);

inst->framePeriod = initParams->framePeriod;

inst->mimoModeFlag = (uint8_t)initParams->mimoModeFlag;
initParams->heatMapMem = inst->localHeatmap;
inst->benchmarkPtr = (radarProcessBenchmarkObj *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, sizeof(radarProcessBenchmarkObj), 1);
inst->benchmarkPtr->bufferLen = 20;
inst->benchmarkPtr->bufferIdx = 0;
inst->benchmarkPtr->buffer = (radarProcessBenchmarkElem *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, inst->benchmarkPtr->bufferLen * sizeof(radarProcessBenchmarkElem), 1);
#ifdef CAPON2DMODULEDEBUG
inst->benchmarkPtr->aoaCyclesLog = inst->aoaOutput->cyclesLog;
#endif

memset(inst->benchmarkPtr->buffer, 0, inst->benchmarkPtr->bufferLen * sizeof(radarProcessBenchmarkElem));

if ((inst->localHeatmap == NULL) ||(inst->benchmarkPtr == NULL) || (inst->benchmarkPtr->buffer == NULL))
errorCode = PROCESS_ERROR_INIT_MEMALLOC_FAILED;


initParams->benchmarkPtr = inst->benchmarkPtr;

*errCode = errorCode;

#ifndef CCS
System_printf("DPU_radarProcess_init - process handle: (radarProcessInstance_t *)0x%x\n", (uint32_t)inst);
System_printf("DPU_radarProcess_init - dynamic CFAR handle: (RADARDEMO_detectionCFAR_handle *)0x%x\n", (uint32_t)(inst->dynamicCFARInstance));
System_printf("DPU_radarProcess_init - staic CFAR handle: (RADARDEMO_detectionCFAR_handle *)0x%x\n", (uint32_t)(inst->staticCFARInstance));
System_printf("DPU_radarProcess_init - 2D capon handle: (RADARDEMO_aoaEst2DCaponBF_handle *)0x%x\n", (uint32_t)(inst->aoaInstance));
System_printf("DPU_radarProcess_init - benchmark obj: (radarProcessBenchmarkObj *)0x%x\n", (uint32_t)(inst->benchmarkPtr));
System_printf("DPU_radarProcess_init - heatmap: (float *)0x%x\n", (uint32_t)(inst->localHeatmap));
#else
printf("DPU_radarProcess_init - process handle: (radarProcessInstance_t *)0x%x\n", (uint32_t)inst);
printf("DPU_radarProcess_init - dynamic CFAR handle: (RADARDEMO_detectionCFAR_handle *)0x%x\n", (uint32_t)(inst->dynamicCFARInstance));
printf("DPU_radarProcess_init - staic CFAR handle: (RADARDEMO_detectionCFAR_handle *)0x%x\n", (uint32_t)(inst->staticCFARInstance));
printf("DPU_radarProcess_init - 2D capon handle: (RADARDEMO_aoaEst2DCaponBF_handle *)0x%x\n", (uint32_t)(inst->aoaInstance));
printf("DPU_radarProcess_init - benchmark obj: (radarProcessBenchmarkObj *)0x%x\n", (uint32_t)(inst->benchmarkPtr));
printf("DPU_radarProcess_init - heatmap: (float *)0x%x\n", (uint32_t)(inst->localHeatmap));
#endif
return (void *) inst;
}

/**
* @b Description
* @n
* The function is radarProcess DPU config function. Currently not used.
*
* @param[in] handle radarProcess handle.
* @param[in] sampleProcCfg radarProcess configurations.
* @param[in] errCode Pointer to errCode generates from the API
*
* \ingroup DPU_SAMPLEPROC_EXTERNAL_FUNCTION
*
* @retval
* Success =0
* @retval
* Error <0
*/
int32_t DPU_radarProcess_config
(
DPU_radarProcess_Handle hndle,
DPU_radarProcessConfig_t * initParams,
DPU_ProcessErrorCodes * errCode
)
{
int32_t retVal = 0;

return (retVal);

}

/**
* @b Description
* @n
* The function is radarProcess DPU process function. It runs from the data path
* processing chain, with configuration and buffers assiged at config time.
*
* @param[in] handle radarProcess handle.
* @param[in] pDataIn Input buffer for the processing -- range FFT output in radar cube
* @param[out] pDataOut 3D point cloud data
* @param[out] errCode Pointer to errCode generates from the API
*
* @retval
* Success =0
* @retval
* Error <0
*/

int32_t DPU_radarProcess_process (void *handle, cplx16_t * pDataIn, void * pDataOut, int32_t *errCode)
{
radarProcessInstance_t * processInst = (radarProcessInstance_t *)handle;
#ifdef _TMS320C6X
int32_t t1;
#endif
int32_t i, cOutNumDectected, numDynamicPnts;
//RADARDEMO_aoaEst2DCaponBF_errorCode aoaBFErrorCode;
radarProcessOutput *resultsPtr = (radarProcessOutput *) pDataOut;
radarProcessOutputToTracker * output = &resultsPtr->pointCloudOut;
DPIF_DetMatrix * heatmap = &resultsPtr->heatMapOut;
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////// Calling modules -- Dynamic processing ////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
{ //range-angle heatmap generation for dynamic scene processing
processInst->aoaInput->fallBackToConvBFFlag = 0; //capon only
processInst->aoaInput->processingStepSelector = 0; //BF part
processInst->aoaInput->clutterRemovalFlag = 1; //clutter removal always on
processInst->aoaInput->nChirps = processInst->numChirpsPerFrame;
processInst->aoaInput->lastRB2Process = 0;
#ifdef _TMS320C6X
t1 = TSCL;
#endif

#ifdef CAPON2DMODULEDEBUG
processInst->aoaOutput->cyclesLog->uniqueRngCnt = 0;
processInst->aoaOutput->cyclesLog->dopDetCnt = 0;
processInst->aoaOutput->cyclesLog->raDetCnt = 0;
#endif

for ( i = processInst->cfarRangeSkipLeft; i < processInst->numRangeBins - processInst->cfarRangeSkipRight; i++)
{
processInst->aoaInput->rangeIndx = i;
processInst->aoaInput->inputRangeProcOutSamples = &pDataIn[i * processInst->nRxAnt * processInst->aoaInput->nChirps];
processInst->aoaOutput->rangeAzimuthHeatMap = processInst->tempHeatMapOut;
//has to be set to indicate the last rb to process, so that buffer init will be done correctly inside module, only needed for dynamic processing.
if ( i == (processInst->numRangeBins - processInst->cfarRangeSkipRight - 1))
processInst->aoaInput->lastRB2Process = 1;
processInst->aoaBFErrorCode = RADARDEMO_aoaEst2DCaponBF_run(
processInst->aoaInstance,
processInst->aoaInput,
processInst->aoaOutput);

//transpose and store
copyTranspose((uint32_t *)&processInst->tempHeatMapOut[0], (uint32_t *)&processInst->localHeatmap[i], processInst->numDynAngleBin, 0, processInst->numRangeBins, 1);
}
#ifdef _TMS320C6X
processInst->benchmarkPtr->bufferIdx++;
if (processInst->benchmarkPtr->bufferIdx >= processInst->benchmarkPtr->bufferLen)
processInst->benchmarkPtr->bufferIdx = 0;
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].dynHeatmpGenCycles = TSCL - t1;
#endif
}

{ //Dynamic CFAR

#ifdef _TMS320C6X
t1 = TSCL;
#endif
processInst->detectionCFARInput->azMaxPerRangeBin = processInst->perRangeBinMax;
processInst->detectionCFARInput->sidelobeThr = processInst->dynamicSideLobeThr;
processInst->detectionCFARInput->enableSecondPass = 1;
processInst->detectionCFARInput->enable_neighbour_check = 1;
processInst->detectionCFARInput->heatmapInput = processInst->dynamicHeatmapPtr;
// Detection
processInst->cfarErrorCode = RADARDEMO_detectionCFAR_run(
processInst->dynamicCFARInstance,
processInst->detectionCFARInput,
processInst->detectionCFAROutput);

#ifdef _TMS320C6X
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].dynCfarDetectionCycles = TSCL - t1;
#endif
}
#ifdef CCS
printf("CFAR pnt: %d\t", processInst->detectionCFAROutput->numObjDetected);
#endif
cOutNumDectected = 0;
{ // angle and doppler estimation, per detected range-angle points -- for dynamic scene processing
int32_t angleCount, dopplerCount, detIdx;
int32_t dopplerIdx;

processInst->aoaInput->processingStepSelector = 1;
#ifdef _TMS320C6X
t1 = TSCL;
#endif
processInst->aoaInput->nChirps = processInst->numChirpsPerFrame;
processInst->aoaOutput->rangeAzimuthHeatMap = processInst->localHeatmap;
for (detIdx = 0; detIdx < (int32_t)processInst->detectionCFAROutput->numObjDetected; detIdx++)
{
if (cOutNumDectected > DOA_OUTPUT_MAXPOINTS) break;
processInst->aoaInput->rangeIndx = processInst->detectionCFAROutput->rangeInd[detIdx];
processInst->aoaInput->angleIndx = processInst->detectionCFAROutput->dopplerInd[detIdx];
processInst->aoaInput->inputRangeProcOutSamples = &pDataIn[processInst->aoaInput->rangeIndx * processInst->nRxAnt * processInst->aoaInput->nChirps];
processInst->aoaInput->noise = processInst->detectionCFAROutput->noise[detIdx];

processInst->aoaBFErrorCode = RADARDEMO_aoaEst2DCaponBF_run(
processInst->aoaInstance,
processInst->aoaInput,
processInst->aoaOutput);

dopplerCount = 0;
for ( angleCount = 0; angleCount < processInst->aoaOutput->numAngleEst; angleCount++ )
{
if (cOutNumDectected > DOA_OUTPUT_MAXPOINTS) break;
for ( i = 0; i < processInst->aoaOutput->numDopplerIdx; i++ )
{
output->pointCloud[cOutNumDectected].range = (float)processInst->aoaInput->rangeIndx * processInst->rangeRes;
output->pointCloud[cOutNumDectected].azimuthAngle = processInst->aoaOutput->azimEst[angleCount];
output->pointCloud[cOutNumDectected].elevAngle = processInst->aoaOutput->elevEst[angleCount];
dopplerIdx = (int32_t)processInst->aoaOutput->dopplerIdx[dopplerCount++];
if ( dopplerIdx > (processInst->DopplerFFTSize >> 1))
dopplerIdx -= processInst->DopplerFFTSize;
output->pointCloud[cOutNumDectected].velocity = (float)dopplerIdx * processInst->dopplerRes;
if (processInst->aoaOutput->numAngleEst == 1)
output->snr[cOutNumDectected].snr = (int16_t)((float)processInst->detectionCFAROutput->snrEst[detIdx] * 8.f);
else
output->snr[cOutNumDectected].snr = (int16_t)(divsp_i ((float)processInst->aoaOutput->peakPow[angleCount], processInst->aoaInput->noise) * 8.f);
cOutNumDectected++;
if (cOutNumDectected > DOA_OUTPUT_MAXPOINTS) break;
}
}
}
numDynamicPnts = cOutNumDectected;
#ifdef _TMS320C6X
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].dynAngleDopEstCycles = TSCL - t1;
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].dynNumDetPnts = numDynamicPnts;
#endif

}
#ifdef CCS
printf("dyn pnt: %d\t", numDynamicPnts);
#endif
/////////////////// end of Dynamic processing ////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////
/////////////////// Calling modules -- Static processing ////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////

if ((processInst->staticProcEnabled) && (cOutNumDectected < DOA_OUTPUT_MAXPOINTS))
{ //range-angle heatmap generation for Static scene processing

processInst->aoaInput->processingStepSelector = 0; //BF part
#ifdef _TMS320C6X
t1 = TSCL;
#endif
for ( i = 0; i < processInst->numRangeBins; i++)
{
processInst->aoaInput->rangeIndx = i;
processInst->aoaOutput->rangeAzimuthHeatMap = processInst->tempHeatMapOut;
processInst->aoaBFErrorCode = RADARDEMO_aoaEst2DCaponBF_static_run(
processInst->aoaInstance,
processInst->aoaInput,
processInst->aoaOutput);
copyTranspose((uint32_t *)&processInst->tempHeatMapOut[0], (uint32_t *)&processInst->localHeatmap[i], processInst->numStaticAngleBin, 0, processInst->numRangeBins, 1);
}
#ifdef _TMS320C6X
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].staticHeatmpGenCycles = TSCL - t1;
#endif
}

if (processInst->staticProcEnabled)
{ // test CFAR -- for Static scene processing

#ifdef _TMS320C6X
t1 = TSCL;
#endif
processInst->detectionCFARInput->azMaxPerRangeBin = processInst->perRangeBinMax;
processInst->detectionCFARInput->sidelobeThr = processInst->staticSideLobeThr;
processInst->detectionCFARInput->enableSecondPass = 0;
processInst->detectionCFARInput->enable_neighbour_check = 1;
processInst->detectionCFARInput->heatmapInput = processInst->staticHeatmapPtr;
// Detection
processInst->cfarErrorCode = RADARDEMO_detectionCFAR_run(
processInst->staticCFARInstance,
processInst->detectionCFARInput,
processInst->detectionCFAROutput);

#ifdef _TMS320C6X
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].staticCfarDetectionCycles = TSCL - t1;
#endif
}

if (processInst->staticProcEnabled)
{ // angle interpolation per detected range-angle points -- for Static scene processing
int32_t detIdx, angleIdx;
#ifdef _TMS320C6X
t1 = TSCL;
#endif
processInst->aoaInput->processingStepSelector = 1;
processInst->aoaOutput->rangeAzimuthHeatMap = &processInst->localHeatmap[0];
processInst->aoaInput->nChirps = processInst->numChirpsPerFrame;
processInst->aoaOutput->rangeAzimuthHeatMap = processInst->localHeatmap;
for (detIdx = 0; detIdx < (int32_t)processInst->detectionCFAROutput->numObjDetected; detIdx++)
{
if (cOutNumDectected > DOA_OUTPUT_MAXPOINTS) break;
processInst->aoaInput->rangeIndx = processInst->detectionCFAROutput->rangeInd[detIdx];
processInst->aoaInput->angleIndx = processInst->detectionCFAROutput->dopplerInd[detIdx];
processInst->aoaInput->inputRangeProcOutSamples = &pDataIn[processInst->aoaInput->rangeIndx * processInst->nRxAnt * processInst->aoaInput->nChirps];
processInst->aoaInput->noise = processInst->detectionCFAROutput->noise[detIdx];

processInst->aoaBFErrorCode = RADARDEMO_aoaEst2DCaponBF_static_run(
processInst->aoaInstance,
processInst->aoaInput,
processInst->aoaOutput);

for ( angleIdx = 0; angleIdx < processInst->aoaOutput->numAngleEst; angleIdx++ )
{
output->pointCloud[cOutNumDectected].range = (float)processInst->aoaInput->rangeIndx * processInst->rangeRes;
output->pointCloud[cOutNumDectected].azimuthAngle = -processInst->aoaOutput->azimEst[angleIdx];
output->pointCloud[cOutNumDectected].elevAngle = processInst->aoaOutput->elevEst[angleIdx];
output->pointCloud[cOutNumDectected].velocity = 0.f;
output->snr[cOutNumDectected].snr = (int16_t)(divsp_i ((float)processInst->aoaOutput->peakPow[angleIdx], processInst->aoaInput->noise) * 8.f);
cOutNumDectected++;
if (cOutNumDectected > DOA_OUTPUT_MAXPOINTS) break;

}
}
#ifdef _TMS320C6X
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].staticAngleEstCycles = TSCL - t1;
processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx].staticNumDetPnts = cOutNumDectected - numDynamicPnts;
#endif
}
#ifdef CCS
printf("static pnt: %d\t", cOutNumDectected - numDynamicPnts);
#endif

#ifdef _TMS320C6X
resultsPtr->benchmarkOut = &processInst->benchmarkPtr->buffer[processInst->benchmarkPtr->bufferIdx];
#endif

heatmap->datafmt = 0;
heatmap->dataSize = processInst->heatMapMemSize;
heatmap->data = (void *)processInst->localHeatmap;

output->object_count = cOutNumDectected;

*errCode = (int32_t)processInst->aoaBFErrorCode;

return(-processInst->aoaBFErrorCode);
}


/**
* @b Description
* @n
* The function is radarProcess DPU control function. Currently not used.
*
* @param[in] handle radarProcess handle.
*
* @retval
* Success =0
* @retval
* Error <0
*/
int32_t DPU_radarProcess_control
(
DPU_radarProcess_Handle handle
)
{
int32_t retVal = 0;

return (retVal);
}

/**
* @b Description
* @n
* The function is radarProcess DPU deinit function. It release resources used for the DPU.
*
* @param[in] handle radarProcess handle.
* @param[in] errCode Pointer to errCode generates from the API
*
*
* @retval
* Success =0
* @retval
* Error <0
*/
int32_t DPU_radarProcess_deinit
(
DPU_radarProcess_Handle handle,
int32_t *errCode
)
{
radarProcessInstance_t * processInst = (radarProcessInstance_t *)handle;

RADARDEMO_aoaEst2DCaponBF_delete(processInst->aoaInstance);
RADARDEMO_detectionCFAR_delete(processInst->dynamicCFARInstance);
if (processInst->staticProcEnabled)
RADARDEMO_detectionCFAR_delete(processInst->staticCFARInstance);

//
radarOsal_memFree(processInst, sizeof(radarProcessInstance_t));

return 0;
}


+ 1
- 0
dss/src/.exclude View File

@@ -0,0 +1 @@
This file exists to prevent Eclipse/CDT from adding the C sources contained in this directory (or below) to any enclosing project.

+ 62
- 0
dss/src/makefile.libs View File

@@ -0,0 +1,62 @@
#
# This file was generated based on the configuration script:
# C:\Users\Daunair\workspace_v10\3D_people_count_68xx_dss\dss\pcount3D_dss.cfg
#
# This makefile may be included in other makefiles that need to build
# the libraries containing the compiled source files generated as
# part of the configuration step.

#
# ======== GEN_SRC_DIR =========
# The path to the sources generated during configuration
#
# This path must be either absolute or relative to the build directory.
#
# The absolute path to the generated source directory (at the time the
# sources were generated) is:
# C:\Users\Daunair\workspace_v10\3D_people_count_68xx_dss\dss\src
#
GEN_SRC_DIR ?= ../dss/src

ifeq (,$(wildcard $(GEN_SRC_DIR)))
$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources")
endif

#
# ======== .force ========
# The .force goal is used to force the build of any goal that names it as
# a prerequisite
#
.PHONY: .force
#
# ======== library macros ========
#
sysbios_SRC = $(GEN_SRC_DIR)/sysbios
sysbios_LIB = $(GEN_SRC_DIR)/sysbios/sysbios.ae674

#
# ======== dependencies ========
#
all: $(sysbios_LIB)
clean: .sysbios_clean


# ======== convenient build goals ========
.PHONY: sysbios
sysbios: $(GEN_SRC_DIR)/sysbios/sysbios.ae674

# CDT managed make executables depend on $(OBJS)
OBJS += $(sysbios_LIB)

#
# ======== rules ========
#
$(sysbios_LIB): .force
@echo making $@ ...
@$(MAKE) -C $(sysbios_SRC)

.sysbios_clean:
@echo cleaning $(sysbios_SRC) ...
-@$(MAKE) --no-print-directory -C $(sysbios_SRC) clean


+ 78
- 0
dss/src/sysbios/makefile View File

@@ -0,0 +1,78 @@
# This is a generated file.
#
# Do not edit this file. Any modifications to this file
# will be overwritten whenever makefiles are re-generated.
#
# template: ti.sysbios/makefile.xdt
# target: ti.targets.elf.C674

vpath % C:/ti/bios_6_73_01_01/packages/ti/sysbios/
vpath %.c C:/ti/xdctools_3_50_08_24_core/packages/

XOPTS = -I"C:/ti/xdctools_3_50_08_24_core/packages/" -Dxdc_target_types__=C:/ti/bios_6_73_01_01/packages/ti/targets/elf/std.h -Dxdc_target_name__=C674

BIOS_DEFS = -Dti_sysbios_BIOS_swiEnabled__D=TRUE -Dti_sysbios_BIOS_taskEnabled__D=TRUE -Dti_sysbios_BIOS_clockEnabled__D=TRUE -Dti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE -Dti_sysbios_knl_Task_moduleStateCheckFlag__D=FALSE -Dti_sysbios_knl_Task_objectCheckFlag__D=FALSE -Dti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Swi_DISABLE_ALL_HOOKS -Dti_sysbios_BIOS_smpEnabled__D=FALSE -Dti_sysbios_BIOS_mpeEnabled__D=FALSE -Dti_sysbios_Build_useHwiMacros -Dti_sysbios_knl_Swi_numPriorities__D=16 -Dti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE -Dti_sysbios_knl_Task_numPriorities__D=16 -Dti_sysbios_knl_Task_checkStackFlag__D=TRUE -Dti_sysbios_knl_Task_initStackFlag__D=TRUE -Dti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER -Dti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_PERIODIC -Dti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E -Dti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E -Dti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E -Dti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E -Dti_sysbios_hal_Core_numCores__D=1 -Dti_sysbios_hal_CoreNull_numCores__D=1 -Dti_sysbios_utils_Load_taskEnabled__D=TRUE -Dti_sysbios_utils_Load_swiEnabled__D=FALSE -Dti_sysbios_utils_Load_hwiEnabled__D=FALSE -Dti_sysbios_family_c64p_Hwi_dispatcherSwiSupport__D=TRUE -Dti_sysbios_family_c64p_Hwi_dispatcherTaskSupport__D=TRUE -Dti_sysbios_family_c64p_Hwi_dispatcherAutoNestingSupport__D=TRUE -Dti_sysbios_family_c64p_Hwi_dispatcherIrpTrackingSupport__D=TRUE -Dti_sysbios_knl_Semaphore_supportsEvents__D=FALSE -Dti_sysbios_knl_Semaphore_supportsPriority__D=TRUE -Dxdc_runtime_Log_DISABLE_ALL

CCOPTS = -mv6740 --abi=eabi -q -mi10 -mo -pdr -pden -pds=238 -pds=880 -pds1110 --program_level_compile -o3 -g --enum_type=int -Dti_sysbios_family_c64p_Exception_enableExternalMPC__D=FALSE -Dti_sysbios_family_c64p_Exception_enablePrint__D=TRUE -Dti_sysbios_knl_Clock_stopCheckNext__D=FALSE -Dti_sysbios_knl_Task_ENABLE_SWITCH_HOOKS -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE

BIOS_INC = -I"C:/ti/bios_6_73_01_01/packages/"
ANNEX_INCS =
INCS = $(BIOS_INC) $(ANNEX_INCS) -I"C:/ti/bios_6_73_01_01/packages/" -I"C:/ti/xdctools_3_50_08_24_core/packages/" -I"../" -I"/packages//" -IC:/ti/ti-cgt-c6000_8.3.3/include

CC = C:/ti/ti-cgt-c6000_8.3.3/bin/cl6x -c $(CCOPTS)
ASM = C:/ti/ti-cgt-c6000_8.3.3/bin/cl6x -c $(CCOPTS)
AR = C:/ti/ti-cgt-c6000_8.3.3/bin/ar6x rq

DEL = C:/ti/xdctools_3_50_08_24_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_50_08_24_core/packages/../bin/cp -f

define RM
$(if $(wildcard $1),$(DEL) $1,:)
endef

define ASSEMBLE
@echo asme674 $< ...
@$(ASM) $(BIOS_DEFS) $(XOPTS) $(INCS) $<
endef

all: sysbios.ae674

c64p_Exception_asm.obj: family/c64p/Exception_asm.s64P makefile
@-$(call RM, $@)
$(ASSEMBLE) --output_file=c64p_Exception_asm.obj

c64p_Hwi_asm.obj: family/c64p/Hwi_asm.s62 makefile
@-$(call RM, $@)
$(ASSEMBLE) --output_file=c64p_Hwi_asm.obj

c64p_Hwi_asm_switch.obj: family/c64p/Hwi_asm_switch.s62 makefile
@-$(call RM, $@)
$(ASSEMBLE) --output_file=c64p_Hwi_asm_switch.obj

c64p_Hwi_disp_always.obj: family/c64p/Hwi_disp_always.s64P makefile
@-$(call RM, $@)
$(ASSEMBLE) --output_file=c64p_Hwi_disp_always.obj

ti_tls_get_tp.obj: rts/ti/tls_get_tp.asm makefile
@-$(call RM, $@)
$(ASSEMBLE) --output_file=ti_tls_get_tp.obj

c62_TaskSupport_asm.obj: family/c62/TaskSupport_asm.s62 makefile
@-$(call RM, $@)
$(ASSEMBLE) --output_file=c62_TaskSupport_asm.obj


BIOS.obj: BIOS.c family/c64p/EventCombiner.c family/c64p/Exception.c family/c64p/Hwi.c family/c64p/Hwi_startup.c family/c64p/TimestampProvider.c family/c64p/Cache.c knl/Clock.c knl/Idle.c knl/Intrinsics.c knl/Event.c knl/Queue.c knl/Semaphore.c knl/Swi.c knl/Task.c heaps/HeapBuf.c heaps/HeapMem.c utils/Load.c utils/Load_CPU.c rts/ti/ThreadLocalStorage.c hal/Hwi.c hal/Hwi_stack.c hal/Hwi_startup.c family/c62/TaskSupport.c family/c62/IntrinsicsSupport.c gates/GateHwi.c gates/GateMutex.c timers/rti/Timer.c xdc/runtime/xdc_noinit.c xdc/runtime/Assert.c xdc/runtime/Core-mem.c xdc/runtime/Core-smem.c xdc/runtime/Core-label.c xdc/runtime/Core-params.c xdc/runtime/Diags.c xdc/runtime/Error.c xdc/runtime/Gate.c xdc/runtime/Log.c xdc/runtime/LoggerBuf.c xdc/runtime/Memory.c xdc/runtime/Registry.c xdc/runtime/Startup.c xdc/runtime/System.c xdc/runtime/SysStd.c xdc/runtime/Text.c xdc/runtime/Timestamp.c xdc/runtime/TimestampNull.c makefile
@-$(call RM, $@)
@echo cle674 $< ...
@$(CC) $(BIOS_DEFS) $(XOPTS) $(INCS) $(subst makefile,,$^)

sysbios.ae674: BIOS.obj c64p_Exception_asm.obj c64p_Hwi_asm.obj c64p_Hwi_asm_switch.obj c64p_Hwi_disp_always.obj ti_tls_get_tp.obj c62_TaskSupport_asm.obj
@-$(call RM, $@)
@echo are674 $^ ...
@$(AR) $@ $^


clean:
@$(DEL) ..\makefile.libs
@-$(call RM, *)

BIN
dss/src/sysbios/sysbios.ae674 View File


Loading…
Cancel
Save