api-interrupt-mgr.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. InterruptTypeTimerCapture,
  12. InterruptTypeTimerOutputCompare,
  13. InterruptTypeTimerUpdate,
  14. InterruptTypeExternalInterrupt,
  15. } InterruptType;
  16. /** Interrupt callback type */
  17. typedef struct {
  18. InterruptCallback callback;
  19. InterruptType type;
  20. void* context;
  21. bool ready;
  22. } InterruptCallbackItem;
  23. /**
  24. * Init interrupt
  25. * @return true on succsessful initialization, false otherwise
  26. */
  27. bool api_interrupt_init();
  28. /**
  29. * Add interrupt
  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. /**
  36. * Remove interrupt
  37. * @param callback InterruptCallback
  38. * @param type InterruptType
  39. */
  40. void api_interrupt_remove(InterruptCallback callback, InterruptType type);
  41. /**
  42. * Enable interrupt
  43. * @param callback InterruptCallback
  44. * @param type InterruptType
  45. */
  46. void api_interrupt_enable(InterruptCallback callback, InterruptType type);
  47. /**
  48. * Disable interrupt
  49. * @param callback InterruptCallback
  50. * @param type InterruptType
  51. */
  52. void api_interrupt_disable(InterruptCallback callback, InterruptType type);
  53. /**
  54. * Call interrupt
  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