/* SPI2 interrupt handler. Clear the SPI interrupt flag and execute the callback function.  */
void SPI2IntHandler(void)
/* SPI2 interrupt handler. Clear the SPI interrupt flag and execute the callback function.  */
void SPI2IntHandler(void)
{
    unsigned long ulEventFlags, ulCR1;
    ulEventFlags =  xHWREG(SPI2_BASE + SPI_SR);
    if((ulEventFlags & SPI_SR_OVR) != 0)
    {
        xHWREG(SPI2_BASE + SPI_DR);
        xHWREG(SPI2_BASE + SPI_SR);
    }
    else if((ulEventFlags & SPI_SR_MODF) != 0)
    {
        ulCR1 = xHWREG(SPI2_BASE + SPI_CR1);
        xHWREG(SPI2_BASE + SPI_CR1) = ulCR1;     
    }
    else if((ulEventFlags & SPI_SR_CRCERR) != 0)
    {
        xHWREG(SPI2_BASE + SPI_SR) &= ~SPI_SR_CRCERR; 
    }
    if(g_pfnSPIHandlerCallbacks[1])
    {
        g_pfnSPIHandlerCallbacks[1](0, 0, ulEventFlags, 0);
    }
}