Example #1
0
/*******************************************************************************
* Function Name: SPIM_ReadStatus
********************************************************************************
*
* Summary:
*  Read the status register for the component.
*
* Parameters:
*  None.
*
* Return:
*  Contents of the status register.
*
* Global variables:
*  SPIM_swStatus - used to store in software status register, 
*  modified every function call - resets to zero.
*
* Theory:
*  Allows the user and the API to read the status register for error detection
*  and flow control.
*
* Side Effects:
*  Clear status register of the component.
*
* Reentrant:
*  No.
*
*******************************************************************************/
uint8 SPIM_ReadStatus(void)
{
    uint8 tmpStatus;
        
    #if ((SPIM_TXBUFFERSIZE > 4u) || (SPIM_RXBUFFERSIZE > 4u))
    
        SPIM_DisableInt();
        
        tmpStatus = (SPIM_GET_STATUS_TX(SPIM_swStatusTx) & 
                      ~(1u << SPIM_STS_SPI_IDLE_SHIFT)) | 
                      SPIM_GET_STATUS_RX(SPIM_swStatusRx);
        
        SPIM_swStatusTx = 0u;
        SPIM_swStatusRx = 0u;
        
        /* Enable Interrupts */
        SPIM_EnableInt();
        
    #else /* (SPIM_TXBUFFERSIZE < 4u) && (SPIM_RXBUFFERSIZE < 4u) */
    
        tmpStatus = (SPIM_TX_STATUS_REG & ~(1u << SPIM_STS_SPI_IDLE_SHIFT)) |
                     SPIM_RX_STATUS_REG;
        
    #endif /* (SPIM_TXBUFFERSIZE > 4u) || (SPIM_RXBUFFERSIZE > 4u) */
    
    return(tmpStatus);
}
Example #2
0
/*******************************************************************************
* Function Name: SPIM_ReadStatus
********************************************************************************
*
* Summary:
*  Read the status register for the component.
*
* Parameters:
*  None.
*
* Return:
*  Contents of the status register.
*
* Global variables:
*  SPIM_swStatus - used to store in software status register,
*  modified every function call - resets to zero.
*
* Theory:
*  Allows the user and the API to read the status register for error detection
*  and flow control.
*
* Side Effects:
*  Clear status register of the component.
*
* Reentrant:
*  No.
*
*******************************************************************************/
uint8 SPIM_ReadStatus(void) 
{
    uint8 tmpStatus;

    #if(SPIM_TX_SOFTWARE_BUF_ENABLED || SPIM_RX_SOFTWARE_BUF_ENABLED)

        SPIM_DisableInt();

        tmpStatus  = SPIM_GET_STATUS_RX(SPIM_swStatusRx);
        tmpStatus |= SPIM_GET_STATUS_TX(SPIM_swStatusTx);
        tmpStatus &= ((uint8) ~SPIM_STS_SPI_IDLE);

        SPIM_swStatusTx = 0u;
        SPIM_swStatusRx = 0u;

        SPIM_EnableInt();

    #else

        tmpStatus  = SPIM_RX_STATUS_REG;
        tmpStatus |= SPIM_TX_STATUS_REG;
        tmpStatus &= ((uint8) ~SPIM_STS_SPI_IDLE);

    #endif /* (SPIM_TX_SOFTWARE_BUF_ENABLED || SPIM_RX_SOFTWARE_BUF_ENABLED) */

    return(tmpStatus);
}