button(Key)
Global variable
| Global variable | type | Annotation |
|---|---|---|
| g_key1_long_press | uint16_t | The long press of the record button 1 |
Macro definition
| Macro definition | value | Annotation |
|---|---|---|
| KEY1_GPIO_PORT | GPIOA | GPIO port of keys 1 |
| KEY1_GPIO_PIN | GPIO_Pin_8 | GPIO pin of keys 1 |
| KEY1_GPIO_CLK | RCC_APB2Periph_GPIOA | GPIO clock with keys 1 |
| KEY_PRESS | 1 | The button is pressed |
| KEY_RELEASE | 0 | The keys are loosened |
| KEY_MODE_ONE_TIME | 1 | Press 1 back 1 |
| KEY_MODE_ALWAYS | 0 | Continue pressing back 1 |
method
Key_Scan(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Scan button state
| parameter | type | Annotation |
|---|---|---|
| GPIOx | GPIO_TypeDef* | GPIO port |
| GPIO_Pin | uint16_t | GPIO pin |
| Return value | type |
|---|---|
| Keys | uint8_t |
Key1_GPIO_Init(void)
GPIO of initialization button 1
| Return value | type |
|---|---|
| none | void |
KEYAll_GPIO_Init(void)
GPIO of all keys
| Return value | type |
|---|---|
| none | void |
Key1_State(uint8_t mode)
Read the state of the button K1
| parameter | type | Annotation |
|---|---|---|
| mode | uint8_t | Setting mode, 0: Continue pressing 1, 1: Press only once 1 |
| Return value | type |
|---|---|
| Keys | uint8_t |
Key1_Long_Press(uint16_t timeout)
Read the long press status of the button K1
| parameter | type | Annotation |
|---|---|---|
| timeout | uint16_t | Long press time, the unit is second |
| Return value | type |
|---|---|
| 1: Long pressing state, 0: not reached | uint8_t |
Key1_is_Press(void)
Determine whether the button is pressed
| Return value | type |
|---|---|
| Key_press: Press, key_release: loose | uint8_t |