api_interrupt_mgr.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. InterruptTypeTimerUpdate,
  15. InterruptTypeLast,
  16. } InterruptType;
  17. /** Interrupt callback type */
  18. typedef struct {
  19. InterruptCallback callback;
  20. void* context;
  21. bool ready;
  22. } InterruptCallbackItem;
  23. /** Init interrupt
  24. *
  25. * @return true on succsessful initialization, false otherwise
  26. */
  27. bool api_interrupt_init();
  28. /** Add interrupt
  29. *
  30. * @param callback InterruptCallback
  31. * @param type InterruptType
  32. * @param context context for callback
  33. */
  34. void api_interrupt_add(InterruptCallback callback, InterruptType type, void* context);
  35. /** Remove interrupt
  36. *
  37. * @param callback InterruptCallback
  38. * @param type InterruptType
  39. */
  40. void api_interrupt_remove(InterruptCallback callback, InterruptType type);
  41. /** Enable interrupt
  42. *
  43. * @param callback InterruptCallback
  44. * @param type InterruptType
  45. */
  46. void api_interrupt_enable(InterruptCallback callback, InterruptType type);
  47. /** Disable interrupt
  48. *
  49. * @param callback InterruptCallback
  50. * @param type InterruptType
  51. */
  52. void api_interrupt_disable(InterruptCallback callback, InterruptType type);
  53. /** Call interrupt
  54. *
  55. * @param type InterruptType
  56. * @param hw pointer to hardware peripheral
  57. */
  58. void api_interrupt_call(InterruptType type, void* hw);
  59. #ifdef __cplusplus
  60. }
  61. #endif