button(Key)

Global variable

Global variabletypeAnnotation
g_key1_long_pressuint16_tThe long press of the record button 1

Macro definition

Macro definitionvalueAnnotation
KEY1_GPIO_PORTGPIOAGPIO port of keys 1
KEY1_GPIO_PINGPIO_Pin_8GPIO pin of keys 1
KEY1_GPIO_CLKRCC_APB2Periph_GPIOAGPIO clock with keys 1
KEY_PRESS1The button is pressed
KEY_RELEASE0The keys are loosened
KEY_MODE_ONE_TIME1Press 1 back 1
KEY_MODE_ALWAYS0Continue pressing back 1

method

Key_Scan(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)

Scan button state

parametertypeAnnotation
GPIOxGPIO_TypeDef*GPIO port
GPIO_Pinuint16_tGPIO pin
Return valuetype
Keysuint8_t

Key1_GPIO_Init(void)

GPIO of initialization button 1

Return valuetype
nonevoid

KEYAll_GPIO_Init(void)

GPIO of all keys

Return valuetype
nonevoid

Key1_State(uint8_t mode)

Read the state of the button K1

parametertypeAnnotation
modeuint8_tSetting mode, 0: Continue pressing 1, 1: Press only once 1
Return valuetype
Keysuint8_t

Key1_Long_Press(uint16_t timeout)

Read the long press status of the button K1

parametertypeAnnotation
timeoutuint16_tLong press time, the unit is second
Return valuetype
1: Long pressing state, 0: not reacheduint8_t

Key1_is_Press(void)

Determine whether the button is pressed

Return valuetype
Key_press: Press, key_release: looseuint8_t