api_interrupt_mgr.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @file api_interrupt_mgr.h
  3. * Furi: interrupt API
  4. */
  5. #pragma once
  6. #include <stdbool.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /** Interrupt callback prototype */
  11. typedef void (*InterruptCallback)(void*, void*);
  12. /** Interupt type */
  13. typedef enum {
  14. InterruptTypeComparatorTrigger,
  15. InterruptTypeTimerUpdate,
  16. InterruptTypeLast,
  17. } InterruptType;
  18. /** Interrupt callback type */
  19. typedef struct {
  20. InterruptCallback callback;
  21. void* context;
  22. bool ready;
  23. } InterruptCallbackItem;
  24. /** Init interrupt
  25. *
  26. * @return true on succsessful initialization, false otherwise
  27. */
  28. bool api_interrupt_init();
  29. /** Add interrupt
  30. *
  31. * @param callback InterruptCallback
  32. * @param type InterruptType
  33. * @param context context for callback
  34. */
  35. void api_interrupt_add(InterruptCallback callback, InterruptType type, void* context);
  36. /** Remove interrupt
  37. *
  38. * @param callback InterruptCallback
  39. * @param type InterruptType
  40. */
  41. void api_interrupt_remove(InterruptCallback callback, InterruptType type);
  42. /** Enable interrupt
  43. *
  44. * @param callback InterruptCallback
  45. * @param type InterruptType
  46. */
  47. void api_interrupt_enable(InterruptCallback callback, InterruptType type);
  48. /** Disable interrupt
  49. *
  50. * @param callback InterruptCallback
  51. * @param type InterruptType
  52. */
  53. void api_interrupt_disable(InterruptCallback callback, InterruptType type);
  54. /** Call interrupt
  55. *
  56. * @param type InterruptType
  57. * @param hw pointer to hardware peripheral
  58. */
  59. void api_interrupt_call(InterruptType type, void* hw);
  60. #ifdef __cplusplus
  61. }
  62. #endif