Esempio n. 1
0
File: Init.c Progetto: Shogun5/BLE
/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
*
* Summary:
*  Systm initialization function.
*
* Parameters:  
*  None
*
* Return: 
*  None
*
*******************************************************************************/
void InitializeSystem(void)
{
    CyGlobalIntEnable;      /* Enable Global Interrupts*/
    
    /* Internal low power oscillator is no longer required after Watch Crystal oscillator is started */
    CySysClkIloStop();
    
    /* Set the divider for ECO, ECO will be used as source when IMO is switched off to save power */
    CySysClkWriteEcoDiv(CY_SYS_CLK_ECO_DIV8);
    
    BLE_Engine_Start();     /* Kick start the BLE GATT server and client interface */
    
    /* Wait for BLE Component to Initialize */
    while (CyBle_GetState() == CYBLE_STATE_INITIALIZING)
    {
        CyBle_ProcessEvents(); 
    }
    
#if BLE_COEXISTENCE_ENABLE
    *(uint32*)(CYREG_RADIO_TX_RX_MUX_REGISTER)&= ~RADIO_TX_RX_MUX_MASK;   /* Clear Previous mux selection */
    *(uint32*)(CYREG_RADIO_TX_RX_MUX_REGISTER) |=  BLESS_MUX_INPUT_MASK;  /* Set BLESS as the source of the mux */
    *(uint32*)(CYREG_BLE_BLESS_RF_CONFIG) |= RADIO_TX_RX_SEL; /* Select Tx enable & Rx enable signals from BLESS as input to mux */
    
    Radio_Control_Interrupt_StartEx(&Radio_Control_ISR);
#endif /* End of #if BLE_COEXISTENCE_ENABLE */
}
Esempio n. 2
0
File: Init.c Progetto: Shogun5/BLE
/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
*
* Summary:
*  Systm initialization function.
*
* Parameters:  
*  None
*
* Return: 
*  None
*
*******************************************************************************/
void InitializeSystem(void)
{
    CyGlobalIntEnable;      /* Enable Global Interrupts*/
    
    /* Internal low power oscillator is no longer required after Watch Crystal oscillator is started */
    CySysClkIloStop();
    
    /* Set the divider for ECO, ECO will be used as source when IMO is switched off to save power */
    CySysClkWriteEcoDiv(CY_SYS_CLK_ECO_DIV8);
    
    BLE_Engine_Start();     /* start the BLE interface */
    
    /* Wait for BLE Component to Initialize */
    while (CyBle_GetState() == CYBLE_STATE_INITIALIZING)
    {
        CyBle_ProcessEvents(); 
    }
    
#if (CONSOLE_LOG_ENABLE)
    Console_Start();  /* Console log interface */
    Console_UartPutString("System initialization complete\r\n"); 
#endif /* End of #if (CONSOLE_LOG_ENABLE) */
    
    /* ADD YOUR CODE TO INITIALIZE OTHER COMPONENTS IN YOUR DESIGN */
}
Esempio n. 3
0
/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
*
* Summary:
*  Systm initialization function.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void InitializeSystem(void)
{
    CyGlobalIntEnable;      /* Enable Global Interrupts*/

    /* Set the divider for ECO, ECO will be used as source when IMO is switched off to save power */
    CySysClkWriteEcoDiv(CY_SYS_CLK_ECO_DIV8);

#if LOW_POWER_STARTUP_ENABLE

    /* If LOW_POWER_STARTUP_ENABLE is set, then do the following for achieving lowest possible WCO & ECO startup current:
     * 1. Shut down the ECO (to reduce power consumption while WCO is starting)
     * 2. Enable WDT counter 0 to wakeup the system after 500ms (500ms = WCO startup time)
     * 3. Configure PSoC 4 BLE device in DeepSleep mode for the 500ms WCO startup time
     * 4. After WCO is enabled, restart the ECO so that BLESS interface can function
     * 5. Enable WDT counter 1 to wakeup the system after 1ms (1ms = ECO startup time)
     * 5. Configure PSoC 4 BLE device in DeepSleep mode for the 1ms ECO startup time */

    CySysClkEcoStop();      /* Shutdown the ECO and later re-start in low power mode after WCO is turned on */

    WDT_Interrupt_StartEx(WDT_Handler); /* Initialize WDT interrupt */

    WCO_ECO_LowPowerStart();    /* Enable WCO & ECO in low power mode using WDT counter 0/1 as system wakeup sources respectively */

#endif /* End of #if LOW_POWER_STARTUP_ENABLE */

#if (CONSOLE_LOG_ENABLE)
    Console_Start();  /* Console log interface */
    Console_UartPutString("Low power system startup complete\r\n");
#endif /* End of #if (CONSOLE_LOG_ENABLE) */

    BLE_Engine_Start();     /* start the BLE interface */

    /* Wait for BLE Component to Initialize */
    while (CyBle_GetState() == CYBLE_STATE_INITIALIZING)
    {
        CyBle_ProcessEvents();
    }
}