你好,我正在使用CY8C4045 AZI S413进行我的项目。在空闲状态机中,代码只需每500毫秒唤醒一次,并检查邻近控件。有线部分是,如果我关闭睡眠功能,系统状态机将顺利转移到ToucEdEl状态。如果我打开睡眠功能。传输状态机需要很长时间。
静态子状态MeNeIDIDLE状态(空隙){
子状态子状态= SnNO;
CAPIA Outlook编写(1);
VDDyLeDyCtRLX编写(0);
MeMSET(Word缓冲区,0,WorkBuffell长度);
BoOL ISH-BTNYROMPULTE= TRUE;
而(子状态= = sn-无){
*扫描所有小部件*/
如果(CopsSeNeNothLoad==CAPENSESEIISBYY());
CAPENSESEA SETUP WIDGET(CAPENSESEA OU
tiQUITY 0XWDGTZID);
CAPENSESEA扫描();
ISSB处理= FALSE;
}
/*如果唤醒命令从主机接收…*/
如果(Word缓冲区〔0〕=0x5a){
G.FASTHEXSCALL DELAYY计数器= FASTH扫描延迟;
GyAdvEddoxMatCHyValue= WDTTyTimeOutFASTHySCAN;
子状态= S.Mistalay-EVT;
断裂;
}
如果(CopsSeNeNothLoad==CAPENSESEIISBYY());
CAPENSESEIUPDATEWIDGETBASIC(CAPENSESEA OULIDITY 0WDGTGYID);
CAPSENSEA进程WIGGET(CAPENSESEA近邻0WDGTGID);
//If(CopsSeNeISWIDGETAcIcd(CopsSeNeRealthIy00WDGTGYID)){
如果(CopsSeNeSeNesithEnristor Actu能能能为量(CAPENSESEIONTIONITY 0WDGTGID,0))
*初始化快速扫描延迟计数器**
G.FASTHEXSCALL DELAYY计数器= FASTH扫描延迟;
GyAdvEddoxMatCHyValue= WDTTyTimeOutFASTHySCAN;
CAPIA Outlook编写(0);
子状态= SO TouChyEVT;
断裂;
}
ISSB处理=真;
}
*将CPU置于睡眠状态。当WDT中断发生时,CPU将唤醒。
并执行下一次扫描*/
(如果)= 0)
如果(子状态==Sn-无){
//CysYSPMLeSEP();
GoToScript();
}
第二节
} /*同时(子状态= = sn-无)*/
返回子状态;
}
E-LoC.CyWrk.CaseV01.Zip
674.4 K
以上来自于百度翻译
以下为原文
Hi, I am using CY8C4045AZI-S413 for my project. In IDLE state machine, the code simply wakes up every 500ms and checks for proximity widget. The wired part is if I turn off the sleep feature, system state machine will transfer smoothly to Touched_State. If I turn sleep function on. It will take a long time to transfer state machine.
static SUB_STATE main_idle_state(void){
SUB_STATE sub_state = S_NONE;
CAP_OUT_Write(1);
VDD_LED_CTRL_Write(0);
memset(WORK_BUFFER, 0, WORK_BUFFER_LENGTH);
bool is_btn_processed = true;
while(sub_state == S_NONE){
/* Scan all widgets */
if(CapSense_NOT_BUSY == CapSense_IsBusy() && is_btn_processed == true){
CapSense_SetupWidget(CapSense_PROXIMITY0_WDGT_ID);
CapSense_Scan();
is_btn_processed = false;
}
/* If a wakeup command received from master... */
if(WORK_BUFFER[0] == 0x5A){
g_fast_scan_delay_counter = FAST_SCAN_DELAY;
g_watchdog_match_value = WDT_TIMEOUT_FAST_SCAN;
sub_state = S_MASTER_EVT;
break;
}
if(CapSense_NOT_BUSY == CapSense_IsBusy() && is_btn_processed == false){
CapSense_UpdateWidgetBaseline(CapSense_PROXIMITY0_WDGT_ID);
CapSense_ProcessWidget(CapSense_PROXIMITY0_WDGT_ID);
//if(CapSense_IsWidgetActive(CapSense_PROXIMITY0_WDGT_ID)){
if(CapSense_IsProximitySensorActive(CapSense_PROXIMITY0_WDGT_ID,0)){
/* Initialize fast scan delay counter */
g_fast_scan_delay_counter = FAST_SCAN_DELAY;
g_watchdog_match_value = WDT_TIMEOUT_FAST_SCAN;
CAP_OUT_Write(0);
sub_state = S_TOUCH_EVT;
break;
}
is_btn_processed = true;
}
/* Put CPU to sleep. When the WDT interrupt occurs, CPU will wakeup
and perform the next scan */
#if (POWER_SAVE_MODE != 0)
if(sub_state == S_NONE){
//CySysPmSleep();
GotoSleep();
}
#endif
}/*while(sub_state == S_NONE)*/
return sub_state;
}
0