示例#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);
}
示例#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);
}
示例#3
0
/*******************************************************************************
* Function Name: SPIM_ReadRxStatus
********************************************************************************
*
* Summary:
*  Read the Rx status register for the component.
*
* Parameters:
*  None.
*
* Return:
*  Contents of the Rx status register.
*
* Global variables:
*  SPIM_swStatusRx - used to store in software Rx status register,
*  modified every function call - resets to zero.
*
* Theory:
*  Allows the user and the API to read the Rx status register for error
*  detection and flow control.
*
* Side Effects:
*  Clear Rx status register of the component.
*
* Reentrant:
*  No.
*
*******************************************************************************/
uint8 SPIM_ReadRxStatus(void) 
{
    uint8 tmpStatus;

    #if(SPIM_RX_SOFTWARE_BUF_ENABLED)
        /* Disable RX interrupt to protect global veriables */
        SPIM_DisableRxInt();

        tmpStatus = SPIM_GET_STATUS_RX(SPIM_swStatusRx);
        SPIM_swStatusRx = 0u;

        SPIM_EnableRxInt();

    #else

        tmpStatus = SPIM_RX_STATUS_REG;

    #endif /* (SPIM_RX_SOFTWARE_BUF_ENABLED) */

    return(tmpStatus);
}
示例#4
0
/*******************************************************************************
* Function Name: SPIM_ReadRxStatus
********************************************************************************
*
* Summary:
*  Read the Rx status register for the component.
*
* Parameters:
*  None.
*
* Return:
*  Contents of the Rx status register.
*
* Global variables:
*  SPIM_swStatusRx - used to store in software Rx status register, 
*  modified every function call - resets to zero.
*
* Theory:
*  Allows the user and the API to read the Rx status register for error 
*  detection and flow control.
*
* Side Effects:
*  Clear Rx status register of the component.
*
* Reentrant:
*  No.
*
*******************************************************************************/
uint8 SPIM_ReadRxStatus(void)
{
    uint8 tmpStatus = 0u;
        
    #if (SPIM_RXBUFFERSIZE > 4u)
    
        SPIM_DisableRxInt();
        
        tmpStatus = SPIM_GET_STATUS_RX(SPIM_swStatusRx);
               
        SPIM_swStatusRx = 0u;
        
        /* Enable Interrupts */
        SPIM_EnableRxInt();
        
    #else /* (SPIM_RXBUFFERSIZE < 4u) */
    
        tmpStatus = SPIM_RX_STATUS_REG;
        
    #endif /* (SPIM_RXBUFFERSIZE > 4u) */
    
    return(tmpStatus);
}