drv_pin.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * 2018-04-12 RT-Thread the first version
  9. */
  10. #ifndef __DRV_PIN_H__
  11. #define __DRV_PIN_H__
  12. #include <hal_gpio.h>
  13. /* IO port */
  14. enum gpio_port
  15. {
  16. GPIO_PORT_RESERVED0 = 0,
  17. GPIO_PORT_B,
  18. GPIO_PORT_C,
  19. GPIO_PORT_D,
  20. GPIO_PORT_E,
  21. GPIO_PORT_F,
  22. GPIO_PORT_G,
  23. GPIO_PORT_NUM,
  24. };
  25. /* IO pin */
  26. enum gpio_pin
  27. {
  28. GPIO_PIN_0 = 0,
  29. GPIO_PIN_1,
  30. GPIO_PIN_2,
  31. GPIO_PIN_3,
  32. GPIO_PIN_4,
  33. GPIO_PIN_5,
  34. GPIO_PIN_6,
  35. GPIO_PIN_7,
  36. GPIO_PIN_8,
  37. GPIO_PIN_9,
  38. GPIO_PIN_10,
  39. GPIO_PIN_11,
  40. GPIO_PIN_12,
  41. GPIO_PIN_13,
  42. GPIO_PIN_14,
  43. GPIO_PIN_15,
  44. GPIO_PIN_16,
  45. GPIO_PIN_17,
  46. GPIO_PIN_18,
  47. GPIO_PIN_19,
  48. GPIO_PIN_20,
  49. GPIO_PIN_21,
  50. GPIO_PIN_22,
  51. GPIO_PIN_NUM,
  52. };
  53. #define HAL_GPIO(bank,num) GPIO_P##bank##num
  54. #define GET_GPIO_PORT(PIN) (PIN / 32)
  55. #define GET_GPIO_PIN(PIN) (PIN % 32)
  56. #define GET_PIN(PORTx, PIN) (rt_base_t)(32 * PORTx + PIN)
  57. #endif