📄 powerdemointhndlers.c
字号:
/*********************************************************************************
Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
This software is proprietary and confidential. By using this software you agree
to the terms of the associated Analog Devices License Agreement.
Description:
The Interrupt Handlers for the PowerDemo sample program. Both handlers are
defined according to the requirements for the Interrupt Manager.
*********************************************************************************/#include "PowerDemo.h"
#include "PowerDemo.h"
/////////////////////////
// External Variables //
/////////////////////////
extern u16 CurrentDisplay;
extern u32 CurrentPowerState;
/*********************************************************************
Function: PushButtonCallback
Description: Services the push button callbacks
***********************************************************************/
void PushButtonCallback(
void *ClientHandle,
u32 Event,
void *pArg)
{
u32 Button;
#if defined(__ADSP_EDINBURGH__)
adi_int_SICDisable(ADI_INT_PFA);
#elif defined(__ADSP_BRAEMAR__)
adi_int_SICDisable(ADI_INT_PORTFG_A);
#endif
// ClientHandle is the button that was pushed
Button = (u32)ClientHandle;
switch (Button) {
/* ***************************************************************************
* Buttons 4 & 5 test the SDRAM configuration:
* Button 4 writes to SDRAM and turns on LED 4
* Button 5 reads and validates SDRAM if already written to (i.e. LED 4 is on)
* and turns on LED 4 if successful
* ***************************************************************************/
case EZ_FIRST_BUTTON:
WriteSDRAM();
ezSetDisplay(CurrentDisplay);
ezTurnOnLED(EZ_FIRST_LED);
CurrentDisplay = ezGetDisplay();
break;
case EZ_FIRST_BUTTON + 1:
ezSetDisplay(CurrentDisplay);
if( ezIsLEDOn(EZ_FIRST_LED) && ReadSDRAM() )
ezTurnOffLED(EZ_FIRST_LED);
else
ezErrorCheck(0);
CurrentDisplay = ezGetDisplay();
break;
/* ***************************************************************************
* Button 6 Cycles down the Power Modes:
* First Press -> Active PLL enabled
* Second Press -> Active PLL disabled
* Third Press -> Sleep (awaits RTC wakeup)
* Fourth Press -> After returns from Sleep, Goes into Deep Sleep
* (also awaits RTC wakeup)
* ***************************************************************************/
case EZ_FIRST_BUTTON + 2:
TogglePowerMode();
break;
/* ***************************************************************************
* Button 7 Cycles Voltage Levels:
* ***************************************************************************/
case EZ_FIRST_BUTTON + 3:
ToggleVoltage();
break;
}
#if defined(__ADSP_EDINBURGH__)
adi_int_SICEnable(ADI_INT_PFA);
#elif defined(__ADSP_BRAEMAR__)
adi_int_SICEnable(ADI_INT_PORTFG_A);
#endif
}
/*********************************************************************
Function: RealTimeClockHandler
Description: Services the RTC Stopwatch interrupt event.
***********************************************************************/
ADI_INT_HANDLER(RealTimeClockHandler)
{
u16 tmpDisplay;
// Check to see if the RTC caused this interrupt, return if not
if ( !adi_int_SICInterruptAsserted(ADI_INT_RTC) )
return ADI_INT_RESULT_NOT_PROCESSED;
*pRTC_ISTAT = CLEAR_RTC_IRQS; // Acknowledge RTC Interrupt Request
*pRTC_SWCNT = 0x0005; // Reset Stopwatch for 5 Seconds
// Check for awake from Sleep or Deep Sleep and act accordingly
if ( CurrentPowerState==3 || CurrentPowerState==5 )
{
// Go to full-on
adi_pwr_SetPowerMode(ADI_PWR_MODE_FULL_ON);
// Blink all LED's four times to signal transition
tmpDisplay = CurrentDisplay;
CurrentDisplay = ALL_LEDS;
BlinkLEDs(4,ALL_LEDS);
CurrentDisplay = tmpDisplay;
// adjust LED's to reflect correct status
if (CurrentPowerState==3)
// simply increment state to indicate
// that next button press is to invoke Deep Sleep
CurrentPowerState++;
else {
// Access SDRAM to take it out of self-refresh
AccessSDRAM();
// Set Power State and Power Mode to the Full-on state
ezTurnOnLED(EZ_FIRST_LED+1);
ezTurnOnLED(EZ_FIRST_LED+2);
ezTurnOnLED(EZ_FIRST_LED+3);
CurrentDisplay |= ezGetDisplay();
CurrentPowerState=0;
}
}
return ADI_INT_RESULT_PROCESSED;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -