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.
All:
IRQ_enable( ) gets used in my code and in the example code. However, it differs from most of the other functions in the interrupt support in the value it returns. Most other functions return an error or CSL_OK. IRQ_enable returns an error or a "previous bit mask value."
If I do a test for the error, can I also get confused with a "previous bit mask value" having the same value as the error?
I would like to add this to code that calls IRQ_enable:
...setup code for UART...
retVal = IRQ_enable(UART_EVENT); // Enable Uart interrupt
if(retVal != CSL_ESYS_INVPARAMS) // Check for error response.
{
retVal = 0; // if no error, then set return value to 0.
}
return(retVal); // Return from setup.
Is there a better way to handle the "previous bit mask value" so that I can get a return of error or CSL_OK?
Hi Todd Anderson,
CSL IRQ_enable function returns the previous value of interrupt bit you are trying to enable. It will not return the complete IER register value. For example in your case it returns the UART interrupt bit value in IER0 register before executing the function. In case of successful execution of the function, it returns either 1 or 0 at any instance. So there is no chance of bit mask matching with error return value which is -6. Your logic should work well.
- Pratap.
I agree. In fact there is no need for returning old flag value. You may want to change the function as below.
CSL_Status IRQ_enable (
Uint16 EventId
)
{
Uint16 bit;
Bool old_intm;
/* Wrong Event Id */
if (SINT31_EVENT < EventId)
{
return CSL_ESYS_INVPARAMS;
}
bit= EventId ;
old_intm = IRQ_globalDisable();
if (EventId > RCV2_EVENT)
{
bit = bit - XMT3_EVENT;
CSL_FINSR (CSL_CPU_REGS->IER1, bit,bit,CSL_INTC_BIT_SET);
}
else
{
CSL_FINSR (CSL_CPU_REGS->IER0, bit, bit,CSL_INTC_BIT_SET);
}
IRQ_globalRestore(old_intm);
return (CSL_SOK);
}
- Pratap.