/* * btn.h */ #ifndef USER_SRC_BTN_H_ #define USER_SRC_BTN_H_ #include #define BTN_COUNT 5 #define BTN_DEBOUNCE (24 / 4) // debounce time in ~4ms increments #define BTN_PORT GPIOB #define BTN1_PIN 10 #define BTN2_PIN 11 #define DIP1_PIN 12 #define DIP2_PIN 13 #define DIP3_PIN 14 #define BTN_PIN_MASK 0xf #define BTN_PUSH (1 << 0) #define BTN_HOLD (1 << 1) #define BTN_RELEASE (1 << 2) #define BTN_IGNORE (1 << 3) typedef struct Btn { uint8_t _pintype; uint8_t _mask; uint16_t _count; // held counts uint16_t hold; // initial hold uint16_t repeat; // repeated hold void (*cb_push)(uint8_t); void (*cb_hold)(uint8_t); void (*cb_release)(uint8_t); } Btn; extern struct Btn btn[BTN_COUNT]; void btn_init(); void btn_poll(); #endif /* USER_SRC_BTN_H_ */