Other Parts Discussed in Thread: SYSBIOS
下面是SRIO例程中设置中断的部分代码:
/* 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);
然后我在sysbios中也看到一个示例代码如下:
Int i;
Int eventId;
Hwi_Params hwiParams;
Int hostInt, sysInt;
Error_Block eb;
// Initialize the error block
Error_init(&eb);
// Map 3 System interrupts (33-35) to a single Host interrupt (1).
sysInt = 33;
hostInt = 1;
for (i = 0; i < 3; i++) {
// Map System interrupts to the Host interrupt on Intc 0
CpIntc_mapSysIntToHostInt(0, sysInt + i, hostInt);
// Plug and enable the function and argument for System interrupts
CpIntc_dispatchPlug(sysInt + i, myIsr, sysInt + i, TRUE);
}
// Enable the Host interrupt on Intc 0
CpIntc_enableHostInt(0, hostInt);
// Get the eventId associated with the Host interrupt
eventId = CpIntc_getEventId(hostInt);
// Plug the event associated with Host Interrupt.
// The function must be 'CpIntc_dispatch' and argument 'hostInt'.
EventCombiner_dispatchPlug(eventId, &CpIntc_dispatch, hostInt, TRUE);
// Initialize the Hwi parameters
Hwi_Params_init(&hwiParams);
// The eventId must be set to the combined event
hwiParams.eventId = (eventId / 32);
// The arg must be set to hwiParams.eventId
hwiParams.arg = hwiParams.eventId;
// Enable the interrupt.
hwiParams.enableInt = TRUE;
// Create the Hwi on interrupt 9 then specify 'EventCombiner_dispatch'
// as the function.
Hwi_create(9, &EventCombiner_dispatch, &hwiParams, NULL);
针对以上代码,我有几点不明白的地方:
1、SRIO例程中的CSL_SRIO_DisableInterruptPacing (hSrioCSL, 0)这个函数的作用不太理解;
2、SRIO例程中EventCombiner_dispatchPlug (eventId, CpIntc_dispatch, 8, TRUE)这个函数的第二个参数是CpIntc_dispatch,而sysbios示例代码中这个函数的第二个参数是&CpIntc_dispatch,这是为什么呢?
3、SRIO例程中没有调用Hwi_create来映射event id到可屏蔽中断号,而sysbios示例代码中是有的,这是为什么呢?
希望专家或前辈能够解答一下,谢谢!