//============= 按钮任务函数,处理按钮事件 ===============
static int user_task_func(os_event_t *param)
{
switch(param->event_id)
{
case USER_EVT_BUTTON:
{
struct button_msg_t *button_msg;
								const char *button_type_str[] = {
"BUTTON_PRESSED",
"BUTTON_RELEASED",
"BUTTON_SHORT_PRESSED",
"BUTTON_MULTI_PRESSED",
"BUTTON_LONG_PRESSED",
"BUTTON_LONG_PRESSING",
"BUTTON_LONG_RELEASED",
"BUTTON_LONG_LONG_PRESSED",
"BUTTON_LONG_LONG_RELEASED",
"BUTTON_COMB_PRESSED",
"BUTTON_COMB_RELEASED",
"BUTTON_COMB_SHORT_PRESSED",
"BUTTON_COMB_LONG_PRESSED",
"BUTTON_COMB_LONG_PRESSING",
"BUTTON_COMB_LONG_RELEASED",
"BUTTON_COMB_LONG_LONG_PRESSED",
"BUTTON_COMB_LONG_LONG_RELEASED",
};
button_msg = (struct button_msg_t *)param->param;
//								co_printf("KEY 0x%08x, TYPE %s.\r\n", button_msg->button_index, button_type_str[button_msg->button_type]);
							if(button_msg->button_type == BUTTON_PRESSED)		//短按按钮
							{
									//if(button_msg->button_index == GPIO_PD4 )					//Key1
									{
											co_printf("K2 Peleased A1\r\n");			Key_Num = 2;
									}
							}
							else 
									if(button_msg->button_type == BUTTON_LONG_PRESSING)			//长按按钮3S
//										if(button_msg->button_type == BUTTON_LONG_RELEASED)			//长按后释放3S
									{
											//if(button_msg->button_index == GPIO_PD4 )
											{
													co_printf("K1 BUTTON_LONG_PRESSING 5\r\n");		Key_Num = 5;
													Power_OFF_After();					//关机前需要做的事
													system_power_off(0xc6);			//进入关机模式,电流2uA;
	//												system_sleep_enable();			//进入休眠;
											}
									}
        }
        break;
}
return EVT_CONSUMED;
}
GPIO初始化时如下配置:
	//---------按键初始化 按钮 PD4 ---------
		pmu_set_pin_dir(GPIO_PORT_D, BIT(4),GPIO_DIR_IN);
		pmu_port_wakeup_func_set(GPIO_PD4);		//使能低功耗唤醒
		button_init(GPIO_PD4);
