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.

关于用SYS/BIOS配置中断时函数参数的疑问?

Other Parts Discussed in Thread: SYSBIOS

1.Hwi_Params params;

params.arg是赋值 host interrupt value吗?

如果我的中断事件有对应的eventID,只用配置Hwi,那这个值怎么赋值呢?

2.对于Hwi_creat 的使用

如果只配置Hwi的话,第二个参数就是(ti_sysbios_hal_Hwi_FuncPtr)InterruptHandler,

如果是还配置了CpIntc,用CpIntc_dispatchPlug绑定了Isr,那么第二个参数就是&CpIntc_dispatch吗?

  • 下面是一个简单的例子

     

    1. arg不是中断号,是需要传递给ISR的参数,如果你的ISR需要参数输入,那么这里可以写参数值,没有参数就取0了。

    2. 是的,你用了Cpintc 的dispatcer,那么就把dispatcher挂到就行。

     

    Int main(Int argc, char* argv[]) {

        Log_info0("Bios Start Calling");

        Hwi_Params hwiParams;

        Hwi_Params_init(&hwiParams);

        // set the argument you want passed to your ISR function    

    hwiParams.arg = 0;

        // set the event id of the peripheral assigned to this interrupt    

     hwiParams.eventId = 119;

        // don't allow this interrupt to nest itself    

    hwiParams.maskSetting = Hwi_MaskingOption_SELF;

        hwiParams.enableInt = 0;

         Hwi_eventMap(4, 119);    

        myHwi = Hwi_create(4, &myIsr, &hwiParams, NULL);

        if (myHwi == NULL) {      System_printf("Create Int Failed!");     }

        //Enable interrupt    

       Hwi_enableInterrupt(4);

        BIOS_start();

    }

    Void myIsr(UArg arg)

     {   

     Log_info0("Enter ISR");  

    //Clear Event

    *(Int *)(0x0180004C) |= 0x00800000;

     }

  • 谢谢你的回答,我想再问一下,上边的程序中 Hwi_eventMap(4, 119); 是必须的吗,自己见的程序中没有使用这条语句,我一直以为是Hwi_creat把他们绑定到一起的。

    还有一个问题是如果配置了host interrupt 和system interrupt的话,eventID 是必须用Hwi_getEventId得到的结果来赋值给hwiParams.eventId吗?

  • eventID是不同事件源的No.,这个要查不同芯片手册的事件表来获得;

    Hwi_getEventId是中断设置完成后用来查某个中断对应的事件号的。