コード例 #1
0
ファイル: UART_DEB_PM.c プロジェクト: reachmesharan/BLE
/*******************************************************************************
* Function Name: UART_DEB_Sleep
********************************************************************************
*
* Summary:
*  Prepares the component to enter Deep Sleep.
*  The "Enable wakeup from Sleep Mode" selection has an influence on
*  this function implementation.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void UART_DEB_Sleep(void)
{
#if(UART_DEB_SCB_MODE_UNCONFIG_CONST_CFG)

    if(UART_DEB_SCB_WAKE_ENABLE_CHECK)
    {
        if(UART_DEB_SCB_MODE_I2C_RUNTM_CFG)
        {
            UART_DEB_I2CSaveConfig();
        }
        else if(UART_DEB_SCB_MODE_EZI2C_RUNTM_CFG)
        {
            UART_DEB_EzI2CSaveConfig();
        }
#if(!UART_DEB_CY_SCBIP_V1)
        else if(UART_DEB_SCB_MODE_SPI_RUNTM_CFG)
        {
            UART_DEB_SpiSaveConfig();
        }
        else if(UART_DEB_SCB_MODE_UART_RUNTM_CFG)
        {
            UART_DEB_UartSaveConfig();
        }
#endif /* (!UART_DEB_CY_SCBIP_V1) */
        else
        {
            /* Unknown mode */
        }
    }
    else
    {
        UART_DEB_backup.enableState = (uint8) UART_DEB_GET_CTRL_ENABLED;

        if(0u != UART_DEB_backup.enableState)
        {
            UART_DEB_Stop();
        }
    }

#else

#if (UART_DEB_SCB_MODE_I2C_CONST_CFG && UART_DEB_I2C_WAKE_ENABLE_CONST)
    UART_DEB_I2CSaveConfig();

#elif (UART_DEB_SCB_MODE_EZI2C_CONST_CFG && UART_DEB_EZI2C_WAKE_ENABLE_CONST)
    UART_DEB_EzI2CSaveConfig();

#elif (UART_DEB_SCB_MODE_SPI_CONST_CFG && UART_DEB_SPI_WAKE_ENABLE_CONST)
    UART_DEB_SpiSaveConfig();

#elif (UART_DEB_SCB_MODE_UART_CONST_CFG && UART_DEB_UART_WAKE_ENABLE_CONST)
    UART_DEB_UartSaveConfig();

#else

    UART_DEB_backup.enableState = (uint8) UART_DEB_GET_CTRL_ENABLED;

    if(0u != UART_DEB_backup.enableState)
    {
        UART_DEB_Stop();
    }

#endif /* defined (UART_DEB_SCB_MODE_I2C_CONST_CFG) && (UART_DEB_I2C_WAKE_ENABLE_CONST) */

