firstone
This commit is contained in:
@@ -38,6 +38,32 @@
|
||||
#include <ti/drivers/pinmux/pinmux.h>
|
||||
#include <ti/drivers/osal/MemoryP.h>
|
||||
#include <ti/utils/testlogger/logger.h>
|
||||
/* Global Variable: The variable detects if the configuration has been
|
||||
* detected or not. */
|
||||
uint32_t gConfigDetected = 0U;
|
||||
|
||||
/* Global Variable: The variable detects if the start has been
|
||||
* detected or not. */
|
||||
uint32_t gStartDetected = 0U;
|
||||
|
||||
/* Global Variable: The variable detects if the start has been
|
||||
* detected or not. */
|
||||
uint32_t gStopDetected = 0U;
|
||||
|
||||
/* Global Variable: The variable detects if the open has been
|
||||
* detected or not. */
|
||||
uint32_t gOpenDetected = 0U;
|
||||
|
||||
/* Global Variable: The variable detects if the close has been
|
||||
* detected or not. */
|
||||
uint32_t gCloseDetected = 0U;
|
||||
|
||||
/* Global Variable: This is the handle to the mmWave module */
|
||||
MMWave_Handle gMMWaveHandle;
|
||||
|
||||
/* Global Variable: The variable detects the test selection as entered on the MSS */
|
||||
int32_t gTestSelection;
|
||||
|
||||
SOC_Handle socHandle;
|
||||
Event_Handle event;
|
||||
uint8_t period = 0;
|
||||
@@ -49,6 +75,7 @@ uint8_t id = 0;
|
||||
uint8_t metka = 0;
|
||||
|
||||
UART_Handle handle;
|
||||
MMWave_Handle handleMMwave;
|
||||
|
||||
UInt eventMask1 = Event_Id_00;
|
||||
UInt eventMask2 = Event_Id_01;
|
||||
@@ -95,12 +122,16 @@ Mbox_Handle peerMailbox;
|
||||
#define BIG_MSG_SIZE 3
|
||||
|
||||
volatile uint8_t mboxProcToken = 0;
|
||||
|
||||
//void MmwDemo_sleep(void)
|
||||
//{
|
||||
// /* issue WFI (Wait For Interrupt) instruction */
|
||||
// asm(" IDLE ");
|
||||
//}
|
||||
extern void Mmwave_populateDefaultOpenCfg (MMWave_OpenCfg* ptrOpenCfg);
|
||||
extern int32_t Mmwave_testLinkAPI (void);
|
||||
extern int32_t Mmwave_eventFxn(uint16_t msgId, uint16_t sbId, uint16_t sbLen, uint8_t *payload);
|
||||
extern void Mmwave_cfgFxn(MMWave_CtrlCfg* ptrCtrlCfg);
|
||||
extern void Mmwave_startFxn(MMWave_CalibrationCfg* ptrCalibrationCfg);
|
||||
extern void Mmwave_stopFxn(void);
|
||||
extern void Mmwave_openFxn (MMWave_OpenCfg* ptrOpenCfg);
|
||||
extern void Mmwave_closeFxn (void);
|
||||
extern void Mmwave_ctrlTask(UArg arg0, UArg arg1);
|
||||
extern int32_t MonitoringEnable();
|
||||
|
||||
static int32_t mboxWrite_ch0(uint8_t *message, int32_t len)
|
||||
{
|
||||
@@ -132,11 +163,30 @@ static void mboxReadProc_ch0()
|
||||
else
|
||||
{
|
||||
Mailbox_readFlush (peerMailbox);
|
||||
UART_write(handle, "\n", 1);
|
||||
System_printf("%d\n", mes);
|
||||
UART_write(handle, &mes, 1);
|
||||
UART_write(handle, "\n", 1);
|
||||
|
||||
int i;
|
||||
if(mes/100 > 0) {
|
||||
i = 3;
|
||||
} else if((mes - (mes / 100) * 100) / 10 > 0) {
|
||||
i = 2;
|
||||
} else {
|
||||
i = 1;
|
||||
}
|
||||
char str[i];
|
||||
if(i == 3) {
|
||||
str[0] = '0' + mes / 100;
|
||||
mes = mes - (mes / 100) * 100;
|
||||
str[1] = '0' + mes / 10;
|
||||
mes = mes - (mes / 10) * 10;
|
||||
str[2] = '0' + mes;
|
||||
} else if(i == 2) {
|
||||
str[0] = '0' + mes / 10;
|
||||
mes = mes - (mes / 10) * 10;
|
||||
str[1] = '0' + mes;
|
||||
} else {
|
||||
str[0] = '0' + mes;
|
||||
}
|
||||
CLI_write(str);
|
||||
CLI_write("\n");
|
||||
if (ret != 0)
|
||||
{
|
||||
System_printf ("Error: Mailbox send message failed \n");
|
||||
@@ -150,7 +200,7 @@ static void mboxReadProc_ch0()
|
||||
void mboxCallback_ch0 (Mbox_Handle handle, Mailbox_Type peer)
|
||||
{
|
||||
/* Message has been received from the peer endpoint. */
|
||||
// mboxReadProc_ch0();
|
||||
// mboxReadProc_ch0();
|
||||
mboxProcToken = 1;
|
||||
}
|
||||
|
||||
@@ -167,12 +217,33 @@ void mBox(UArg a0, UArg a1)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t SetVal(int32_t argc, char* argv[])
|
||||
{
|
||||
uint8_t message[BIG_MSG_SIZE];
|
||||
message[0] = 0;
|
||||
int id = atoi(argv[1]);
|
||||
int value = atoi(argv[2]);
|
||||
if((value > 255) || (id > 128)) return -1;
|
||||
message[1] = (uint8_t)atoi(argv[1]);
|
||||
message[2] = (uint8_t)atoi(argv[2]);
|
||||
mboxWrite_ch0(message, BIG_MSG_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Get(int32_t argc, char* argv[])
|
||||
{
|
||||
uint8_t message[BIG_MSG_SIZE];
|
||||
message[0] = 1;
|
||||
int id = atoi(argv[1]);
|
||||
if(id > 128) return -1;
|
||||
message[1] = (uint8_t)atoi(argv[1]);
|
||||
mboxWrite_ch0(message, BIG_MSG_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Work_UART(UArg arg0, UArg arg1)
|
||||
{
|
||||
uint8_t index[128];
|
||||
uint8_t message[BIG_MSG_SIZE];
|
||||
UART_Params params;
|
||||
uint8_t len;
|
||||
|
||||
/* Setup the default UART Parameters */
|
||||
UART_Params_init(¶ms);
|
||||
@@ -189,76 +260,156 @@ void Work_UART(UArg arg0, UArg arg1)
|
||||
printf("Error: Unable to open the UART Instance\n");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
while(TRUE)
|
||||
void init_mmWave() {
|
||||
MMWave_InitCfg initCfg;
|
||||
Task_Params taskParams;
|
||||
MMWave_CalibrationCfg calibrationCfg;
|
||||
MMWave_OpenCfg openCfg;
|
||||
int32_t errCode;
|
||||
/* Initialize the configuration: */
|
||||
memset ((void *)&initCfg, 0, sizeof(MMWave_InitCfg));
|
||||
memset ((void *)&calibrationCfg, 0, sizeof(MMWave_CalibrationCfg));
|
||||
|
||||
/***********************************************************************
|
||||
* [Isolation Mode]: MSS executes the mmWave link
|
||||
***********************************************************************/
|
||||
initCfg.domain = MMWave_Domain_MSS;
|
||||
initCfg.socHandle = socHandle;
|
||||
initCfg.eventFxn = Mmwave_eventFxn;
|
||||
initCfg.cfgMode = MMWave_ConfigurationMode_MINIMAL;
|
||||
initCfg.executionMode = MMWave_ExecutionMode_ISOLATION;
|
||||
initCfg.linkCRCCfg.useCRCDriver = 1U;
|
||||
initCfg.linkCRCCfg.crcChannel = CRC_Channel_CH1;
|
||||
|
||||
/* Initialize and setup the mmWave Control module */
|
||||
gMMWaveHandle = MMWave_init (&initCfg, &errCode);
|
||||
if (gMMWaveHandle == NULL)
|
||||
{
|
||||
len = UART_read(handle, index, sizeof(index)/sizeof(uint8_t)) - 1;
|
||||
if(len <= 13)
|
||||
{
|
||||
if(memcmp(index, "Get ID ", 7) == 0)
|
||||
{
|
||||
int i;
|
||||
for(i = 7; i < len; i++)
|
||||
{
|
||||
if(index[i] >= '0' && index[i] <= '9')
|
||||
{
|
||||
id_buf = id_buf * 10 + (index[i] - '0');
|
||||
}
|
||||
}
|
||||
message[0] = 0;
|
||||
id = id_buf;
|
||||
id_buf = 0;
|
||||
message[1] = id;
|
||||
mboxWrite_ch0(message, BIG_MSG_SIZE);
|
||||
}
|
||||
else if(memcmp(index, "Set ", 4) == 0)
|
||||
{
|
||||
int i;
|
||||
int pointer = 0;
|
||||
for(i = 4; i < len; i++)
|
||||
{
|
||||
if(index[i] >= '0' && index[i] <= '9')
|
||||
{
|
||||
value_buf = value_buf * 10 + (index[i] - '0');
|
||||
} else if(index[i] == 'I') {
|
||||
pointer = i;
|
||||
value = value_buf;
|
||||
value_buf = 0;
|
||||
message[2] = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(memcmp(index, " ID ", 4)) {
|
||||
int i;
|
||||
for(i = pointer + 2; i < len; i++)
|
||||
{
|
||||
if(index[i] >= '0' && index[i] <= '9')
|
||||
{
|
||||
id_buf = id_buf * 10 + (index[i] - '0');
|
||||
}
|
||||
}
|
||||
id = id_buf;
|
||||
id_buf = 0;
|
||||
message[0] = 1;
|
||||
message[1] = id;
|
||||
mboxWrite_ch0(message, BIG_MSG_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
UART_write(handle, "\nError\n", 7);
|
||||
}
|
||||
/* Error: Unable to initialize the mmWave control module */
|
||||
System_printf ("Error: mmWave Control Initialization failed [Error code %d]\n", errCode);
|
||||
|
||||
/* Log into the MCPI Test Logger: */
|
||||
return;
|
||||
}
|
||||
/******************************************************************************
|
||||
* TEST: Synchronization
|
||||
* - The synchronization API always needs to be invoked [Irrespective of the
|
||||
* mode]
|
||||
******************************************************************************/
|
||||
while (1)
|
||||
{
|
||||
int32_t syncStatus;
|
||||
|
||||
/* Get the synchronization status: */
|
||||
syncStatus = MMWave_sync (gMMWaveHandle, &errCode);
|
||||
if (syncStatus < 0)
|
||||
{
|
||||
/* Error: Unable to synchronize the mmWave control module */
|
||||
System_printf ("Error: mmWave Control Synchronization failed [Error code %d]\n", errCode);
|
||||
return;
|
||||
}
|
||||
if (syncStatus == 1)
|
||||
{
|
||||
/* Synchronization acheived: */
|
||||
break;
|
||||
}
|
||||
/* Sleep and poll again: */
|
||||
Task_sleep(1);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Launch the mmWave control execution task
|
||||
* - This should have a higher priroity than any other task which uses the
|
||||
* mmWave control API
|
||||
*****************************************************************************/
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.priority = 6;
|
||||
taskParams.stackSize = 4*1024;
|
||||
Task_create(Mmwave_ctrlTask, &taskParams, NULL);
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* [Isolation Mode]: MSS executes the mmWave link
|
||||
***********************************************************************/
|
||||
Mmwave_populateDefaultOpenCfg (&openCfg);
|
||||
|
||||
/************************************************************************
|
||||
* Open the mmWave:
|
||||
************************************************************************/
|
||||
if (MMWave_open (gMMWaveHandle, &openCfg, NULL, &errCode) < 0)
|
||||
{
|
||||
/* Error: Unable to configure the mmWave control module */
|
||||
System_printf ("Error: mmWave open failed [Error code %d]\n", errCode);
|
||||
int16_t mmWaveError;
|
||||
int16_t subSysError;
|
||||
MMWave_ErrorLevel errorLevel;
|
||||
MMWave_decodeError(errCode, &errorLevel, &mmWaveError, &subSysError);
|
||||
System_printf ("Error Level: %s mmWave: %d Subsys: %d\n",
|
||||
(errorLevel == MMWave_ErrorLevel_ERROR) ? "Error" : "Warning",
|
||||
mmWaveError, subSysError);
|
||||
return;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Minimal Mode: We can now call the mmWave Link API to perform the
|
||||
* profile/chirp/frame configuration. This is just an illustration
|
||||
************************************************************************/
|
||||
if (Mmwave_testLinkAPI () < 0){
|
||||
System_printf("Error: Link Api failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (MonitoringEnable() != 0){
|
||||
System_printf("Error: temperature monitoring failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (GPADCMonitoringEnable() != 0){
|
||||
System_printf("Error: Gpadc monitoring failed\n");
|
||||
return;
|
||||
}*/
|
||||
/* Populate the calibration configuration: */
|
||||
calibrationCfg.dfeDataOutputMode = MMWave_DFEDataOutputMode_FRAME;
|
||||
calibrationCfg.u.chirpCalibrationCfg.enableCalibration = true;
|
||||
calibrationCfg.u.chirpCalibrationCfg.enablePeriodicity = true;
|
||||
calibrationCfg.u.chirpCalibrationCfg.periodicTimeInFrames = 10U;
|
||||
|
||||
/************************************************************************
|
||||
* Start the mmWave:
|
||||
************************************************************************/
|
||||
if (MMWave_start (gMMWaveHandle, &calibrationCfg, &errCode) < 0)
|
||||
{
|
||||
/* Error: Unable to configure the mmWave control module */
|
||||
System_printf ("Error: mmWave start failed [Error code %d]\n", errCode);
|
||||
return;
|
||||
}
|
||||
/**************************************************************************
|
||||
************************** Extern Definitions ****************************
|
||||
**************************************************************************/
|
||||
return;
|
||||
}
|
||||
int32_t MmwDemo_mssMmwaveEventCallbackFxn(uint16_t msgId, uint16_t sbId, uint16_t sbLen, uint8_t *payload){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void InitTask(UArg arg0, UArg arg1)
|
||||
{
|
||||
Task_Params taskParamsUART;
|
||||
Task_Params taskParams;
|
||||
int32_t errCode;
|
||||
Mailbox_Config cfg;
|
||||
|
||||
CLI_Cfg cliCfg;
|
||||
|
||||
/* Initialize the UART */
|
||||
UART_init();
|
||||
|
||||
Mailbox_init(MAILBOX_TYPE_MSS);
|
||||
|
||||
if(Mailbox_Config_init(&cfg) < 0)
|
||||
{
|
||||
System_printf ("Error: Mailbox init failed\n");
|
||||
@@ -279,34 +430,58 @@ static void InitTask(UArg arg0, UArg arg1)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Initialize the UART */
|
||||
UART_init();
|
||||
|
||||
/* Test the GPIO Output: Configure pin K13 as GPIO_2 output */
|
||||
|
||||
/* Setup the PINMUX to bring out the MSS UART-1 */
|
||||
Pinmux_Set_FuncSel(SOC_XWR16XX_PINN5_PADBE, SOC_XWR16XX_PINN5_PADBE_MSS_UARTA_TX);
|
||||
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN5_PADBE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
|
||||
Pinmux_Set_FuncSel(SOC_XWR16XX_PINN4_PADBD, SOC_XWR16XX_PINN4_PADBD_MSS_UARTA_RX);
|
||||
Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN4_PADBD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
|
||||
|
||||
/* Initialize the Task Parameters. */
|
||||
Task_Params_init(&taskParamsUART);
|
||||
taskParamsUART.stackSize = 4*1024;
|
||||
taskParamsUART.priority = 3;
|
||||
Task_create(Work_UART, &taskParamsUART, NULL);
|
||||
Work_UART(0,0);
|
||||
|
||||
/* Initialize the CLI configuration: */
|
||||
memset ((void *)&cliCfg, 0, sizeof(CLI_Cfg));
|
||||
|
||||
init_mmWave();
|
||||
|
||||
cliCfg.cliPrompt = "mmwDemo:/>";
|
||||
cliCfg.cliUartHandle = handle;
|
||||
cliCfg.taskPriority = 3;
|
||||
cliCfg.socHandle = socHandle;
|
||||
cliCfg.mmWaveHandle = gMMWaveHandle;
|
||||
cliCfg.enableMMWaveExtension = 0U;
|
||||
cliCfg.usePolledMode = true;
|
||||
|
||||
cliCfg.tableEntry[0].cmd = "set";
|
||||
cliCfg.tableEntry[0].helpString = "Set val and ID to buffer";
|
||||
cliCfg.tableEntry[0].cmdHandlerFxn = SetVal;
|
||||
|
||||
cliCfg.tableEntry[1].cmd = "get";
|
||||
cliCfg.tableEntry[1].helpString = "Get ID from buffer";
|
||||
cliCfg.tableEntry[1].cmdHandlerFxn = Get;
|
||||
|
||||
// Open the CLI:
|
||||
|
||||
errCode = CLI_open (&cliCfg);
|
||||
if (errCode < 0)
|
||||
{
|
||||
System_printf ("Error: Unable to open the CLI: %d\n", errCode);
|
||||
return;
|
||||
}
|
||||
System_printf ("Debug: CLI is operational\n");
|
||||
|
||||
/* Initialize the Task Parameters Mailbox. */
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.priority = 2;
|
||||
taskParams.stackSize = 3 * 1024;
|
||||
taskParams.stackSize = 1 * 1024;
|
||||
Task_create(mBox, &taskParams, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
|
||||
int32_t errCode;
|
||||
Task_Params taskParams;
|
||||
SOC_Cfg socCfg;
|
||||
@@ -337,7 +512,8 @@ int main (void)
|
||||
|
||||
/* Initialize the Task Parameters. */
|
||||
Task_Params_init(&taskParams);
|
||||
taskParams.stackSize = 2*1024;
|
||||
taskParams.priority = 3;
|
||||
taskParams.stackSize = 5*1024;
|
||||
Task_create(InitTask, &taskParams, NULL);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user