This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
毫米波 SDK 提供在此路径上可用的 SPI 测试应用 \packages/ti\drivers\spi\test
它提供了通过 SPI 将 AWR1843与 MSP43x 连接的用例、其中任何一个器件都可以在主模式或从模式下工作。
请参考此测试应用进行开发。
此致、
Jitendra
我已经引用了 SPI 测试应用、因此我已经完成了配置 SPI 通信的步骤、但我仍然没有从 STM32wb55获取任何值。
我遵循了您在此处描述的步骤:
我认为问题来自 SPI_params,这就是为什么我要问您 ,哪些 SPI 参数配置(适用于 AWR1843)可以与上图中所示的 stm32wb55配置配合使用?
您将在下面找到我为将 SPI 添加到 AWR1843而对演示代码所做的修改:
/************************************************************************** *************************** 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/family/arm/v7a/Pmu.h> #include <ti/sysbios/family/arm/v7r/vim/Hwi.h> /* mmWave SDK Include Files: */ #include <ti/common/sys_common.h> #include <ti/drivers/soc/soc.h> #include <ti/drivers/esm/esm.h> #include <ti/drivers/crc/crc.h> #include <ti/drivers/uart/UART.h> #include <ti/drivers/spi/SPI.h> #include <ti/drivers/gpio/gpio.h> #include <ti/drivers/mailbox/mailbox.h> #include <ti/control/mmwave/mmwave.h> #include <ti/utils/cli/cli.h> #include <ti/drivers/osal/DebugP.h> #include <ti/drivers/osal/HwiP.h> #include <ti/utils/hsiheader/hsiheader.h> /* Demo Include Files */ #include "mss_mmw.h" #include "./common/mmw_messages.h" /************************************************************************** *************************** Local Definitions **************************** **************************************************************************/ /************************************************************************** *************************** Global Definitions *************************** **************************************************************************/ /* System DMA handle, created in init Task */ DMA_Handle gDmaHandle= NULL ;//gDmaHandle ; /** * @brief * Global Variable for tracking information required by the mmw Demo */ MmwDemo_MCB gMmwMssMCB; /************************************************************************** *************************** Extern Definitions ******************************* **************************************************************************/ /* CLI Init function */ extern void MmwDemo_CLIInit (void); /************************************************************************** ************************* Millimeter Wave Demo Functions Prototype************** **************************************************************************/ /* Data path functions */ int32_t MmwDemo_mssDataPathConfig(void); int32_t MmwDemo_mssDataPathStart(void); int32_t MmwDemo_mssDataPathStop(void); /* mmwave library call back fundtions */ void MmwDemo_mssMmwaveConfigCallbackFxn(MMWave_CtrlCfg* ptrCtrlCfg); void MmwDemo_mssMmwaveStartCallbackFxn(MMWave_CalibrationCfg* ptrCalibrationCfg); static void MmwDemo_mssMmwaveOpenCallbackFxn(MMWave_OpenCfg* ptrOpenCfg); static void MmwDemo_mssMmwaveCloseCallbackFxn(void); void MmwDemo_mssMmwaveStopcallbackFxn(void); int32_t MmwDemo_mssMmwaveEventCallbackFxn(uint16_t msgId, uint16_t sbId, uint16_t sbLen, uint8_t *payload); /* MMW demo Task */ void MmwDemo_mssInitTask(UArg arg0, UArg arg1); void MmwDemo_mmWaveCtrlTask(UArg arg0, UArg arg1); void MmwDemo_mssCtrlPathTask(UArg arg0, UArg arg1); void MmwDemo_gpioSwitchTask(UArg arg0, UArg arg1); /* external sleep function when in idle (used in .cfg file) */ void MmwDemo_sleep(void); /* DSS to MSS exception signalling ISR */ static void MmwDemo_installDss2MssExceptionSignallingISR(void); /************************************************************************** ************************* Millimeter Wave Demo Functions ********************** **************************************************************************/ /** * @b Description * @n * Registered event function which is invoked when an event from the * BSS is received. * * @param[in] msgId * Message Identifier * @param[in] sbId * Subblock identifier * @param[in] sbLen * Length of the subblock * @param[in] payload * Pointer to the payload buffer * * @retval * Always returns 0 [Continue passing the event to the peer domain] */ int32_t MmwDemo_mssMmwaveEventCallbackFxn(uint16_t msgId, uint16_t sbId, uint16_t sbLen, uint8_t *payload) { uint16_t asyncSB = RL_GET_SBID_FROM_UNIQ_SBID(sbId); #if 0 System_printf ("Debug: BSS Event MsgId: %d [Sub Block Id: %d Sub Block Length: %d]\n", msgId, sbId, sbLen); #endif /* Process the received message: */ switch (msgId) { case RL_RF_ASYNC_EVENT_MSG: { /* Received Asychronous Message: */ switch (asyncSB) { case RL_RF_AE_CPUFAULT_SB: { /* Post event to datapath task notify BSS events */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_BSS_CPUFAULT_EVT); break; } case RL_RF_AE_ESMFAULT_SB: { /* Post event to datapath task notify BSS events */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_BSS_ESMFAULT_EVT); break; } case RL_RF_AE_ANALOG_FAULT_SB: { /* Post event to datapath task notify BSS events */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_BSS_ANALOGFAULT_EVT); break; } case RL_RF_AE_INITCALIBSTATUS_SB: { rlRfInitComplete_t* ptrRFInitCompleteMessage; uint32_t calibrationStatus; /* Get the RF-Init completion message: */ ptrRFInitCompleteMessage = (rlRfInitComplete_t*)payload; calibrationStatus = ptrRFInitCompleteMessage->calibStatus & 0xFFFU; /* Display the calibration status: */ CLI_write ("Debug: Init Calibration Status = 0x%x\n", calibrationStatus); break; } case RL_RF_AE_FRAME_TRIGGER_RDY_SB: { /* This event is not handled on MSS */ break; } case RL_RF_AE_MON_TIMING_FAIL_REPORT_SB: { /* Increment the statistics for the number of failed reports */ gMmwMssMCB.stats.numFailedTimingReports++; #if 0 /* if something needs to be done then need to implement the function to handle the event below in MmwDemo_mssCtrlPathTask()*/ /* Post event to datapath task notify BSS events */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_BSS_MONITORING_REP_EVT); #endif break; } case RL_RF_AE_RUN_TIME_CALIB_REPORT_SB: { /* Increment the statistics for the number of received calibration reports */ gMmwMssMCB.stats.numCalibrationReports++; #if 0 /* if something needs to be done then need to implement the function to handle the event below in MmwDemo_mssCtrlPathTask()*/ /* Post event to datapath task notify BSS events */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_BSS_CALIBRATION_REP_EVT); #endif break; } case RL_RF_AE_FRAME_END_SB: { /*Received Frame Stop async event from BSS. No further action required on MSS as it will wait for a message from DSS when it is done (MMWDEMO_DSS2MSS_STOPDONE)*/ break; } default: { System_printf ("Error: Asynchronous Event SB Id %d not handled\n", asyncSB); break; } } break; } default: { System_printf ("Error: Asynchronous message %d is NOT handled\n", msgId); break; } } return 0; } /** * @b Description * @n * Application registered callback function which is invoked after the configuration * has been used to configure the mmWave link and the BSS. This is applicable only for * the XWR16xx. The BSS can be configured only by the MSS *or* DSS. The callback API is * triggered on the remote execution domain (which did not configure the BSS) * * @param[in] ptrCtrlCfg * Pointer to the control configuration * * @retval * Not applicable */ void MmwDemo_mssMmwaveConfigCallbackFxn(MMWave_CtrlCfg* ptrCtrlCfg) { /* For mmw Demo, mmwave_config() will always be called from MSS, due to the fact CLI is running on MSS, hence this callback won't be called */ gMmwMssMCB.stats.datapathConfigEvt ++; } /** * @b Description * @n * Application registered callback function which is invoked the mmWave link on BSS * has been opened. * * @param[in] ptrOpenCfg * Pointer to the open configuration * * @retval * Not applicable */ static void MmwDemo_mssMmwaveOpenCallbackFxn(MMWave_OpenCfg* ptrOpenCfg) { return; } /** * @b Description * @n * Application registered callback function which is invoked the mmWave link on BSS * has been closed. * * @retval * Not applicable */ static void MmwDemo_mssMmwaveCloseCallbackFxn(void) { return; } /** * @b Description * @n * Application registered callback function which is invoked the mmWave link on BSS * has been started. This is applicable only for the XWR16xx. The BSS can be configured * only by the MSS *or* DSS. The callback API is triggered on the remote execution * domain (which did not configure the BSS) * * @param[in] ptrCalibrationCfg * Pointer to the calibration configuration * * @retval * Not applicable */ void MmwDemo_mssMmwaveStartCallbackFxn(MMWave_CalibrationCfg* ptrCalibrationCfg) { /* Post an event to main data path task. This function in only called when mmwave_start() is called on DSS */ gMmwMssMCB.stats.datapathStartEvt ++; /* Post event to start is done */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_START_COMPLETED_EVT); } /** * @b Description * @n * Application registered callback function which is invoked the mmWave link on BSS * has been stopped. This is applicable only for the XWR16xx. The BSS can be configured * only by the MSS *or* DSS. The callback API is triggered on the remote execution * domain (which did not configure the BSS) * * @retval * Not applicable */ void MmwDemo_mssMmwaveStopCallbackFxn(void) { /* Possible sceanarios: 1. CLI sensorStop command triggers mmwave_stop() to be called from MSS 2. In case of Error, mmwave_stop() will be triggered either from MSS or DSS */ gMmwMssMCB.stats.datapathStopEvt ++; } /** * @b Description * @n * Function to send a message to peer through Mailbox virtural channel * * @param[in] message * Pointer to the MMW demo message. * * @retval * Success - 0 * Fail < -1 */ int32_t MmwDemo_mboxWrite(MmwDemo_message * message) { int32_t retVal = -1; retVal = Mailbox_write (gMmwMssMCB.peerMailbox, (uint8_t*)message, sizeof(MmwDemo_message)); if (retVal == sizeof(MmwDemo_message)) { retVal = 0; } return retVal; } /** * @b Description * @n * The Task is used to handle the mmw demo messages received from * Mailbox virtual channel. * * @param[in] arg0 * arg0 of the Task. Not used * @param[in] arg1 * arg1 of the Task. Not used * * @retval * Not Applicable. */ static void MmwDemo_mboxReadTask(UArg arg0, UArg arg1) { MmwDemo_message message; int32_t retVal = 0; uint32_t totalPacketLen; uint32_t numPaddingBytes; uint32_t itemIdx; bool ret ; SPI_Transaction transaction; uint8_t txBuf[] = "****SPI - Two Boards communication based on Polling **** SPI Message ******** SPI Message ******** SPI Message ****"; uint8_t rxBuf[sizeof(txBuf)]; /* Configure Data Transfer */ transaction.count = sizeof(txBuf); //(uint16_t)1U; transaction.txBuf = (uint8_t*)txBuf; transaction.rxBuf = (uint8_t *)rxBuf; transaction.slaveIndex = (uint16_t)0U; /* Start Data Transfer */ ret = SPI_transfer(gMmwMssMCB.loggingSpiHandle, &transaction); if (ret != true) { System_printf("Debug: SPI_transfer with data size = %d failed with error=%d.\n", transaction.count, transaction.status ); } /* wait for new message and process all the messages received from the peer */ while(1) { Semaphore_pend(gMmwMssMCB.mboxSemHandle, BIOS_WAIT_FOREVER); /* Read the message from the peer mailbox: We are not trying to protect the read * from the peer mailbox because this is only being invoked from a single thread */ retVal = Mailbox_read(gMmwMssMCB.peerMailbox, (uint8_t*)&message, sizeof(MmwDemo_message)); if (retVal < 0) { /* Error: Unable to read the message. Setup the error code and return values */ System_printf ("Error: Mailbox read failed [Error code %d]\n", retVal); } else if (retVal == 0) { /* We are done: There are no messages available from the peer execution domain. */ continue; } else { /* Flush out the contents of the mailbox to indicate that we are done with the message. This will * allow us to receive another message in the mailbox while we process the received message. */ Mailbox_readFlush (gMmwMssMCB.peerMailbox); /* Process the received message: */ switch (message.type) { case MMWDEMO_DSS2MSS_DETOBJ_READY: /* Got detected objectes , shipped out through UART */ /* Send header */ totalPacketLen = sizeof(MmwDemo_output_message_header); UART_writePolling (gMmwMssMCB.loggingUartHandle, (uint8_t*)&message.body.detObj.header, sizeof(MmwDemo_output_message_header)); /* Send TLVs */ for (itemIdx = 0; itemIdx < message.body.detObj.header.numTLVs; itemIdx++) { UART_writePolling (gMmwMssMCB.loggingUartHandle, (uint8_t*)&message.body.detObj.tlv[itemIdx], sizeof(MmwDemo_output_message_tl)); UART_writePolling (gMmwMssMCB.loggingUartHandle, (uint8_t*)SOC_translateAddress(message.body.detObj.tlv[itemIdx].address, SOC_TranslateAddr_Dir_FROM_OTHER_CPU,NULL), message.body.detObj.tlv[itemIdx].length); totalPacketLen += sizeof(MmwDemo_output_message_tl) + message.body.detObj.tlv[itemIdx].length; } /* Send padding to make total packet length multiple of MMWDEMO_OUTPUT_MSG_SEGMENT_LEN */ numPaddingBytes = MMWDEMO_OUTPUT_MSG_SEGMENT_LEN - (totalPacketLen & (MMWDEMO_OUTPUT_MSG_SEGMENT_LEN-1)); if (numPaddingBytes<MMWDEMO_OUTPUT_MSG_SEGMENT_LEN) { uint8_t padding[MMWDEMO_OUTPUT_MSG_SEGMENT_LEN]; /*DEBUG:*/ memset(&padding, 0xf, MMWDEMO_OUTPUT_MSG_SEGMENT_LEN); UART_writePolling (gMmwMssMCB.loggingUartHandle, padding, numPaddingBytes); } /* Send a message to MSS to log the output data */ memset((void *)&message, 0, sizeof(MmwDemo_message)); message.type = MMWDEMO_MSS2DSS_DETOBJ_SHIPPED; if (MmwDemo_mboxWrite(&message) != 0) { System_printf ("Error: Mailbox send message id=%d failed \n", message.type); } break; case MMWDEMO_DSS2MSS_STOPDONE: /* Post event that stop is done */ gMmwMssMCB.stats.dssSensorStop++; Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_STOP_COMPLETED_EVT); break; case MMWDEMO_DSS2MSS_ASSERT_INFO: /* Send the received DSS assert info through CLI */ CLI_write ("DSS Exception: %s, line %d.\n", message.body.assertInfo.file, message.body.assertInfo.line); break; case MMWDEMO_DSS2MSS_ISR_INFO_ADDRESS: gMmwMssMCB.dss2mssIsrInfoAddress = SOC_translateAddress(message.body.dss2mssISRinfoAddress, SOC_TranslateAddr_Dir_FROM_OTHER_CPU, NULL); MmwDemo_installDss2MssExceptionSignallingISR(); break; default: { /* Message not support */ System_printf ("Error: unsupport Mailbox message id=%d\n", message.type); break; } } } } } /** * @b Description * @n * This function is a callback funciton that invoked when a message is received from the peer. * * @param[in] handle * Handle to the Mailbox on which data was received * @param[in] peer * Peer from which data was received * @retval * Not Applicable. */ void MmwDemo_mboxCallback ( Mbox_Handle handle, Mailbox_Type peer ) { /* Message has been received from the peer endpoint. Wakeup the mmWave thread to process * the received message. */ Semaphore_post (gMmwMssMCB.mboxSemHandle); } #if 0 //OD DEMO: Remove unused functions /** * @b Description * @n * Function that configures the BPM chirps based on the stored BPM CLI commands. * The MMW demo supports only a fixed BPM scheme and this scheme is implemented * by this function. * * @retval * 0 - Success. * <0 - Failed with errors */ int32_t MmwDemo_bpmConfig(void) {s uint8_t subframe; uint8_t numberOfSubframes = 1; int32_t errCode; rlBpmChirpCfg_t bpmChirpCfg; MMWave_BpmChirpHandle bpmChirpHandle; if(gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode == MMWave_DFEDataOutputMode_ADVANCED_FRAME) { /* BPM configuration for all valid subframes */ numberOfSubframes = gMmwMssMCB.cfg.ctrlCfg.u.advancedFrameCfg.frameCfg.frameSeq.numOfSubFrames; } for(subframe = 0; subframe < numberOfSubframes; subframe++) { /* Is BPM enabled*/ if(gMmwMssMCB.cliCfg[subframe].bpmCfg.isEnabled) { /*configure chirp 0 (++)*/ memset ((void *)&bpmChirpCfg, 0, sizeof(rlBpmChirpCfg_t)); bpmChirpCfg.chirpStartIdx = gMmwMssMCB.cliCfg[subframe].bpmCfg.chirp0Idx; bpmChirpCfg.chirpEndIdx = gMmwMssMCB.cliCfg[subframe].bpmCfg.chirp0Idx; /* Phase configuration: TX0 positive, TX1 positive*/ bpmChirpCfg.constBpmVal = 0U; bpmChirpHandle = MMWave_addBpmChirp (gMmwMssMCB.ctrlHandle, &bpmChirpCfg, &errCode); if (bpmChirpHandle == NULL) { System_printf ("Error: Unable to add BPM cfg chirp 0. Subframe %d [Error code %d]\n",subframe, errCode); return -1; } /*configure chirp 1 (++)*/ memset ((void *)&bpmChirpCfg, 0, sizeof(rlBpmChirpCfg_t)); bpmChirpCfg.chirpStartIdx = gMmwMssMCB.cliCfg[subframe].bpmCfg.chirp1Idx; bpmChirpCfg.chirpEndIdx = gMmwMssMCB.cliCfg[subframe].bpmCfg.chirp1Idx; /* Phase configuration: TX0 positive, TX1 negative*/ bpmChirpCfg.constBpmVal = 0xCU; bpmChirpHandle = MMWave_addBpmChirp (gMmwMssMCB.ctrlHandle, &bpmChirpCfg, &errCode); if (bpmChirpHandle == NULL) { System_printf ("Error: Unable to add BPM cfg chirp 1. Subframe %d [Error code %d]\n",subframe, errCode); return -1; } } else { /*BPM is disabled. Configure the range of chirps [chirp0Idx..chirp1Idx] all to have zero phase.*/ memset ((void *)&bpmChirpCfg, 0, sizeof(rlBpmChirpCfg_t)); bpmChirpCfg.chirpStartIdx = gMmwMssMCB.cliCfg[subframe].bpmCfg.chirp0Idx; bpmChirpCfg.chirpEndIdx = gMmwMssMCB.cliCfg[subframe].bpmCfg.chirp1Idx; /* Phase configuration: TX0 positive, TX1 positive*/ bpmChirpCfg.constBpmVal = 0U; bpmChirpHandle = MMWave_addBpmChirp (gMmwMssMCB.ctrlHandle, &bpmChirpCfg, &errCode); if (bpmChirpHandle == NULL) { System_printf ("Error: Unable to add BPM cfg for BPM disabled. Subframe %d [Error code %d]\n",subframe, errCode); return -1; } } } return 0; } #endif /** * @b Description * @n * Function to Setup the HSI Clock. Required for LVDS streaming. * * @retval * 0 - Success. * <0 - Failed with errors */ int32_t MmwDemo_mssSetHsiClk(void) { rlDevHsiClk_t hsiClkgs; int32_t retVal; /************************************************************************************* * Setup the HSI Clock through the mmWave Link: *************************************************************************************/ memset ((void*)&hsiClkgs, 0, sizeof(rlDevHsiClk_t)); /* Setup the HSI Clock as per the Radar Interface Document: * - This is set to 600Mhz DDR Mode */ hsiClkgs.hsiClk = 0x9; /* Setup the HSI in the radar link: */ retVal = rlDeviceSetHsiClk(RL_DEVICE_MAP_CASCADED_1, &hsiClkgs); if (retVal != RL_RET_CODE_OK) { /* Error: Unable to set the HSI clock */ System_printf ("Error: Setting up the HSI Clock Failed [Error %d]\n", retVal); return -1; } /*The delay below is needed only if the DCA1000EVM is being used to capture the data traces. This is needed because the DCA1000EVM FPGA needs the delay to lock to the bit clock before they can start capturing the data correctly. */ Task_sleep(HSI_DCA_MIN_DELAY_MSEC); return 0; } /** * @b Description * @n * Function to do Data Path Configuration on MSS. After received Configuration from * CLI, this function will start the system configuration process, inclucing mmwaveLink, BSS * and DSS. * * @retval * 0 - Success. * <0 - Failed with errors */ int32_t MmwDemo_mssDataPathConfig(void) { int32_t errCode; /* Has the mmWave module been opened? */ if (gMmwMssMCB.isMMWaveOpen == false) { /* Get the open configuration from the CLI mmWave Extension */ CLI_getMMWaveExtensionOpenConfig (&gMmwMssMCB.cfg.openCfg); /* NO: Setup the calibration frequency: */ gMmwMssMCB.cfg.openCfg.freqLimitLow = 760U; gMmwMssMCB.cfg.openCfg.freqLimitHigh = 810U; /* Disable the frame start async event so that small chirp times are supported. If this event is enabled it will break real-time for small chirp times and cause 1D processing to crash due to lack of MIPS*/ gMmwMssMCB.cfg.openCfg.disableFrameStartAsyncEvent = true; /* Enable frame stop async event so that we know when BSS has stopped*/ gMmwMssMCB.cfg.openCfg.disableFrameStopAsyncEvent = false; /* Open the mmWave module: */ if (MMWave_open (gMmwMssMCB.ctrlHandle, &gMmwMssMCB.cfg.openCfg, &errCode) < 0) { System_printf ("Error: MMWDemoMSS mmWave open configuration failed [Error code %d]\n", errCode); return -1; } /* mmWave module has been opened. */ gMmwMssMCB.isMMWaveOpen = true; /*Set up HSI clock*/ if(MmwDemo_mssSetHsiClk() < 0) { System_printf ("Error: MmwDemo_mssSetHsiClk failed.\n"); return -1; } } else { /* openCfg related configurations like chCfg, lowPowerMode, adcCfg * are only used on the first sensor start. If they are different * on a subsequent sensor start, then generate a fatal error * so the user does not think that the new (changed) configuration * takes effect, the board needs to be reboot for the new * configuration to be applied. */ MMWave_OpenCfg openCfg; CLI_getMMWaveExtensionOpenConfig (&openCfg); /* Initialize to same as in "if" part where open is done * to allow memory compare of structures to be used. * Note that even if structures may have holes, the memory * compare is o.k because CLI always stores the configurations * in the same global CLI structure which is copied over to the * one supplied by the application through the * CLI_getMMWaveExtensionOpenConfig API. Not using memcmp will * require individual field comparisons which is probably * more code size and ***. */ openCfg.freqLimitLow = 760U; openCfg.freqLimitHigh = 810U; openCfg.disableFrameStartAsyncEvent = true; openCfg.disableFrameStopAsyncEvent = false; /* Compare openCfg */ if(memcmp((void *)&gMmwMssMCB.cfg.openCfg, (void *)&openCfg, sizeof(MMWave_OpenCfg)) != 0) { /* Post event to CLI task that start failed so that CLI/GUI can be notified */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_START_FAILED_EVT); MmwDemo_mssAssert(0); } } /* Get the control configuration from the CLI mmWave Extension */ CLI_getMMWaveExtensionConfig (&gMmwMssMCB.cfg.ctrlCfg); #if 0 //OD DEMO: Remove unused messages /* Prepare BPM configuration */ if(MmwDemo_bpmConfig() < 0) { System_printf ("Error: MMWDemoMSS mmWave BPM Configuration failed\n"); return -1; } #endif /* Configure the mmWave module: */ if (MMWave_config (gMmwMssMCB.ctrlHandle, &gMmwMssMCB.cfg.ctrlCfg, &errCode) < 0) { System_printf ("Error: MMWDemoMSS mmWave Configuration failed [Error code %d]\n", errCode); return -1; } return 0; } /** * @b Description * @n * Function to do Data Path Start on MSS. After received SensorStart command, MSS will * start all data path componets including mmwaveLink, BSS and DSS. * * @retval * 0 - Success. * <0 - Failed with errors */ int32_t MmwDemo_mssDataPathStart(void) { int32_t errCode; MMWave_CalibrationCfg calibrationCfg; /* Initialize the calibration configuration: */ memset ((void*)&calibrationCfg, 0, sizeof(MMWave_CalibrationCfg)); /* Populate the calibration configuration: */ calibrationCfg.dfeDataOutputMode = gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode; calibrationCfg.u.chirpCalibrationCfg.enableCalibration = true; calibrationCfg.u.chirpCalibrationCfg.enablePeriodicity = true; calibrationCfg.u.chirpCalibrationCfg.periodicTimeInFrames = 10U; /* Start the mmWave module: The configuration has been applied successfully. */ if (MMWave_start (gMmwMssMCB.ctrlHandle, &calibrationCfg, &errCode) < 0) { /* Error: Unable to start the mmWave control */ System_printf ("Error: MMWDemoMSS mmWave Start failed [Error code %d]\n", errCode); return -1; } System_printf ("Debug: MMWDemoMSS mmWave Start succeeded \n"); return 0; } /** * @b Description * @n * Function to do Data Path Start on MSS. After received SensorStart command, MSS will * start all data path componets including mmwaveLink, BSS and DSS. * * @retval * 0 - Success. * <0 - Failed with errors */ int32_t MmwDemo_mssDataPathStop(void) { int32_t errCode; MMWave_ErrorLevel errorLevel; int16_t mmWaveErrorCode; int16_t subsysErrorCode; int32_t retVal = 0; /* Start the mmWave module: The configuration has been applied successfully. */ if (MMWave_stop (gMmwMssMCB.ctrlHandle, &errCode) < 0) { /* Error/Warning: Unable to stop the mmWave module */ MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode); if (errorLevel == MMWave_ErrorLevel_ERROR) { /* Error: Set the return value to indicate error: */ System_printf ("Error: MMWDemoMSS mmWave Stop failed [mmWave Error: %d Subsys: %d]\n", mmWaveErrorCode, subsysErrorCode); retVal = -1; } else { System_printf ("Warning: MMWDemoMSS mmWave Stop failed [mmWave Error: %d Subsys: %d]\n", mmWaveErrorCode, subsysErrorCode); /* Warning: This is treated as a successful stop. */ } } return retVal; } /** * @b Description * @n * The task is used to provide an execution context for the mmWave * control task * * @retval * Not Applicable. */ void MmwDemo_mmWaveCtrlTask(UArg arg0, UArg arg1) { int32_t errCode; while (1) { /* Execute the mmWave control module: */ if (MMWave_execute (gMmwMssMCB.ctrlHandle, &errCode) < 0) System_printf ("Error: mmWave control execution failed [Error code %d]\n", errCode); } } /** * @b Description * @n * This is a utility function which can be invoked from the CLI or * the Switch press to start the sensor. This sends an event to the * sensor management task where the actual *start* procedure is * implemented. * * @retval * Not applicable */ void MmwDemo_notifySensorStart(bool doReconfig) { gMmwMssMCB.stats.cliSensorStartEvt ++; if (doReconfig) { /* Post sensorStart event to start reconfig and then start the sensor */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_CLI_SENSORSTART_EVT); } else { /* Post frameStart event to skip reconfig and just start the sensor */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_CLI_FRAMESTART_EVT); } } /** * @b Description * @n * This is a utility function which can be invoked from the CLI or * the Switch press to start the sensor. This sends an event to the * sensor management task where the actual *start* procedure is * implemented. * * @retval * Not applicable */ void MmwDemo_notifySensorStop(void) { gMmwMssMCB.stats.cliSensorStopEvt ++; /* Post sensorSTOP event to notify sensor stop command */ Event_post(gMmwMssMCB.eventHandle, MMWDEMO_CLI_SENSORSTOP_EVT); } /** * @b Description * @n * This is a utility function which can be used by the CLI to * pend for start complete (after MmwDemo_notifySensorStart is called) * * @retval * Not applicable */ int32_t MmwDemo_waitSensorStartComplete(void) { UInt event; int32_t retVal; /* Pend on the START NOTIFY event */ event = Event_pend(gMmwMssMCB.eventHandleNotify, Event_Id_NONE, MMWDEMO_DSS_START_COMPLETED_EVT | MMWDEMO_DSS_START_FAILED_EVT, BIOS_WAIT_FOREVER); /************************************************************************ * DSS event:: START notification ************************************************************************/ if(event & MMWDEMO_DSS_START_COMPLETED_EVT) { /* Sensor has been started successfully */ gMmwMssMCB.isSensorStarted = true; /* Turn on the LED */ GPIO_write (SOC_XWR16XX_GPIO_2, 1U); retVal = 0; } else if(event & MMWDEMO_DSS_START_FAILED_EVT) { /* Sensor start failed */ gMmwMssMCB.isSensorStarted = false; retVal = -1; } else { /* we should block forever till we get the events. If the desired event didnt happen, then throw an assert */ retVal = -1; MmwDemo_mssAssert(0); } return retVal; } /** * @b Description * @n * This is a utility function which can be used by the CLI to * pend for stop complete (after MmwDemo_notifySensorStart is called) * * @retval * Not applicable */ void MmwDemo_waitSensorStopComplete(void) { UInt event; /* Pend on the START NOTIFY event */ event = Event_pend(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_STOP_COMPLETED_EVT | MMWDEMO_MSS_STOP_COMPLETED_EVT, /* andMask */ Event_Id_NONE, /* orMask */ BIOS_WAIT_FOREVER); /************************************************************************ * DSS event:: STOP notification ************************************************************************/ if(event & (MMWDEMO_DSS_STOP_COMPLETED_EVT | MMWDEMO_MSS_STOP_COMPLETED_EVT)) { /* Sensor has been stopped successfully */ gMmwMssMCB.isSensorStarted = false; /* Turn off the LED */ GPIO_write (SOC_XWR16XX_GPIO_2, 0U); /* print for user */ System_printf("Sensor has been stopped\n"); } else { /* we should block forever till we get the event. If the desired event didnt happen, then throw an assert */ MmwDemo_mssAssert(0); } } /** * @b Description * @n * Callback function invoked when the GPIO switch is pressed. * This is invoked from interrupt context. * * @param[in] index * GPIO index configured as input * * @retval * Not applicable */ static void MmwDemo_switchPressFxn(unsigned int index) { /* Post semaphore to process GPIO switch event */ Semaphore_post (gMmwMssMCB.gpioSemHandle); } /** * @b Description * @n * The task is used to process data path events * control task * * @retval * Not Applicable. */ void MmwDemo_mssCtrlPathTask(UArg arg0, UArg arg1) { UInt event; /********************************************************************** * Setup the PINMUX: * - GPIO Input : Configure pin J13 as GPIO_1 input * - GPIO Output: Configure pin K13 as GPIO_2 output **********************************************************************/ Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINJ13_PADAC, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINJ13_PADAC, SOC_XWR16XX_PINJ13_PADAC_GPIO_1); Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINK13_PADAZ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINK13_PADAZ, SOC_XWR16XX_PINK13_PADAZ_GPIO_2); /********************************************************************** * Setup the SW1 switch on the EVM connected to GPIO_1 * - This is used as an input * - Enable interrupt to be notified on a switch press **********************************************************************/ GPIO_setConfig (SOC_XWR16XX_GPIO_1, GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING | GPIO_CFG_IN_INT_LOW); GPIO_setCallback (SOC_XWR16XX_GPIO_1, MmwDemo_switchPressFxn); GPIO_enableInt (SOC_XWR16XX_GPIO_1); /********************************************************************** * Setup the DS3 LED on the EVM connected to GPIO_2 **********************************************************************/ GPIO_setConfig (SOC_XWR16XX_GPIO_2, GPIO_CFG_OUTPUT); /* Data Path management task Main loop */ while (1) { event = Event_pend(gMmwMssMCB.eventHandle, Event_Id_NONE, MMWDEMO_CLI_EVENTS | MMWDEMO_BSS_FAULT_EVENTS | MMWDEMO_DSS_EXCEPTION_EVENTS, BIOS_WAIT_FOREVER); /************************************************************************ * CLI event:: SensorStart ************************************************************************/ if(event & MMWDEMO_CLI_SENSORSTART_EVT) { System_printf ("Debug: MMWDemoMSS Received CLI sensorStart Event\n"); /* Setup the data path: */ if(gMmwMssMCB.isSensorStarted==false) { if (MmwDemo_mssDataPathConfig () < 0) { /* Post start failed event; error printing is done in function above */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_START_FAILED_EVT); continue; } else { /* start complete event is posted via DSS */ } } else { /* Post start complete event as this is just a duplicate command */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_START_COMPLETED_EVT); continue; } } /************************************************************************ * CLI event:: SensorStop ************************************************************************/ if(event & MMWDEMO_CLI_SENSORSTOP_EVT) { if(gMmwMssMCB.isSensorStarted==true) { if (MmwDemo_mssDataPathStop () < 0) { /* Do we need stop fail event? */ DebugP_assert(0); } else { /* DSS will post the stop completed event */ } } else { /* Post data path stop complete event on behalf on Datapath in case sensor is already in stop state */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_STOP_COMPLETED_EVT); } /* In all cases send MSS stop complete */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_MSS_STOP_COMPLETED_EVT); } /************************************************************************ * CLI event:: Framestart ************************************************************************/ if(event & MMWDEMO_CLI_FRAMESTART_EVT) { /* error printing happens inside this function */ if(gMmwMssMCB.isSensorStarted==false) { if (MmwDemo_mssDataPathStart () < 0) { /* Post start failed event; error printing is done in function above */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_START_FAILED_EVT); continue; } } /* Post event to start is done */ Event_post(gMmwMssMCB.eventHandleNotify, MMWDEMO_DSS_START_COMPLETED_EVT); } /************************************************************************ * BSS event:: CPU fault ************************************************************************/ if(event & MMWDEMO_BSS_CPUFAULT_EVT) { MmwDemo_mssAssert(0); break; } /************************************************************************ * BSS event:: ESM fault ************************************************************************/ if(event & MMWDEMO_BSS_ESMFAULT_EVT) { MmwDemo_mssAssert(0); break; } /************************************************************************ * BSS event:: Analog fault ************************************************************************/ if (event & MMWDEMO_BSS_ANALOGFAULT_EVT) { MmwDemo_mssAssert(0); break; } if(event & MMWDEMO_DSS_CHIRP_PROC_DEADLINE_MISS_EVT) { CLI_write ("DSS Chirp Processing Deadline Miss Exception.\n"); DebugP_assert(0); break; } if(event & MMWDEMO_DSS_FRAME_PROC_DEADLINE_MISS_EVT) { CLI_write ("DSS Frame Processing Deadline Miss Exception.\n"); DebugP_assert(0); break; } } System_printf("Debug: MMWDemoDSS Data path exit\n"); } /** * @b Description * @n * The task is used to process events related * to pressing the GPIO switch * * @retval * Not Applicable. */ void MmwDemo_gpioSwitchTask(UArg arg0, UArg arg1) { /* wait for GPIO switch event */ while(1) { Semaphore_pend(gMmwMssMCB.gpioSemHandle, BIOS_WAIT_FOREVER); /* Was the sensor started? */ if (gMmwMssMCB.isSensorStarted == true) { /* YES: We need to stop the sensor now */ MmwDemo_notifySensorStop(); /* Pend for completion */ MmwDemo_waitSensorStopComplete(); } else { /* NO: We need to start the sensor now. */ MmwDemo_notifySensorStart(true); /* Pend for completion */ if(MmwDemo_waitSensorStartComplete() == -1) { /* Sensor start failed */ MmwDemo_mssAssert(0); } } } } /** * @b Description * @n * DSS to MSS ISR used for direct signalling of things like urgent exception * events from DSS. Posts deadline miss events to @ref MmwDemo_mssCtrlPathTask. * * @retval * Not Applicable. */ void MmwDemo_Dss2MssISR(uintptr_t arg) { switch(*(uint8_t*)gMmwMssMCB.dss2mssIsrInfoAddress) { case MMWDEMO_DSS2MSS_CHIRP_PROC_DEADLINE_MISS_EXCEPTION: Event_post(gMmwMssMCB.eventHandle, MMWDEMO_DSS_CHIRP_PROC_DEADLINE_MISS_EVT); break; case MMWDEMO_DSS2MSS_FRAME_PROC_DEADLINE_MISS_EXCEPTION: Event_post(gMmwMssMCB.eventHandle, MMWDEMO_DSS_FRAME_PROC_DEADLINE_MISS_EVT); break; default: MmwDemo_mssAssert(0); break; } } /** * @b Description * @n * Installs DSS to MSS Software Interrupt ISR for exception signalling. * * @retval * Not Applicable. */ static void MmwDemo_installDss2MssExceptionSignallingISR(void) { HwiP_Params hwiParams; volatile HwiP_Handle hwiHandle; HwiP_Params_init(&hwiParams); hwiParams.name = "Dss2MssSwISR"; hwiHandle = HwiP_create(MMWDEMO_DSS2MSS_EXCEPTION_SIGNALLING_SW_INT_MSS, MmwDemo_Dss2MssISR, &hwiParams); } /** * @b Description * @n * System Initialization Task which initializes the various * components in the system. * * @retval * Not Applicable. */ void MmwDemo_mssInitTask(UArg arg0, UArg arg1) { int32_t errCode; MMWave_InitCfg initCfg; UART_Params uartParams; SPI_Params spiParams; Task_Params taskParams; Semaphore_Params semParams; Mailbox_Config mboxCfg; Error_Block eb; DMA_Params dmaParams; /* Debug Message: */ System_printf("Debug: MMWDemoMSS Launched the Initialization Task\n"); /***************************************************************************** * Initialize the mmWave SDK components: *****************************************************************************/ /* Pinmux setting */ /* Setup the PINMUX to bring out the UART-1 */ Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN5_PADBE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINN5_PADBE, SOC_XWR16XX_PINN5_PADBE_MSS_UARTA_TX); Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINN4_PADBD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINN4_PADBD, SOC_XWR16XX_PINN4_PADBD_MSS_UARTA_RX); /* Setup the PINMUX to bring out the UART-3 */ Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINF14_PADAJ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINF14_PADAJ, SOC_XWR16XX_PINF14_PADAJ_MSS_UARTB_TX); /* Setup the PINMUX to bring out the DSS UART */ Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINP8_PADBM, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINP8_PADBM, SOC_XWR16XX_PINP8_PADBM_DSS_UART_TX); /* Setup the PINMUX to bring out the SPIA 3-pin Mode */ Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PIND13_PADAD, SOC_XWR16XX_PIND13_PADAD_SPIA_MOSI); Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINE14_PADAE, SOC_XWR16XX_PINE14_PADAE_SPIA_MISO); Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE13_PADAF, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINE13_PADAF, SOC_XWR16XX_PINE13_PADAF_SPIA_CLK); /* Initialize the UART */ UART_init(); /* Initialize the GPIO */ GPIO_init(); /* Initialize the GPIO */ SPI_init(); /* Init SYSDMA params */ DMA_Params_init(&dmaParams); /* Initialize the Mailbox */ Mailbox_init(MAILBOX_TYPE_MSS); /* Enable output control for SPIA 3-pin Mode */ SOC_SPIOutputCtrl(gMmwMssMCB.socHandle, 0U, 1U, &errCode); if(SOC_SPIOutputCtrl(gMmwMssMCB.socHandle, 0U, 1U, &errCode)) { /* Debug Message: */ System_printf ("Debug: SOC_SPIOutputCtrl failed with Error [%d]\n", errCode); return; } /***************************************************************************** * Open & configure the drivers: *****************************************************************************/ /* Open DMA driver instance 0 for SPI test */ gDmaHandle = DMA_open(0, &dmaParams, &errCode); if(gDmaHandle == NULL) { printf("Open DMA driver failed with error=%d\n", errCode); return; } /* Setup the default UART Parameters */ UART_Params_init(&uartParams); uartParams.clockFrequency = gMmwMssMCB.cfg.sysClockFrequency; uartParams.baudRate = gMmwMssMCB.cfg.commandBaudRate; uartParams.isPinMuxDone = 1U; /* Open the UART Instance */ gMmwMssMCB.commandUartHandle = UART_open(0, &uartParams); if (gMmwMssMCB.commandUartHandle == NULL) { System_printf("Error: MMWDemoMSS Unable to open the Command UART Instance\n"); return; } /* Setup the default UART Parameters */ UART_Params_init(&uartParams); uartParams.writeDataMode = UART_DATA_BINARY; uartParams.readDataMode = UART_DATA_BINARY; uartParams.clockFrequency = gMmwMssMCB.cfg.sysClockFrequency; uartParams.baudRate = gMmwMssMCB.cfg.loggingBaudRate; uartParams.isPinMuxDone = 1U; /* Open the Logging UART Instance: */ gMmwMssMCB.loggingUartHandle = UART_open(1, &uartParams); if (gMmwMssMCB.loggingUartHandle == NULL) { System_printf("Error: MMWDemoMSS Unable to open the Logging UART Instance\n"); return; } /* Setup the default SPI Parameters */ SPI_Params_init(&spiParams); spiParams.mode = SPI_MASTER; spiParams.u.masterParams.bitRate = 500000; //5000; spiParams.u.masterParams.numSlaves = 1; spiParams.u.masterParams.slaveProf[0].chipSelect = 0; spiParams.u.masterParams.slaveProf[0].ramBufLen = MIBSPI_RAM_MAX_ELEM/2; //MIBSPI_RAM_MAX_ELEM/2; spiParams.frameFormat = SPI_POL0_PHA0; spiParams.shiftFormat = SPI_MSB_FIRST; spiParams.pinMode = SPI_PINMODE_3PIN; spiParams.dataSize = 8; spiParams.dmaEnable = 1; //(uint8_t)1U; spiParams.dmaHandle = gDmaHandle; spiParams.u.masterParams.slaveProf[0].dmaCfg.txDmaChanNum =1U; spiParams.u.masterParams.slaveProf[0].dmaCfg.rxDmaChanNum =0U; spiParams.u.masterParams.slaveProf[1].chipSelect = 1; spiParams.u.masterParams.slaveProf[1].ramBufLen = MIBSPI_RAM_MAX_ELEM/2; //MIBSPI_RAM_MAX_ELEM/2; spiParams.u.masterParams.slaveProf[1].dmaCfg.txDmaChanNum =3U; spiParams.u.masterParams.slaveProf[1].dmaCfg.rxDmaChanNum =2U; /* Open the Logging SPI Instance */ gMmwMssMCB.loggingSpiHandle = SPI_open(0,&spiParams); if (gMmwMssMCB.loggingSpiHandle == NULL) { System_printf("Error: MMWDemoMSS Unable to open the Logging SPI Instance\n"); return; } /* Create a binary semaphore which is used to handle GPIO switch interrupt. */ Semaphore_Params_init(&semParams); semParams.mode = Semaphore_Mode_BINARY; gMmwMssMCB.gpioSemHandle = Semaphore_create(0, &semParams, NULL); /***************************************************************************** * Creating communication channel between MSS & DSS *****************************************************************************/ /* Create a binary semaphore which is used to handle mailbox interrupt. */ Semaphore_Params_init(&semParams); semParams.mode = Semaphore_Mode_BINARY; gMmwMssMCB.mboxSemHandle = Semaphore_create(0, &semParams, NULL); /* Setup the default mailbox configuration */ Mailbox_Config_init(&mboxCfg); /* Setup the configuration: */ mboxCfg.chType = MAILBOX_CHTYPE_MULTI; mboxCfg.chId = MAILBOX_CH_ID_0; mboxCfg.writeMode = MAILBOX_MODE_BLOCKING; mboxCfg.readMode = MAILBOX_MODE_CALLBACK; mboxCfg.readCallback = &MmwDemo_mboxCallback; /* Initialization of Mailbox Virtual Channel */ gMmwMssMCB.peerMailbox = Mailbox_open(MAILBOX_TYPE_DSS, &mboxCfg, &errCode); if (gMmwMssMCB.peerMailbox == NULL) { /* Error: Unable to open the mailbox */ System_printf("Error: Unable to open the Mailbox to the DSS [Error code %d]\n", errCode); return; } /* Create task to handle mailbox messges */ Task_Params_init(&taskParams); taskParams.stackSize = 16*1024; Task_create(MmwDemo_mboxReadTask, &taskParams, NULL); /***************************************************************************** * Create Event to handle mmwave callback and system datapath events *****************************************************************************/ /* Default instance configuration params */ Error_init(&eb); gMmwMssMCB.eventHandle = Event_create(NULL, &eb); if (gMmwMssMCB.eventHandle == NULL) { MmwDemo_mssAssert(0); return ; } Error_init(&eb); gMmwMssMCB.eventHandleNotify = Event_create(NULL, &eb); if (gMmwMssMCB.eventHandleNotify == NULL) { MmwDemo_mssAssert(0); return ; } /***************************************************************************** * mmWave: Initialization of the high level module *****************************************************************************/ /* Initialize the mmWave control init configuration */ memset ((void*)&initCfg, 0 , sizeof(MMWave_InitCfg)); /* Populate the init configuration for mmwave library: */ initCfg.domain = MMWave_Domain_MSS; initCfg.socHandle = gMmwMssMCB.socHandle; initCfg.eventFxn = MmwDemo_mssMmwaveEventCallbackFxn; initCfg.linkCRCCfg.useCRCDriver = 1U; initCfg.linkCRCCfg.crcChannel = CRC_Channel_CH1; initCfg.cfgMode = MMWave_ConfigurationMode_FULL; initCfg.executionMode = MMWave_ExecutionMode_COOPERATIVE; initCfg.cooperativeModeCfg.cfgFxn = MmwDemo_mssMmwaveConfigCallbackFxn; initCfg.cooperativeModeCfg.openFxn = MmwDemo_mssMmwaveOpenCallbackFxn; initCfg.cooperativeModeCfg.closeFxn = MmwDemo_mssMmwaveCloseCallbackFxn; initCfg.cooperativeModeCfg.startFxn = MmwDemo_mssMmwaveStartCallbackFxn; initCfg.cooperativeModeCfg.stopFxn = MmwDemo_mssMmwaveStopCallbackFxn; /* Initialize and setup the mmWave Control module */ gMmwMssMCB.ctrlHandle = MMWave_init (&initCfg, &errCode); if (gMmwMssMCB.ctrlHandle == NULL) { /* Error: Unable to initialize the mmWave control module */ System_printf("Error: MMWDemoMSS mmWave Control Initialization failed [Error code %d]\n", errCode); return; } System_printf("Debug: MMWDemoMSS mmWave Control Initialization was successful\n"); /* 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 = MMWave_sync (gMmwMssMCB.ctrlHandle , &errCode); if (syncStatus < 0) { /* Error: Unable to synchronize the mmWave control module */ System_printf ("Error: MMWDemoMSS 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 = 3*1024; Task_create(MmwDemo_mmWaveCtrlTask, &taskParams, NULL); /***************************************************************************** * Create a data path management task to handle data Path events *****************************************************************************/ Task_Params_init(&taskParams); taskParams.priority = 2; taskParams.stackSize = 3*1024; Task_create(MmwDemo_mssCtrlPathTask, &taskParams, NULL); /***************************************************************************** * Create a GPIO switch task to handle events related to pressing GPIO switch *****************************************************************************/ Task_Params_init(&taskParams); taskParams.priority = 3; taskParams.stackSize = 1024; Task_create(MmwDemo_gpioSwitchTask, &taskParams, NULL); /***************************************************************************** * At this point, MSS and DSS are both up and synced. Configuration is ready to be sent. * Start CLI to get configuration from user *****************************************************************************/ MmwDemo_CLIInit(); /***************************************************************************** * Benchmarking Count init *****************************************************************************/ /* Configure banchmark counter */ Pmu_configureCounter(0, 0x11, FALSE); Pmu_startCounter(0); return; } /** * @b Description * @n * Function to sleep the R4F using WFI (Wait For Interrupt) instruction. * When R4F has no work left to do, * the BIOS will be in Idle thread and will call this function. The R4F will * wake-up on any interrupt (e.g chirp interrupt). * * @retval * Not Applicable. */ void MmwDemo_sleep(void) { /* issue WFI (Wait For Interrupt) instruction */ asm(" WFI "); } /** * @b Description * @n * Send MSS assert information through CLI. */ void _MmwDemo_mssAssert(int32_t expression, const char *file, int32_t line) { if (!expression) { CLI_write ("MSS Exception: %s, line %d.\n",file,line); } } /** * @b Description * @n * Entry point into the Millimeter Wave Demo * * @retval * Not Applicable. */ int main (void) { Task_Params taskParams; int32_t errCode; SOC_Cfg socCfg; /* Initialize the ESM: */ ESM_init(0U); //dont clear errors as TI RTOS does it /* Initialize and populate the demo MCB */ memset ((void*)&gMmwMssMCB, 0, sizeof(MmwDemo_MCB)); /* Initialize the SOC confiugration: */ memset ((void *)&socCfg, 0, sizeof(SOC_Cfg)); /* Populate the SOC configuration: */ socCfg.clockCfg = SOC_SysClock_INIT; /* Initialize the SOC Module: This is done as soon as the application is started * to ensure that the MPU is correctly configured. */ gMmwMssMCB.socHandle = SOC_init (&socCfg, &errCode); if (gMmwMssMCB.socHandle == NULL) { System_printf ("Error: SOC Module Initialization failed [Error code %d]\n", errCode); return -1; } /* Initialize the DEMO configuration: */ gMmwMssMCB.cfg.sysClockFrequency = MSS_SYS_VCLK; gMmwMssMCB.cfg.loggingBaudRate = 921600; gMmwMssMCB.cfg.commandBaudRate = 115200; /* Check if the SOC is a secure device */ if (SOC_isSecureDevice(gMmwMssMCB.socHandle, &errCode)) { /* Disable firewall for JTAG and LOGGER (UART) which is needed by the demo */ SOC_controlSecureFirewall(gMmwMssMCB.socHandle, (uint32_t)(SOC_SECURE_FIREWALL_JTAG | SOC_SECURE_FIREWALL_LOGGER), SOC_SECURE_FIREWALL_DISABLE, &errCode); } /* Debug Message: */ System_printf ("**********************************************\n"); System_printf ("Debug: Launching the Millimeter Wave Demo\n"); System_printf ("**********************************************\n"); /* Initialize the Task Parameters. */ Task_Params_init(&taskParams); taskParams.priority = 3; taskParams.stackSize = 2*1024; Task_create(MmwDemo_mssInitTask, &taskParams, NULL); /* Start BIOS */ BIOS_start(); return 0; }
此致、
Ben Hassine
您好!
我 仍然有同样的问题、您是否有可以帮助我的建议或答案?
此致、
Ben Hassine
假设(AWR:主器件和 STM 作为 SPI 从器件)、则需要在 SPI 测试应用中将 gXWR1xxxMasterWithMSPTest 设置为 true。
显然、我无法将 SPI 参数 STM 器件映射到 AWR 器件。
以下是与上述 STM 设置匹配(几乎)的参数
params.dataSize = 8;
params.frameFormat = SPI_POL0_PHA0;
Params.ShiftFormat = SPI_MSB_FIRST;
Params.pinMode = SPI_PINMODE_3Pin;
Params.U.masterParams.t2cDelay、c2tDelay 和 wDelay
uint8_t t2cDelay; /*!<发送端到芯片选择无效延迟*/
uint8_t c2tDelay; /*!<芯片选择激活以发送开始延迟*
uint8_t wDelay; /*!<传输之间的延迟*/
需要考虑的要点是相位和极性、我认为您最好使用 SPI 探针来查看信号。
以下是一个用于参考 的 SPI 线路捕捉(相位1、极性0)
https://software-dl.ti.com/ra-processors/esd/MMWAVE-DFP/01_02_06_03/exports/mmWave-Radar-Interface-Control.pdf (图3.3:SPI 消息序列)