/* The Receive Buffer Full IRQ is enabled in the following conditions: */
void sci_spi_rxi_isr(void)
/* The Receive Buffer Full IRQ is enabled in the following conditions: */
void sci_spi_rxi_isr(void)
{
    FSP_CONTEXT_SAVE;
    IRQn_Type irq = R_FSP_CurrentIrqGet();
    R_BSP_IrqStatusClear(irq);
    sci_spi_instance_ctrl_t * p_ctrl = (sci_spi_instance_ctrl_t *) R_FSP_IsrContextGet(irq);
    r_sci_spi_transmit(p_ctrl);
    if (p_ctrl->rx_count < p_ctrl->count)
    {
        p_ctrl->p_dest[p_ctrl->rx_count++] = p_ctrl->p_reg->RDR;
    }
    if (p_ctrl->rx_count == p_ctrl->count)
    {
        p_ctrl->p_reg->SCR =
            (uint8_t) ((p_ctrl->p_reg->SCR & ~(R_SCI0_SCR_TIE_Msk | R_SCI0_SCR_RIE_Msk)) | R_SCI0_SCR_TEIE_Msk);
    }
    FSP_CONTEXT_RESTORE;
}