/*FUNCTION*----------------------------------------------------------------- * * Function Name : _mcf5441_int_init * Returned Value : uint_32 * Comments : * Initialize a specific interrupt in the proper interrupt controller * SEJ 26-APR-2013 : Revised to quick fix incoming irq as unsigned char. * *END*---------------------------------------------------------------------*/ uint_32 _mcf5441_int_init ( // [IN} Interrupt number //PSP_INTERRUPT_TABLE_INDEX irq, PSP_INTERRUPT_TABLE_INDEX irq_in, // SEJ - this is being case as signed 8-bit // [IN} Interrupt priority level _int_level level, // [IN} Unmask the interrupt now? boolean unmask ) { _mqx_int idx; uint_32 temp; /* This function had some issues... at least when called from an external application. * The passed PSP_INTERRUPT_TABLE_INDEX irq was interpreted as a signed 8-bit number, * so any irq > 127 came in as a negative number. Perhaps this issue is deeper than * this, but to quick fix I changed the passed in argument 'irq' to 'irq_in' and then * declare the local uchar irq here. **/ uchar irq = irq_in ;
if (irq >= PSP_INT_FIRST_EXTERNAL) { idx = irq - PSP_INT_FIRST_EXTERNAL; temp = _psp_get_sr(); _psp_set_sr(temp | 0x0700); if (idx < 64) { PSP_GET_ICTRL0_BASE()->ICR[idx] = level & 7; if (unmask) PSP_GET_ICTRL0_BASE()->CIMR = MCF54XX_ICTRL_IMR_N(idx); else PSP_GET_ICTRL0_BASE()->SIMR = MCF54XX_ICTRL_IMR_N(idx); } else if (idx < 128) { idx -= 64; PSP_GET_ICTRL1_BASE()->ICR[idx] = level & 7; if (unmask) PSP_GET_ICTRL1_BASE()->CIMR = MCF54XX_ICTRL_IMR_N(idx); else PSP_GET_ICTRL1_BASE()->SIMR = MCF54XX_ICTRL_IMR_N(idx); } else { idx -= 128; PSP_GET_ICTRL2_BASE()->ICR[idx] = level & 7; if (unmask) PSP_GET_ICTRL2_BASE()->CIMR = MCF54XX_ICTRL_IMR_N(idx); else PSP_GET_ICTRL2_BASE()->SIMR = MCF54XX_ICTRL_IMR_N(idx); } _psp_set_sr(temp); return MQX_OK; } return MQX_INVALID_PARAMETER; } |