Ejemplo n.º 1
0
/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
* Summary:
* Start the components and initialize system.
*
* Parameters:
*  void
*
* Return:
*  void
*
*******************************************************************************/
void InitializeSystem(void)
{
	/* Enable global interrupt mask */
	CyGlobalIntEnable; 
		
	/* Start BLE component and register the CustomEventHandler function. This 
	 * function exposes the events from BLE component for application use */
    CyBle_Start(CustomEventHandler);	
    
	/* Start both the PrISM components for LED control*/
    PRS_1_Start();
    PRS_2_Start();
	
	/* The RGB LED on BLE Pioneer kit are active low. Drive HIGH on 
	 * pin for OFF and drive LOW on pin for ON*/
	PRS_1_WritePulse0(RGB_LED_OFF);
	PRS_1_WritePulse1(RGB_LED_OFF);
	PRS_2_WritePulse0(RGB_LED_OFF);
	
	/* Set Drive mode of output pins from HiZ to Strong */
	RED_SetDriveMode(RED_DM_STRONG);
	GREEN_SetDriveMode(GREEN_DM_STRONG);
	BLUE_SetDriveMode(BLUE_DM_STRONG);
	
	/* Initialize CapSense component and initialize baselines*/
	CapSense_Start();
	CapSense_InitializeAllBaselines();
}
Ejemplo n.º 2
0
void initializeSystem(void) {
    CyGlobalIntEnable;
    
    UART_Start(); 
    
    PrISM_1_Start();
    PrISM_2_Start();
    
    Opamp_1_Start();
    
    // Start the Bluetooth Stack
    CyBle_Start(CustomEventHandler);	
    
    // Set up the LED. First set its output to be off so that the LED doesn't blink on.
    // Then set the drive mode to strong.
	PrISM_1_WritePulse0(255);
	PrISM_1_WritePulse1(255);
	PrISM_2_WritePulse0(255);
	
	RED_SetDriveMode(RED_DM_STRONG);
	GREEN_SetDriveMode(GREEN_DM_STRONG);
	BLUE_SetDriveMode(BLUE_DM_STRONG);
    
    // Start the ADC
    ADC_SAR_Seq_Start();
    ADC_SAR_Seq_StartConvert();
    ADC_SAR_Seq_IRQ_Enable();
    // Enable an interupt for when the ADC has data
    ADC_SAR_Seq_IRQ_StartEx(ADC_SAR_Seq_ISR_LOC);
    
    // Start the Timer for the ADC
    ADC_Timer_Start();
    
    elapsed = 0;
}
Ejemplo n.º 3
0
/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
* Summary:
*        Start the components and initialize system 
*
* Parameters:
*  void
*
* Return:
*  void
*
*******************************************************************************/
void InitializeSystem(void)
{
	/* Enable global interrupt mask */
	CyGlobalIntEnable; 
			
	/* Start BLE component and register the CustomEventHandler function. This 
	* function exposes the events from BLE component for application use */
    CyBle_Start(CustomEventHandler);
	
	/* Set Drive mode of output pins from HiZ to Strong */
	RED_SetDriveMode(RED_DM_STRONG);
	GREEN_SetDriveMode(GREEN_DM_STRONG);
	BLUE_SetDriveMode(BLUE_DM_STRONG);
	
	/* Start the Button ISR to allow wakeup from sleep */
	isr_button_StartEx(MyISR);
	
	/* Set the Watchdog Interrupt vector to the address of Interrupt routine 
	* WDT_INT_Handler. This routine counts the 3 seconds for LED ON state during
	* connection. */
	CyIntSetVector(WATCHDOG_INT_VEC_NUM, &WDT_INT_Handler);
}
/*******************************************************************************
* Function Name: HandleLowPowerMode
********************************************************************************
* Summary:
*        This function puts the BLESS in deep sleep mode and CPU to sleep mode. 
* System will resume from here when it wakes from user button press.
*
* Parameters:
*  void
*
* Return:
*  void
*
*******************************************************************************/
void HandleLowPowerMode(uint8 lpmSel)
{
	#ifdef ENABLE_LOW_POWER_MODE
		/* Local variable to store the status of BLESS Hardware block */
		CYBLE_LP_MODE_T sleepMode;
		CYBLE_BLESS_STATE_T blessState;

        if (lpmSel == DEEPSLEEP)
        {
            /* Leave chip in Deep Sleep mode */
    		/* Put BLESS into Deep Sleep and check the return status */
    		sleepMode = CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP);
    		
    		/* Disable global interrupt to prevent changes from any other interrupt ISR */
    		CyGlobalIntDisable;
    	
    		/* Check the Status of BLESS */
    		blessState = CyBle_GetBleSsState();

    		if(sleepMode == CYBLE_BLESS_DEEPSLEEP)
    		{
    		    /* If the ECO has started or the BLESS can go to Deep Sleep, then place CPU 
    			* to Deep Sleep */
    			if(blessState == CYBLE_BLESS_STATE_ECO_ON || blessState == CYBLE_BLESS_STATE_DEEPSLEEP)
    		    {
    				/* Place CPU to Deep sleep */
                    #ifdef ENABLE_LED_NOTIFICATION
                    GREEN_SetDriveMode(GREEN_DM_STRONG);
                    GREEN_Write(0);
                    #endif
                    
    		        CySysPmDeepSleep();
                    
                    #ifdef ENABLE_LED_NOTIFICATION
                    GREEN_SetDriveMode(GREEN_DM_STRONG);
                    GREEN_Write(1);
                    #endif
    		 	}
    		}
    		
    		/* Re-enable global interrupt mask after wakeup */
    		CyGlobalIntEnable;        
        }
#if 0
        else if (lpmSel == SLEEP)
        {
            /* Leave chip in Sleep mode */
            /* Leave chip in Deep Sleep mode */
    		/* Put BLESS into Deep Sleep and check the return status */
    		sleepMode = CyBle_EnterLPM(CYBLE_BLESS_SLEEP);
    		
    		/* Disable global interrupt to prevent changes from any other interrupt ISR */
    		CyGlobalIntDisable;
    	
    		/* Check the Status of BLESS */
    		blessState = CyBle_GetBleSsState();

    		if(sleepMode == CYBLE_BLESS_SLEEP)
    		{
    		    if(blessState != CYBLE_BLESS_STATE_EVENT_CLOSE)
    		    {
    				/* If BLE Event has not 
    				* closed yet, then place CPU to Sleep */
                    #ifdef ENABLE_LED_NOTIFICATION                   
                    BLUE_Write(0);
                    BLUE_SetDriveMode(BLUE_DM_STRONG);
                    #endif
                    
    		        CySysPmSleep();
                    
                    #ifdef ENABLE_LED_NOTIFICATION
                    BLUE_SetDriveMode(BLUE_DM_STRONG);
                    BLUE_Write(1);
                    #endif
    		    }
    		}
    		
    		/* Re-enable global interrupt mask after wakeup */
    		CyGlobalIntEnable;        
        }
        else if (lpmSel == ACTIVE)
        {
            /* Leave chip in Active mode */
            #ifdef ENABLE_LED_NOTIFICATION
            RED_Write(0);
            RED_SetDriveMode(RED_DM_STRONG);
            #endif
        }
#endif        
	#endif
}