void LED_B(void){ BLUE_Write(~BLUE_Read()); }
/******************************************************************************* * 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 }