Exemplo n.º 1
0
/*******************************************************************************
* Function Name: SPIM_1_Wakeup
********************************************************************************
*
* Summary:
*  Prepare SPIM Component to wake up.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Global Variables:
*  SPIM_1_backup - used when non-retention registers are restored.
*  SPIM_1_txBufferWrite - modified every function call - resets to
*  zero.
*  SPIM_1_txBufferRead - modified every function call - resets to
*  zero.
*  SPIM_1_rxBufferWrite - modified every function call - resets to
*  zero.
*  SPIM_1_rxBufferRead - modified every function call - resets to
*  zero.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void SPIM_1_Wakeup(void) 
{
    SPIM_1_RestoreConfig();

    #if(SPIM_1_RX_SOFTWARE_BUF_ENABLED)
        SPIM_1_rxBufferFull  = 0u;
        SPIM_1_rxBufferRead  = 0u;
        SPIM_1_rxBufferWrite = 0u;
    #endif /* (SPIM_1_RX_SOFTWARE_BUF_ENABLED) */

    #if(SPIM_1_TX_SOFTWARE_BUF_ENABLED)
        SPIM_1_txBufferFull  = 0u;
        SPIM_1_txBufferRead  = 0u;
        SPIM_1_txBufferWrite = 0u;
    #endif /* (SPIM_1_TX_SOFTWARE_BUF_ENABLED) */

    /* Clear any data from the RX and TX FIFO */
    SPIM_1_ClearFIFO();

    /* Restore components block enable state */
    if(0u != SPIM_1_backup.enableState)
    {
        SPIM_1_Enable();
    }
}
Exemplo n.º 2
0
/*******************************************************************************
* Function Name: SPIM_1_Init
********************************************************************************
*
* Summary:
*  Inits/Restores default SPIM configuration provided with customizer.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Side Effects:
*  When this function is called it initializes all of the necessary parameters
*  for execution. i.e. setting the initial interrupt mask, configuring the
*  interrupt service routine, configuring the bit-counter parameters and
*  clearing the FIFO and Status Register.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void SPIM_1_Init(void) 
{
    /* Initialize the Bit counter */
    SPIM_1_COUNTER_PERIOD_REG = SPIM_1_BITCTR_INIT;

    /* Init TX ISR  */
    #if(0u != SPIM_1_INTERNAL_TX_INT_ENABLED)
        CyIntDisable         (SPIM_1_TX_ISR_NUMBER);
        CyIntSetPriority     (SPIM_1_TX_ISR_NUMBER,  SPIM_1_TX_ISR_PRIORITY);
        (void) CyIntSetVector(SPIM_1_TX_ISR_NUMBER, &SPIM_1_TX_ISR);
    #endif /* (0u != SPIM_1_INTERNAL_TX_INT_ENABLED) */

    /* Init RX ISR  */
    #if(0u != SPIM_1_INTERNAL_RX_INT_ENABLED)
        CyIntDisable         (SPIM_1_RX_ISR_NUMBER);
        CyIntSetPriority     (SPIM_1_RX_ISR_NUMBER,  SPIM_1_RX_ISR_PRIORITY);
        (void) CyIntSetVector(SPIM_1_RX_ISR_NUMBER, &SPIM_1_RX_ISR);
    #endif /* (0u != SPIM_1_INTERNAL_RX_INT_ENABLED) */

    /* Clear any stray data from the RX and TX FIFO */
    SPIM_1_ClearFIFO();

    #if(SPIM_1_RX_SOFTWARE_BUF_ENABLED)
        SPIM_1_rxBufferFull  = 0u;
        SPIM_1_rxBufferRead  = 0u;
        SPIM_1_rxBufferWrite = 0u;
    #endif /* (SPIM_1_RX_SOFTWARE_BUF_ENABLED) */

    #if(SPIM_1_TX_SOFTWARE_BUF_ENABLED)
        SPIM_1_txBufferFull  = 0u;
        SPIM_1_txBufferRead  = 0u;
        SPIM_1_txBufferWrite = 0u;
    #endif /* (SPIM_1_TX_SOFTWARE_BUF_ENABLED) */

    (void) SPIM_1_ReadTxStatus(); /* Clear Tx status and swStatusTx */
    (void) SPIM_1_ReadRxStatus(); /* Clear Rx status and swStatusRx */

    /* Configure TX and RX interrupt mask */
    SPIM_1_TX_STATUS_MASK_REG = SPIM_1_TX_INIT_INTERRUPTS_MASK;
    SPIM_1_RX_STATUS_MASK_REG = SPIM_1_RX_INIT_INTERRUPTS_MASK;
}