api-interrupt-mgr.h 1.4 KB

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