sam0_eic.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2019 Derek Hageman <hageman@inthat.cloud>
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_SAM0_EIC_H_
  7. #define ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_SAM0_EIC_H_
  8. #include <zephyr/types.h>
  9. /* callback for EIC interrupt */
  10. typedef void (*sam0_eic_callback_t)(uint32_t pins, void *data);
  11. /**
  12. * @brief EIC trigger condition
  13. */
  14. enum sam0_eic_trigger {
  15. /* Rising edge */
  16. SAM0_EIC_RISING,
  17. /* Falling edge */
  18. SAM0_EIC_FALLING,
  19. /* Both edges */
  20. SAM0_EIC_BOTH,
  21. /* High level detection */
  22. SAM0_EIC_HIGH,
  23. /* Low level detection */
  24. SAM0_EIC_LOW,
  25. };
  26. /**
  27. * @brief Acquire an EIC interrupt for specific port and pin combination
  28. *
  29. * This acquires the EIC interrupt for a specific port and pin combination,
  30. * or returns an error if the required line is not available. Only a single
  31. * callback per port is supported and supplying a different one will
  32. * change it for all lines on that port.
  33. *
  34. * @param port port index (A=0, etc)
  35. * @param pin pin in the port
  36. * @param trigger trigger condition
  37. * @param filter enable filter
  38. * @param cb interrupt callback
  39. * @param data parameter to the interrupt callback
  40. */
  41. int sam0_eic_acquire(int port, int pin, enum sam0_eic_trigger trigger,
  42. bool filter, sam0_eic_callback_t cb, void *data);
  43. /**
  44. * @brief Release the EIC interrupt for a specific port and pin combination
  45. *
  46. * Release the EIC configuration for a specific port and pin combination.
  47. * No effect if that combination does not currently hold the associated
  48. * EIC line.
  49. *
  50. * @param port port index (A=0, etc)
  51. * @param pin pin in the port
  52. */
  53. int sam0_eic_release(int port, int pin);
  54. /**
  55. * @brief Enable the EIC interrupt for a specific port and pin combination
  56. *
  57. * @param port port index (A=0, etc)
  58. * @param pin pin in the port
  59. */
  60. int sam0_eic_enable_interrupt(int port, int pin);
  61. /**
  62. * @brief Disable the EIC interrupt for a specific port and pin combination
  63. *
  64. * @param port port index (A=0, etc)
  65. * @param pin pin in the port
  66. */
  67. int sam0_eic_disable_interrupt(int port, int pin);
  68. /**
  69. * @brief Test if there is an EIC interrupt pending for a port
  70. *
  71. * @param port port index (A=0, etc)
  72. */
  73. uint32_t sam0_eic_interrupt_pending(int port);
  74. #endif /* ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_SAM0_EIC_H_ */