input_i.h 715 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "input.h"
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. #include <furi.h>
  7. #define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2)
  8. #define INPUT_LONG_PRESS_TICKS 2048
  9. #define INPUT_THREAD_FLAG_ISR 0x00000001
  10. /* Input pin state */
  11. typedef struct {
  12. const InputPin* pin;
  13. // State
  14. volatile bool state;
  15. volatile uint8_t debounce;
  16. volatile osTimerId_t press_timer;
  17. } InputPinState;
  18. /* Input state */
  19. typedef struct {
  20. osThreadId_t thread;
  21. PubSub event_pubsub;
  22. InputPinState* pin_states;
  23. } Input;
  24. /* Input press timer callback */
  25. void input_press_timer_callback(void* arg);
  26. /* Input interrupt handler */
  27. void input_isr(void* _pin, void* _ctx);