38 #define TM_BUTTON_H 100
76 #include "stm32fxxx_hal.h"
78 #include "tm_stm32_gpio.h"
79 #include "tm_stm32_delay.h"
89 #ifndef BUTTON_MAX_BUTTONS
90 #define BUTTON_MAX_BUTTONS 10
94 #ifndef BUTTON_DEBOUNCE_TIME
95 #define BUTTON_DEBOUNCE_TIME 5
99 #ifndef BUTTON_NORMAL_PRESS_TIME
100 #define BUTTON_NORMAL_PRESS_TIME 100
104 #ifndef BUTTON_LONG_PRESS_TIME
105 #define BUTTON_LONG_PRESS_TIME 1500
109 #ifndef LIB_ALLOC_FUNC
110 #define LIB_ALLOC_FUNC malloc
114 #ifndef LIB_FREE_FUNC
115 #define LIB_FREE_FUNC free
GPIO_TypeDef * GPIOx
Definition: tm_stm32_button.h:142
struct _TM_BUTTON_t TM_BUTTON_t
Button structure.
uint16_t PressNormalTime
Definition: tm_stm32_button.h:150
TM_BUTTON_t * TM_BUTTON_SetPressTime(TM_BUTTON_t *ButtonStruct, uint16_t Normal, uint16_t Long)
Sets press timing values.
void(* ButtonHandler)(struct _TM_BUTTON_t *, TM_BUTTON_PressType_t)
Definition: tm_stm32_button.h:145
Definition: tm_stm32_button.h:133
uint16_t PressDebounceTime
Definition: tm_stm32_button.h:149
TM_BUTTON_PressType_t
Button possible press types.
Definition: tm_stm32_button.h:131
void TM_BUTTON_Update(void)
Updates buttons. This function have to be called periodically.
uint8_t GPIO_State
Definition: tm_stm32_button.h:144
uint16_t GPIO_Pin
Definition: tm_stm32_button.h:143
Definition: tm_stm32_button.h:135
uint8_t LastStatus
Definition: tm_stm32_button.h:147
uint32_t StartTime
Definition: tm_stm32_button.h:146
uint8_t State
Definition: tm_stm32_button.h:148
Definition: tm_stm32_button.h:132
uint16_t PressLongTime
Definition: tm_stm32_button.h:151
Button structure.
Definition: tm_stm32_button.h:141
TM_BUTTON_t * TM_BUTTON_Init(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, uint8_t ButtonState, void(*ButtonHandler)(TM_BUTTON_t *, TM_BUTTON_PressType_t))
Initializes a new button to library.
Definition: tm_stm32_button.h:134