drv_gpio.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-04-16 bigmagic first version
  9. */
  10. #ifndef __DRV_GPIO_H__
  11. #define __DRV_GPIO_H__
  12. #include <rtthread.h>
  13. #include <rtdevice.h>
  14. #include "board.h"
  15. #include "interrupt.h"
  16. #define GPIO_BASE (0xFE000000 + 0x00200000)
  17. #define GPIO_REG_GPFSEL0(BASE) HWREG32(BASE + 0x00)
  18. #define GPIO_REG_GPFSEL1(BASE) HWREG32(BASE + 0x04)
  19. #define GPIO_REG_GPFSEL2(BASE) HWREG32(BASE + 0x08)
  20. #define GPIO_REG_GPFSEL3(BASE) HWREG32(BASE + 0x0C)
  21. #define GPIO_REG_GPFSEL4(BASE) HWREG32(BASE + 0x10)
  22. #define GPIO_REG_GPFSEL5(BASE) HWREG32(BASE + 0x14)
  23. #define GPIO_REG_REV0(BASE) HWREG32(BASE + 0x18)
  24. #define GPIO_REG_GPSET0(BASE) HWREG32(BASE + 0x1C)
  25. #define GPIO_REG_GPSET1(BASE) HWREG32(BASE + 0x20)
  26. #define GPIO_REG_REV1(BASE) HWREG32(BASE + 0x24)
  27. #define GPIO_REG_GPCLR0(BASE) HWREG32(BASE + 0x28)
  28. #define GPIO_REG_GPCLR1(BASE) HWREG32(BASE + 0x2C)
  29. #define GPIO_REG_REV2(BASE) HWREG32(BASE + 0x30)
  30. #define GPIO_REG_GPLEV0(BASE) HWREG32(BASE + 0x34)
  31. #define GPIO_REG_GPLEV1(BASE) HWREG32(BASE + 0x38)
  32. #define GPIO_REG_REV3(BASE) HWREG32(BASE + 0x3C)
  33. #define GPIO_REG_GPEDS0(BASE) HWREG32(BASE + 0x40)
  34. #define GPIO_REG_GPEDS1(BASE) HWREG32(BASE + 0x44)
  35. #define GPIO_REG_REV4(BASE) HWREG32(BASE + 0x48)
  36. #define GPIO_REG_GPREN0(BASE) HWREG32(BASE + 0x4C)
  37. #define GPIO_REG_GPREN1(BASE) HWREG32(BASE + 0x50)
  38. #define GPIO_REG_REV5(BASE) HWREG32(BASE + 0x54)
  39. #define GPIO_REG_GPFEN0(BASE) HWREG32(BASE + 0x58)
  40. #define GPIO_REG_GPFEN1(BASE) HWREG32(BASE + 0x5C)
  41. #define GPIO_REG_REV6(BASE) HWREG32(BASE + 0x60)
  42. #define GPIO_REG_GPHEN0(BASE) HWREG32(BASE + 0x64)
  43. #define GPIO_REG_GPHEN1(BASE) HWREG32(BASE + 0x68)
  44. #define GPIO_REG_REV7(BASE) HWREG32(BASE + 0x6C)
  45. #define GPIO_REG_GPLEN0(BASE) HWREG32(BASE + 0x70)
  46. #define GPIO_REG_GPLEN1(BASE) HWREG32(BASE + 0x74)
  47. #define GPIO_REG_REV8(BASE) HWREG32(BASE + 0x78)
  48. #define GPIO_REG_GPAREN0(BASE) HWREG32(BASE + 0x7C)
  49. #define GPIO_REG_GPAREN1(BASE) HWREG32(BASE + 0x80)
  50. #define GPIO_REG_REV11(BASE) HWREG32(BASE + 0x84)
  51. #define GPIO_REG_GPAFEN0(BASE) HWREG32(BASE + 0x88)
  52. #define GPIO_REG_GPAFEN1(BASE) HWREG32(BASE + 0x8C)
  53. #define GPIO_REG_REV10(BASE) HWREG32(BASE + 0x90)
  54. #define GPIO_REG_GPPUD(BASE) HWREG32(BASE + 0x94)
  55. #define GPIO_REG_GPPUDCLK0(BASE) HWREG32(BASE + 0x98)
  56. #define GPIO_REG_GPPUDCLK1(BASE) HWREG32(BASE + 0x9C)
  57. #define GPIO_REG_REV9(BASE) HWREG32(BASE + 0xA0)
  58. #define GPIO_REG_TEST(BASE) HWREG32(BASE + 0xA4)
  59. typedef enum {
  60. INPUT = 0b000,
  61. OUTPUT = 0b001,
  62. ALT0 = 0b100,
  63. ALT1 = 0b101,
  64. ALT2 = 0b110,
  65. ALT3 = 0b111,
  66. ALT4 = 0b011,
  67. ALT5 = 0b010
  68. } GPIO_FUNC;
  69. int rt_hw_gpio_init(void);
  70. #endif /* __DRV_GPIO_H__ */