drv_gpio.h 1.2 KB

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