dev_pin_dm.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-11-26 GuEe-GUI first version
  9. */
  10. #ifndef __PIN_DM_H__
  11. #define __PIN_DM_H__
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include <rtdevice.h>
  15. /**
  16. * Bind GPIO pin to system PIN API
  17. *
  18. * @param gpio Pin device
  19. * @param pin_nr GPIO pin number
  20. *
  21. * @return RT_EOK on success, error code otherwise
  22. */
  23. rt_err_t pin_api_init(struct rt_device_pin *gpio, rt_size_t pin_nr);
  24. /**
  25. * Bind GPIO pin to system PIN PIC
  26. *
  27. * @param gpio Pin device
  28. * @param pin_irq GPIO irqno
  29. *
  30. * @return RT_EOK on success, error code otherwise
  31. */
  32. rt_err_t pin_pic_init(struct rt_device_pin *gpio, int pin_irq);
  33. /**
  34. * Handle GPIO one pin's ISR
  35. *
  36. * @param gpio Pin device
  37. * @param pin GPIO pin
  38. *
  39. * @return RT_EOK on success, error code otherwise
  40. */
  41. rt_err_t pin_pic_handle_isr(struct rt_device_pin *gpio, rt_base_t pin);
  42. #ifdef RT_USING_PINCTRL
  43. /**
  44. * Request GPIO pin configuration from pinctrl
  45. *
  46. * @param pinctrl Pinctrl device
  47. * @param gpio GPIO pin number
  48. * @param flags GPIO configuration flags
  49. *
  50. * @return RT_EOK on success, error code otherwise
  51. */
  52. rt_err_t pin_gpio_request(struct rt_device_pin *pinctrl, rt_base_t gpio, rt_uint32_t flags);
  53. #endif
  54. #endif /* __DEV_PIN_DM_H__ */