gpio_irq_api.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /** \addtogroup hal */
  2. /** @{*/
  3. /* mbed Microcontroller Library
  4. * Copyright (c) 2006-2013 ARM Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef MBED_GPIO_IRQ_API_H
  19. #define MBED_GPIO_IRQ_API_H
  20. #include "device.h"
  21. #if DEVICE_INTERRUPTIN
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /** GPIO IRQ events
  26. */
  27. typedef enum {
  28. IRQ_NONE,
  29. IRQ_RISE,
  30. IRQ_FALL
  31. } gpio_irq_event;
  32. /** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
  33. */
  34. typedef struct gpio_irq_s gpio_irq_t;
  35. typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
  36. /**
  37. * \defgroup hal_gpioirq GPIO IRQ HAL functions
  38. * @{
  39. */
  40. /** Initialize the GPIO IRQ pin
  41. *
  42. * @param obj The GPIO object to initialize
  43. * @param pin The GPIO pin name
  44. * @param handler The handler to be attached to GPIO IRQ
  45. * @param id The object ID (id != 0, 0 is reserved)
  46. * @return -1 if pin is NC, 0 otherwise
  47. */
  48. int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
  49. /** Release the GPIO IRQ PIN
  50. *
  51. * @param obj The gpio object
  52. */
  53. void gpio_irq_free(gpio_irq_t *obj);
  54. /** Enable/disable pin IRQ event
  55. *
  56. * @param obj The GPIO object
  57. * @param event The GPIO IRQ event
  58. * @param enable The enable flag
  59. */
  60. void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
  61. /** Enable GPIO IRQ
  62. *
  63. * This is target dependent, as it might enable the entire port or just a pin
  64. * @param obj The GPIO object
  65. */
  66. void gpio_irq_enable(gpio_irq_t *obj);
  67. /** Disable GPIO IRQ
  68. *
  69. * This is target dependent, as it might disable the entire port or just a pin
  70. * @param obj The GPIO object
  71. */
  72. void gpio_irq_disable(gpio_irq_t *obj);
  73. /**@}*/
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif
  78. #endif
  79. /** @}*/