drv_gpio.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. * 2020-12-27 iysheng first release
  9. * 2021-09-10 ZhuXW add V85XX support
  10. */
  11. #ifndef __DRV_GPIO_H__
  12. #define __DRV_GPIO_H__
  13. #include <rtthread.h>
  14. #include <rthw.h>
  15. #include <rtdevice.h>
  16. #include <board.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define __V85XX_PORT(port) GPIO##port##_BASE
  21. #define GET_PIN(PORTx,PIN) (__V85XX_PORT(PORTx)==GPIOA_BASE) ? (rt_base_t)(0 + PIN):(rt_base_t)((16 * ( ((rt_base_t)__V85XX_PORT(PORTx) - (rt_base_t)GPIOB_BASE)/(0x0400UL) +1)) + PIN)
  22. #define PIN_NUM(port, no) (((((port) & 0xFu) << 4) | ((no) & 0xFu)))
  23. #define PIN_PORT(pin) ((uint8_t)(((pin) >> 4) & 0xFu))
  24. #define PIN_NO(pin) ((uint8_t)((pin) & 0xFu))
  25. #define PIN_V85XXPORT(pin) ((GPIO_TypeDef *)(GPIOB_BASE + (0x400u * PIN_PORT(pin))))
  26. #define PIN_V85XXPIN(pin) ((uint16_t)(1u << PIN_NO(pin)))
  27. struct pin_irq_map
  28. {
  29. rt_uint16_t pinbit;
  30. IRQn_Type irqno;
  31. };
  32. #ifdef __cplusplus
  33. }
  34. #endif
  35. #endif /* __DRV_GPIO_H__ */