drv_gpio.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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-10-19 Nations first version
  9. */
  10. #ifndef __DRV_GPIO_H__
  11. #define __DRV_GPIO_H__
  12. #include <board.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define __N32_PORT(port) GPIO##port##_BASE
  17. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__N32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  18. #define __N32_PIN(index, gpio, gpio_pin) \
  19. { \
  20. index, gpio, gpio_pin \
  21. }
  22. #define __N32_PIN_RESERVE \
  23. { \
  24. -1, 0, 0 \
  25. }
  26. /* GPIO driver */
  27. struct pin_index
  28. {
  29. int index;
  30. GPIO_Module *gpio;
  31. uint32_t pin;
  32. };
  33. struct pin_irq_map
  34. {
  35. uint16_t pinbit;
  36. IRQn_Type irqno;
  37. };
  38. int rt_hw_pin_init(void);
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif /* __DRV_GPIO_H__ */