TI中文支持网
TI专业的中文技术问题搜集分享网站

在SRIO_LoopbackDioIsrexampleproject中,怎样将dioSocketsWithISR改成接收FPGA发的门铃包,再执行SRIO ISR程序,这个过程是循环的?

static Int32 dioSocketsWithISR (Srio_DrvHandle hSrioDrv, uint8_t dio_ftype, uint8_t dio_ttype)
{
Srio_SockBindAddrInfo bindInfo;
Srio_SockAddrInfo to;
uint16_t sockIdx, i;
uint16_t counter, srcDstBufIdx = 0;
int32_t eventId, startTime;
UInt8 **srcDataBufPtr = NULL, **dstDataBufPtr = NULL;
uint8_t compCode;

System_printf ("*************************************************************\n");
System_printf ("******* DIO Socket Example with Interrupts (Core %d) ********\n", coreNum);
System_printf ("*************************************************************\n");

/* Get the CSL SRIO Handle. */
hSrioCSL = CSL_SRIO_Open (0);
if (hSrioCSL == NULL)
return -1;

/* SRIO DIO Interrupts need to be routed from the CPINTC0 to GEM Event.
* – We have configured DIO Interrupts to get routed to Interrupt Destination 0
* (Refer to the CSL_SRIO_RouteLSUInterrupts API configuration in the SRIO Initialization)
* – We want this System Interrupt to mapped to Host Interrupt 8 */

/* Disable Interrupt Pacing for INTDST0 */
CSL_SRIO_DisableInterruptPacing (hSrioCSL, 0);

/* Route LSU0 ICR0 to INTDST0 */
CSL_SRIO_RouteLSUInterrupts (hSrioCSL, 0, 0);

/* Route LSU0 ICR1 to INTDST0 */
CSL_SRIO_RouteLSUInterrupts (hSrioCSL, 1, 0);

/* Route LSU0 ICR2 to INTDST0 */
CSL_SRIO_RouteLSUInterrupts (hSrioCSL, 2, 0);

/* Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */
CpIntc_dispatchPlug(CSL_INTC0_INTDST0, (CpIntc_FuncPtr)myDioTxCompletionIsr, (UArg)hSrioDrv, TRUE);

/* The configuration is for CPINTC0. We map system interrupt 112 to Host Interrupt 8. */
CpIntc_mapSysIntToHostInt(0, CSL_INTC0_INTDST0, 8);

/* Enable the Host Interrupt. */
CpIntc_enableHostInt(0, 8);

/* Enable the System Interrupt */
CpIntc_enableSysInt(0, CSL_INTC0_INTDST0);

/* Get the event id associated with the host interrupt. */
eventId = CpIntc_getEventId(8);

/* Plug the CPINTC Dispatcher. */
EventCombiner_dispatchPlug (eventId, CpIntc_dispatch, 8, TRUE);

for (sockIdx = 0; sockIdx < SRIO_DIO_LSU_ISR_NUM_SOCKETS; sockIdx++)
{
/* Open DIO SRIO Non-Blocking Socket */
srioSocket[sockIdx] = Srio_sockOpen (hSrioDrv, Srio_SocketType_DIO, FALSE);
if (srioSocket[sockIdx] == NULL)
{
System_printf ("Error: Unable to open the DIO socket – %d\n", sockIdx);
return -1;
}

/* DIO Binding Information: Use 16 bit identifiers and we are bound to the first source id.
* and we are using 16 bit device identifiers. */
bindInfo.dio.doorbellValid = 0;
bindInfo.dio.intrRequest = 1;
bindInfo.dio.supInt = 0;
bindInfo.dio.xambs = 0;
bindInfo.dio.priority = 0;
bindInfo.dio.outPortID = 0;
bindInfo.dio.idSize = 1;
bindInfo.dio.srcIDMap = sockIdx;
bindInfo.dio.hopCount = 0;
bindInfo.dio.doorbellReg = 0;
bindInfo.dio.doorbellBit = 0;

/* Bind the SRIO socket: DIO sockets do not need any binding information. */ if (Srio_sockBind_DIO (srioSocket[sockIdx], &bindInfo) < 0)
{
System_printf ("Error: Binding the SIO socket failed.\n");
return -1;
}
}

/* Allocate memory for the Source and Destination Buffers */
for (i = 0; i < (SRIO_DIO_LSU_ISR_NUM_SOCKETS * SRIO_DIO_LSU_ISR_NUM_TRANSFERS); i++)
{
srcDataBuffer[i] = (uint8_t*)Osal_srioDataBufferMalloc(SIZE_DIO_PACKET);
if (srcDataBuffer[i] == NULL)
{
System_printf ("Error: Source Buffer (%d) Memory Allocation Failed\n", i);
return -1;
}
dstDataBuffer[i] = (uint8_t*)Osal_srioDataBufferMalloc(SIZE_DIO_PACKET);
if (dstDataBuffer[i] == NULL)
{
System_printf ("Error: Destination Buffer (%d) Memory Allocation Failed\n", i);
return -1;
}

/* Initialize the data buffers */
for (counter = 0; counter < SIZE_DIO_PACKET; counter++)
{
srcDataBuffer[i][counter] = 0x30 + (i * 5);
dstDataBuffer[i][counter] = 0;
}
/* Debug Message: */
System_printf ("Debug(Core %d): Starting the DIO Data Transfer – Src(%d) 0x%p Dst(%d) 0x%p\n", coreNum, i, srcDataBuffer[i], i, dstDataBuffer[i]);
}
if ((dio_ftype == Srio_Ftype_WRITE) && (dio_ttype == Srio_Ttype_Write_NWRITE_R))
{
/* DIO Write operation */
srcDataBufPtr = &srcDataBuffer[0];
dstDataBufPtr = &dstDataBuffer[0];
}
else if ((dio_ftype == Srio_Ftype_REQUEST) && (dio_ttype == Srio_Ttype_Request_NREAD))
{
/* DIO Read operation */
srcDataBufPtr = &dstDataBuffer[0];
dstDataBufPtr = &srcDataBuffer[0];
}
else
{
/* Debug Message: */
System_printf ("Debug(Core %d): Unexpected combination of FTYPE and TTYPE. Example couldn't run. Exiting!!!\n", coreNum);
return -1;
}

/*********************************************************************************
* Run multiple iterations of the example to ensure multiple data transfers work
*********************************************************************************/
for (counter = 0; counter < SRIO_DIO_LSU_ISR_NUM_TRANSFERS; counter++)
{
for (sockIdx = 0; sockIdx < SRIO_DIO_LSU_ISR_NUM_SOCKETS; sockIdx++)
{
/* Populate the DIO Address Information where the data is to be sent. */
to.dio.rapidIOMSB = 0x0;
to.dio.rapidIOLSB = (uint32_t)&dstDataBufPtr[srcDstBufIdx][0];
to.dio.dstID = DEVICE_ID2_16BIT;
to.dio.ttype = dio_ttype;
to.dio.ftype = dio_ftype;

/* Send the DIO Information. */
if (Srio_sockSend_DIO (srioSocket[sockIdx], srcDataBufPtr[srcDstBufIdx], SIZE_DIO_PACKET, (Srio_SockAddrInfo*)&to) < 0)
{
System_printf ("Debug(Core %d): DIO Socket Example Failed\n", coreNum);
return -1;
}

/* Wait for the interrupt to occur without touching the peripheral. */
/* Other useful work could be done here such as by invoking a scheduler */
startTime = TSCL;
while((! srioLsuIsrServiced) && ((TSCL – startTime) < SRIO_DIO_LSU_ISR_TIMEOUT));

if (! srioLsuIsrServiced) {
System_printf ("ISR didn't happen within set time – %d cycles. Example failed !!!\n", SRIO_DIO_LSU_ISR_TIMEOUT);
return -1;
}

/* Debug Message: Data Transfer was completed successfully. */
System_printf ("Debug(Core %d): DIO Socket (%d) Send for iteration %d\n", coreNum, sockIdx, counter);

/* Read the completion code filled by the ISR */
compCode = 0xFF;
if (Srio_getSockOpt(srioSocket[sockIdx], Srio_Opt_DIO_READ_SOCK_COMP_CODE, &compCode, sizeof(uint8_t)) < 0)
{
System_printf ("Error: Unable to read the completion code in socket\n");
return -1;
}
/* Was the transfer good. */
if (compCode == 0)
{
srioDioLsuGoodTransfers++;
}
else
{
srioDioLsuBadTransfers++;
}

/* Clear the LSU pending interrupt (ICCx) */
CSL_SRIO_ClearLSUPendingInterrupt (hSrioCSL, 0xFFFFFFFF, 0xFFFFFFFF);
srioLsuIsrServiced = 0;
/* Debug Message: Display ISR count */
System_printf ("Debug(Core %d): ISR Count: %d\n", coreNum, srioDbgDioIsrCnt);

/* Load next set of payload buffers */
srcDstBufIdx++;
if (srcDstBufIdx > (SRIO_DIO_LSU_ISR_NUM_SOCKETS * SRIO_DIO_LSU_ISR_NUM_TRANSFERS))
{
System_printf ("Debug(Core %d): DIO Socket Example — Out of SRC and DST buffers\n", coreNum);
return -1;
}
}
}

/* Validate the received buffer. */
for (i = 0; i < (SRIO_DIO_LSU_ISR_NUM_SOCKETS * SRIO_DIO_LSU_ISR_NUM_TRANSFERS); i++)
{
for (counter = 0; counter < SIZE_DIO_PACKET; counter++)
{
if (dstDataBufPtr[i][counter] != srcDataBufPtr[i][counter])
{
System_printf ("Error(Core %d): Data Validation error. Buffer Number (%d): Expected 0x%x got 0x%x @ index %d\n", coreNum, i, srcDataBufPtr[i][counter], dstDataBufPtr[i][counter], counter);
return -1;
}
}
}

/* Debug Message: Print error counters */
System_printf ("Debug(Core %d): Transfer Completion without Errors – %d\n", coreNum, srioDioLsuGoodTransfers);
System_printf ("Debug(Core %d): Transfer Completion with Errors – %d\n", coreNum, srioDioLsuBadTransfers);

/* Cleanup the source & destination buffers. */
for (srcDstBufIdx = 0; srcDstBufIdx < (SRIO_DIO_LSU_ISR_NUM_SOCKETS * SRIO_DIO_LSU_ISR_NUM_TRANSFERS); srcDstBufIdx++)
{
Osal_srioDataBufferFree ((Void*)srcDataBufPtr[srcDstBufIdx], SIZE_DIO_PACKET);
Osal_srioDataBufferFree ((Void*)dstDataBufPtr[srcDstBufIdx], SIZE_DIO_PACKET);
}
/* Close the sockets */
for (sockIdx = 0; sockIdx < SRIO_DIO_LSU_ISR_NUM_SOCKETS; sockIdx++)
{
Srio_sockClose_DIO (srioSocket[sockIdx]);
}

if (srioDioLsuBadTransfers > 0)
{
System_printf ("Debug(Core %d): DIO Transfer Data NOT completed successfully !!! \n", coreNum);
return -1;
}

/* Debug Message: Data was validated */
System_printf ("Debug(Core %d): DIO Transfer Data Validated for all iterations\n", coreNum);

/* Debug Message: Example completed */
if ((dio_ftype == Srio_Ftype_WRITE) && (dio_ttype == Srio_Ttype_Write_NWRITE_R))
{
System_printf ("Debug(Core %d): DIO Data Transfer (WRITE) with Interrupts Example Passed\n", coreNum);
}
else if ((dio_ftype == Srio_Ftype_REQUEST) && (dio_ttype == Srio_Ttype_Request_NREAD))
{
System_printf ("Debug(Core %d): DIO Data Transfer (READ) with Interrupts Example Passed\n", coreNum);
}

return 0;
}

Shine:

请参考下面的帖子。
e2e.ti.com/…/324521

user5301336:

回复 Shine:

看了您分享的帖子,确实有类似的问题,但是里面并没有解决的方法,不知道该如何弄?能不能再分享几篇?

赞(0)
未经允许不得转载:TI中文支持网 » 在SRIO_LoopbackDioIsrexampleproject中,怎样将dioSocketsWithISR改成接收FPGA发的门铃包,再执行SRIO ISR程序,这个过程是循环的?
分享到: 更多 (0)