Motion_EC_Stm32_archived/App/Inc/th_exti.h

66 lines
1.6 KiB
C
Raw Normal View History

2021-03-10 11:03:35 +08:00
/*
* @Description:
* @Date: 2021-03-10 10:50:02
* @LastEditors: CK.Zh
2021-03-10 12:03:49 +08:00
* @LastEditTime: 2021-03-10 11:50:39
2021-03-10 11:03:35 +08:00
* @FilePath: \NaviKit_EC_stm32\App\Inc\th_button.h
*/
#ifndef __TH_BUTTON_H__
#define __TH_BUTTON_H__
#include "cmsis_os2.h"
2021-03-14 23:24:59 +08:00
//pressed time < short press time(ms)
#define SHORT_PRESS_TIME 500
//pressed time > long press time(ms)
#define LONG_PRESS_TIME 1000
//define exti flag for task-notification / thread-flags
typedef enum{
SHUTDOWN_REQ_ACTIVE = 0x01<< 0,
SHUTDOWN_REQ_INACTIVE = 0x01<< 1,
MOD_SLEEP_ACTIVE = 0x01<< 2,
MOD_SLEEP_INACTIVE = 0x01<< 3,
PWR_BTN_ACTIVE = 0x01<< 4,
PWR_BTN_INACTIVE = 0x01<< 5,
CUS_BTN_ACTIVE = 0x01<< 6,
CUS_BTN_INACTIVE = 0x01<< 7,
}Exti_Flags_t;
Exti_Flags_t Exti_Flags;
/* Definitions for ButtonDetectTask */
osThreadId_t ExtiServiceTaskHandle;
const osThreadAttr_t ExtiServiceTask_attributes;
2021-03-10 11:03:35 +08:00
//Timer
osTimerId_t PwrBtnLongPressTimerHandle;
const osTimerAttr_t PwrBtnLongPressTimer_attributes;
osTimerId_t CustBtnLongPressTimerHandle;
const osTimerAttr_t CustBtnLongPressTimer_attributes;
osTimerId_t PwrBtnShortPressTimerHandle;
const osTimerAttr_t PwrBtnShortPressTimer_attributes;
osTimerId_t CustBtnShortPressTimerHandle;
const osTimerAttr_t CustBtnShortPressTimer_attributes;
2021-03-14 23:24:59 +08:00
//Event Flag
osEventFlagsId_t ExtiEventFlags;
const osEventFlagsAttr_t ExtiEventFlags_attributes;
2021-03-10 11:03:35 +08:00
2021-03-14 23:24:59 +08:00
//Task
void StartExtiServiceTask(void *argument);
2021-03-10 11:03:35 +08:00
//callback
void PwrBtnLongPressTimerCallback(void *argument);
void CustBtnLongPressTimerCallback(void *argument);
void PwrBtnShortPressTimerCallback(void *argument);
void CustBtnShortPressTimerCallback(void *argument);
2021-03-10 12:03:49 +08:00
2021-03-10 11:03:35 +08:00
#endif