input_i.h 1009 B

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