key.h
989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* key.h
*
* Created on: Oct 28, 2019
* Author: Hope
*/
#ifndef INC_HARDWARE_KEY_H_
#define INC_HARDWARE_KEY_H_
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f0xx_hal_gpio.h"
/* key scan defines --------------------------------------------------------*/
#define KEY1_read() HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin)
#define KEY2_read() HAL_GPIO_ReadPin(KEY2_GPIO_Port, KEY2_Pin)
#define KEY1_UP 1
#define KEY1_DOWN !KEY1_UP
#define KEY2_UP 0
#define KEY2_DOWN !KEY2_UP
#define KEY1 1
#define KEY2 2
#define KEY_CONTINUE_TRIGGLE_MODE 1
#define KEY_UNCONTINUE_TRIGGLE_MODE 0
#define KEY_PRESS_0_5S 1
#define KEY_PRESS_5_10S 2
#define KEY_PRESS_10_15S 3
#define KEY_PRESS_UP_15S 4
/* Exported functions --------------------------------------------------------*/
extern uint8_t KEY_Scan(uint8_t mode);
#endif /* INC_HARDWARE_KEY_H_ */