drv_gpio.h 699 B

1234567891011121314151617181920212223242526272829303132333435363738
  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-08-25 liYony first version
  9. */
  10. #ifndef __DRV_GPIO_H__
  11. #define __DRV_GPIO_H__
  12. #include <board.h>
  13. #include <rtthread.h>
  14. #include "rtdevice.h"
  15. #include <rthw.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define __CH32_PORT(port) GPIO##port##_BASE
  20. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__CH32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  21. struct pin_irq_map
  22. {
  23. rt_uint16_t pinbit;
  24. IRQn_Type irqno;
  25. };
  26. int rt_hw_pin_init(void);
  27. #ifdef __cplusplus
  28. }
  29. #endif
  30. #endif /* __DRV_GPIO_H__ */