Пример #1
0
/**************************************************************************************************
 * @fn          SysCtrlWakeupSetting
 *
 * @brief       Setup which peripherals can/cannot wakeup the processor
 *
 * input parameters
 *
 * @param       None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void SysCtrlWakeupSetting(void)
{ 
  /* GPIO A, C and SM Timer can wake up the processor */
  GPIOIntWakeupEnable(GPIO_IWE_PORT_A);
  GPIOIntWakeupDisable(GPIO_IWE_PORT_B);
  GPIOIntWakeupEnable(GPIO_IWE_PORT_C);
  GPIOIntWakeupDisable(GPIO_IWE_PORT_D);
  GPIOIntWakeupDisable(GPIO_IWE_USB);
  GPIOIntWakeupEnable(GPIO_IWE_SM_TIMER);
  
  /* Setup GPIO A, C as a falling edge  */
  GPIOPowIntTypeSet(BSP_KEY_DIR_BASE, BSP_KEY_LEFT | BSP_KEY_RIGHT | 
                    BSP_KEY_UP | BSP_KEY_DOWN, GPIO_POW_FALLING_EDGE);
  GPIOPowIntTypeSet(BSP_KEY_SEL_BASE, BSP_KEY_SELECT, GPIO_POW_FALLING_EDGE);
  
}
Пример #2
0
/**************************************************************************************************
 * @fn          SysCtrlWakeupSetting
 *
 * @brief       Setup which peripherals can/cannot wakeup the processor
 *
 * input parameters
 *
 * @param       None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void SysCtrlWakeupSetting(void)
{ 
  /* GPIO A, C and SM Timer can wake up the processor */
  /* CS */
  GPIOIntWakeupDisable(GPIO_IWE_PORT_A);
  /* MRDY */
  GPIOIntWakeupEnable(GPIO_IWE_PORT_B);
  /* Sleep Timer */
  GPIOIntWakeupEnable(GPIO_IWE_SM_TIMER);
  /* USB */
  GPIOIntWakeupEnable(GPIO_IWE_USB);
  /* Setup MRDY as falling edge  */
  GPIOPowIntTypeSet(GPIO_B_BASE, GPIO_PIN_2, GPIO_POW_FALLING_EDGE);
  
}
void zclEnergyHarvester_Init( byte task_id ) {
  zclEnergyHarvester_TaskID = task_id;

  // This app is part of the Home Automation Profile
  zclHA_Init( &zclSampleLight_SimpleDesc );

  // Register for a test endpoint
  afRegister( &testEp );
  
  zcl_registerPlugin( ZCL_CLUSTER_ID_MS_ILLUMINANCE_MEASUREMENT,
    ZCL_CLUSTER_ID_MS_ALL,
    zclEnergyHarvester_HdlIncoming );
  
  ZDO_RegisterForZDOMsg( zclEnergyHarvester_TaskID, End_Device_Bind_rsp );
  
#if DEV_TYPE == COORDINATOR
  ZDO_RegisterForZDOMsg( zclEnergyHarvester_TaskID, Device_annce );
#else
  adc_Init();
  
  // Configure signal from off-chip timer to be wake-up signal
  GPIODirModeSet( GPIO_B_BASE, GPIO_PIN_3 , GPIO_DIR_MODE_IN );
  
  // Configure deep sleep in power mode 3, woken up by off-chip timer
  SysCtrlDeepSleepSetting();
  SysCtrlPowerModeSet( SYS_CTRL_PM_3 );
  GPIODirModeSet( GPIO_B_BASE, GPIO_PIN_4 , GPIO_DIR_MODE_IN );
  HWREG( SYS_CTRL_IWE ) = 0x02;
  GPIOPowIntTypeSet( GPIO_B_BASE, GPIO_PIN_4, GPIO_POW_RISING_EDGE );
  GPIOPowIntClear( GPIO_B_BASE, GPIO_PIN_4 );
  GPIOPowIntEnable( GPIO_B_BASE, GPIO_PIN_4 );
  
  // Done with off-chip timer acknowledge
  GPIOPinWrite( GPIO_B_BASE, GPIO_PIN_5, GPIO_PIN_5 );
#endif
}
Пример #4
0
//
// Application entry point
//
int main(void)
{
    KEYBOARD_IN_REPORT keybReport;
    uint8_t keybReportSendReq = false;
    uint8_t currKey = 0x00;

    //
    // Initialize board and system clock
    //
    bspInit(SYS_CTRL_32MHZ);

    //
    // Enable the USB interface
    //
    usbHidInit();

    //
    // Initialize GPIO pins for keyboard LEDs (LED 1 on PC0 is used by USB to
    // control D+ pull-up)
    //
    GPIOPinTypeGPIOOutput(BSP_LED_BASE, BSP_LED_2 | BSP_LED_3 | BSP_LED_4);

    //
    // Configure interrupt with wakeup for all buttons
    //
    IntRegister(INT_GPIOA, selKeyRemoteWakeupIsr);
    GPIOPowIntTypeSet(BSP_KEY_SEL_BASE, BSP_KEY_SELECT, GPIO_POW_RISING_EDGE);
    IntRegister(INT_GPIOC, dirKeyRemoteWakeupIsr);
    GPIOPowIntTypeSet(BSP_KEY_DIR_BASE, BSP_KEY_DIR_ALL, GPIO_POW_RISING_EDGE);

    //
    // Initialize button polling for keyboard HID reports
    //
    memset(&keybReport, 0x00, sizeof(KEYBOARD_IN_REPORT));

    //
    // Main loop
    //
    while (1)
    {

        //
        // Process USB events
        //
        usbHidProcessEvents();

        //
        // Generate keyboard input
        //
        if (!keybReportSendReq)
        {
            switch (bspKeyPushed(BSP_KEY_ALL))
            {
            case BSP_KEY_LEFT:
                currKey = 0x50;
                break;
            case BSP_KEY_RIGHT:
                currKey = 0x4F;
                break;
            case BSP_KEY_UP:
                currKey = 0x52;
                break;
            case BSP_KEY_DOWN:
                currKey = 0x51;
                break;
            case BSP_KEY_SELECT:
                currKey = 0x28;
                break;
            default:
                currKey = 0x00;
                break;
            }
            if (currKey != keybReport.pKeyCodes[0])
            {
                keybReport.pKeyCodes[0] = currKey;
                hidUpdateKeyboardInReport(&keybReport);
                keybReportSendReq = true;
            }
        }
        if (keybReportSendReq)
        {
            if (hidSendKeyboardInReport())
            {
                keybReportSendReq = false;
            }
        }
    }

}