#include "irqhandler.h"

void NMI_IRQHandler(void)
{

}

void HardFault_IRQHandler(void)
{
    while (1)
    {
    }
}

void SVC_IRQHandler(void)
{

}

void PendSV_IRQHandler(void)
{

}
void SysTick_IRQHandler(void)
{
    TimingDelay_Decrement();
}

void SPI0_IRQHandler(void)
{
    if ((SET == SPI_GetITStatus(SPI_IT_RB)) && (SET == SPI_GetFlagStatus(SPI_Flag_RB)))
    {
        g_rbuf[rbufIndex++] = SPI_RecByte();

        if (rbufIndex == g_rbufamount)
        {
            SPI_ITConfig(SPI_IT_RB, DISABLE);
        }
    }

    if ((SET == SPI_GetITStatus(SPI_IT_TB)) && (SET == SPI_GetFlagStatus(SPI_Flag_TB)))
    {
        SPI_SendByte(g_wbuf[wbufIndex++]);

        if (wbufIndex == g_wbufamount)
        {
            SPI_ITConfig(SPI_IT_TB, DISABLE);
        }
    }
}
