input_i.h 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "input.h"
  3. #include <FreeRTOS.h>
  4. #include <timers.h>
  5. #include <stdbool.h>
  6. #include <stdint.h>
  7. #include <stdio.h>
  8. #include <furi.h>
  9. #include <cli/cli.h>
  10. #include <m-string.h>
  11. #include <api-hal-gpio.h>
  12. #define INPUT_DEBOUNCE_TICKS_HALF (INPUT_DEBOUNCE_TICKS / 2)
  13. #define INPUT_PRESS_TICKS 150
  14. #define INPUT_LONG_PRESS_COUNTS 2
  15. #define INPUT_THREAD_FLAG_ISR 0x00000001
  16. /* Input pin state */
  17. typedef struct {
  18. const InputPin* pin;
  19. // State
  20. volatile bool state;
  21. volatile uint8_t debounce;
  22. volatile osTimerId_t press_timer;
  23. volatile uint8_t press_counter;
  24. } InputPinState;
  25. /* Input state */
  26. typedef struct {
  27. osThreadId_t thread;
  28. PubSub event_pubsub;
  29. InputPinState* pin_states;
  30. Cli* cli;
  31. } Input;
  32. /* Input press timer callback */
  33. void input_press_timer_callback(void* arg);
  34. /* Input interrupt handler */
  35. void input_isr(void* _ctx);