#endif /* (UART_DEB_SCB_MODE_UNCONFIG_CONST_CFG) */
}
コード例 #2
0
ファイル: hids.c プロジェクト: dmaone/CommonSense
/*******************************************************************************
* Function Name: HidsCallBack()
********************************************************************************
*
* Summary:
*   This is an event callback function to receive service specific events from 
*   HID Service.
*
* Parameters:
*  event - the event code
*  *eventParam - the event parameters
*
* Return:
*  None.
*
********************************************************************************/
void HidsCallBack(uint32 event, void *eventParam)
{
    CYBLE_HIDS_CHAR_VALUE_T *locEventParam = (CYBLE_HIDS_CHAR_VALUE_T *)eventParam;

    DBG_PRINTF("HIDS event: %lx, ", event);

    switch(event)
    {
        case CYBLE_EVT_HIDSS_NOTIFICATION_ENABLED:
            DBG_PRINTF("CYBLE_EVT_HIDSS_NOTIFICATION_ENABLED: serv=%x, char=%x\r\n", 
                locEventParam->serviceIndex,
                locEventParam->charIndex);
            if(CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX == locEventParam->serviceIndex)
            {
                keyboardSimulation = ENABLED;
            }
            break;
        case CYBLE_EVT_HIDSS_NOTIFICATION_DISABLED:
            DBG_PRINTF("CYBLE_EVT_HIDSS_NOTIFICATION_DISABLED: serv=%x, char=%x\r\n", 
                locEventParam->serviceIndex,
                locEventParam->charIndex);
            if(CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX == locEventParam->serviceIndex)
            {
                keyboardSimulation = DISABLED;
            }
            break;
        case CYBLE_EVT_HIDSS_BOOT_MODE_ENTER:
            DBG_PRINTF("CYBLE_EVT_HIDSS_BOOT_MODE_ENTER \r\n");
            protocol = CYBLE_HIDS_PROTOCOL_MODE_BOOT;
            break;
        case CYBLE_EVT_HIDSS_REPORT_MODE_ENTER:
            DBG_PRINTF("CYBLE_EVT_HIDSS_REPORT_MODE_ENTER \r\n");
            protocol = CYBLE_HIDS_PROTOCOL_MODE_REPORT;
            break;
        case CYBLE_EVT_HIDSS_SUSPEND:
            DBG_PRINTF("CYBLE_EVT_HIDSS_SUSPEND \r\n");
            suspend = CYBLE_HIDS_CP_SUSPEND;
        #if (DEBUG_UART_ENABLED == ENABLED)
            /* Reduce power consumption, power down logic that is not required to wake up the system */
            UART_DEB_Stop();
        #endif /* (DEBUG_UART_ENABLED == ENABLED) */
            break;
        case CYBLE_EVT_HIDSS_EXIT_SUSPEND:
        #if (DEBUG_UART_ENABLED == ENABLED)    
            /* Power up all circuitry previously shut down */
            UART_DEB_Start();
        #endif /* (DEBUG_UART_ENABLED == ENABLED) */
            DBG_PRINTF("CYBLE_EVT_HIDSS_EXIT_SUSPEND \r\n");
            suspend = CYBLE_HIDS_CP_EXIT_SUSPEND;
            break;
        case CYBLE_EVT_HIDSS_REPORT_CHAR_WRITE:
            if(CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX == locEventParam->serviceIndex)
            {
                /* Write request to Keyboard Output Report characteristic. 
                *  Handle Boot and Report protocol. 
                */
                if( ((CYBLE_HIDS_PROTOCOL_MODE_REPORT == protocol) && 
                     (CYBLE_HUMAN_INTERFACE_DEVICE_REPORT_OUT == locEventParam->charIndex)) ||
                    ((CYBLE_HIDS_PROTOCOL_MODE_BOOT == protocol) && 
                     (CYBLE_HIDS_BOOT_KYBRD_OUT_REP == locEventParam->charIndex)) )
                {
                    if( (CAPS_LOCK_LED & locEventParam->value->val[0u]) != 0u)
                    {
                        CapsLock_LED_Write(LED_ON);
                    }
                    else
                    {
                        CapsLock_LED_Write(LED_OFF);
                    }
                }
            }
            DBG_PRINTF("CYBLE_EVT_HIDSS_REPORT_CHAR_WRITE: serv=%x, char=%x, value=", 
                locEventParam->serviceIndex,
                locEventParam->charIndex);
                ShowValue(locEventParam->value);
            break;
        case CYBLE_EVT_HIDSC_NOTIFICATION:
            break;
        case CYBLE_EVT_HIDSC_READ_CHAR_RESPONSE:
            break;
        case CYBLE_EVT_HIDSC_WRITE_CHAR_RESPONSE:
            break;
        case CYBLE_EVT_HIDSC_READ_DESCR_RESPONSE:
            break;
        case CYBLE_EVT_HIDSC_WRITE_DESCR_RESPONSE:           
            break;
		default:
            DBG_PRINTF("Not supported event\r\n");
			break;
    }
}