api-interrupt-mgr.h 1.5 KB

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