drv_gpio.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-05-16 shelton first version
  9. */
  10. #ifndef __DRV_GPIO_H__
  11. #define __DRV_GPIO_H__
  12. #include <rthw.h>
  13. #include <rtdevice.h>
  14. #include "drv_common.h"
  15. #define __AT32_PORT(port) GPIO##port##_BASE
  16. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__AT32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  17. #define __AT32_PIN(index, gpio, gpio_index) \
  18. { \
  19. index, GPIO##gpio, GPIO_Pins_##gpio_index, \
  20. GPIO_PortSourceGPIO##gpio, GPIO_PinsSource##gpio_index \
  21. }
  22. #define __AT32_PIN_RESERVE \
  23. { \
  24. -1, 0, 0, 0, 0 \
  25. }
  26. /* AT32 GPIO driver */
  27. struct pin_index
  28. {
  29. int index;
  30. gpio_type *gpio_x;
  31. rt_uint32_t pin;
  32. rt_uint32_t portsource;
  33. rt_uint32_t pinsource;
  34. };
  35. struct pin_irq_map
  36. {
  37. rt_uint16_t pinbit;
  38. rt_uint16_t lineno;
  39. IRQn_Type irqno;
  40. };
  41. int rt_hw_pin_init(void);
  42. #endif /* __DRV_GPIO_H__ */