Input handling and debouncing (#148)
* Add input driver and definitions for target_f2 * Add input_dump example * Invert charge input * Fix back and left button configuration * remove input debug * input testing case * move header * lint code Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
29
target_f2/Inc/input_priv.h
Normal file
29
target_f2/Inc/input_priv.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef __INPUT_PRIV_H
|
||||
#define __INPUT_PRIV_H
|
||||
|
||||
#include "main.h"
|
||||
#include "flipper_hal.h"
|
||||
|
||||
#define DEBOUNCE_TICKS 10
|
||||
|
||||
const GpioPin input_gpio[] = {
|
||||
{BUTTON_UP_GPIO_Port, BUTTON_UP_Pin},
|
||||
{BUTTON_DOWN_GPIO_Port, BUTTON_DOWN_Pin},
|
||||
{BUTTON_RIGHT_GPIO_Port, BUTTON_RIGHT_Pin},
|
||||
{BUTTON_LEFT_GPIO_Port, BUTTON_LEFT_Pin},
|
||||
{BUTTON_OK_GPIO_Port, BUTTON_OK_Pin},
|
||||
{BUTTON_BACK_GPIO_Port, BUTTON_BACK_Pin},
|
||||
{CHRG_GPIO_Port, CHRG_Pin}
|
||||
};
|
||||
|
||||
const bool input_invert[] = {
|
||||
false, // {BUTTON_UP_GPIO_Port, BUTTON_UP_Pin},
|
||||
false, // {BUTTON_DOWN_GPIO_Port, BUTTON_DOWN_Pin},
|
||||
false, // {BUTTON_RIGHT_GPIO_Port, BUTTON_RIGHT_Pin},
|
||||
false, // {BUTTON_LEFT_GPIO_Port, BUTTON_LEFT_Pin},
|
||||
false, // {BUTTON_OK_GPIO_Port, BUTTON_OK_Pin},
|
||||
false, // {BUTTON_BACK_GPIO_Port, BUTTON_BACK_Pin},
|
||||
true, // {CHRG_GPIO_Port, CHRG_Pin}
|
||||
};
|
||||
|
||||
#endif /* __INPUT_PRIV_H */
|
@@ -66,6 +66,7 @@ void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_ev
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define BUTTON_BACK_Pin GPIO_PIN_13
|
||||
#define BUTTON_BACK_GPIO_Port GPIOC
|
||||
#define BUTTON_BACK_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define CHRG_Pin GPIO_PIN_2
|
||||
#define CHRG_GPIO_Port GPIOC
|
||||
#define CHRG_EXTI_IRQn EXTI2_IRQn
|
||||
|
@@ -59,6 +59,7 @@ void EXTI1_IRQHandler(void);
|
||||
void EXTI2_IRQHandler(void);
|
||||
void EXTI4_IRQHandler(void);
|
||||
void EXTI9_5_IRQHandler(void);
|
||||
void EXTI15_10_IRQHandler(void);
|
||||
void TIM8_CC_IRQHandler(void);
|
||||
void OTG_FS_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
Reference in New Issue
Block a user