api-interrupt-mgr.h 1.5 KB

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