drv_gpio.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-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_REG_GPFSEL0(BASE) HWREG32(BASE + 0x00)
  17. #define GPIO_REG_GPFSEL1(BASE) HWREG32(BASE + 0x04)
  18. #define GPIO_REG_GPFSEL2(BASE) HWREG32(BASE + 0x08)
  19. #define GPIO_REG_GPFSEL3(BASE) HWREG32(BASE + 0x0C)
  20. #define GPIO_REG_GPFSEL4(BASE) HWREG32(BASE + 0x10)
  21. #define GPIO_REG_GPFSEL5(BASE) HWREG32(BASE + 0x14)
  22. #define GPIO_REG_REV0(BASE) HWREG32(BASE + 0x18)
  23. #define GPIO_REG_GPSET0(BASE) HWREG32(BASE + 0x1C)
  24. #define GPIO_REG_GPSET1(BASE) HWREG32(BASE + 0x20)
  25. #define GPIO_REG_REV1(BASE) HWREG32(BASE + 0x24)
  26. #define GPIO_REG_GPCLR0(BASE) HWREG32(BASE + 0x28)
  27. #define GPIO_REG_GPCLR1(BASE) HWREG32(BASE + 0x2C)
  28. #define GPIO_REG_REV2(BASE) HWREG32(BASE + 0x30)
  29. #define GPIO_REG_GPLEV0(BASE) HWREG32(BASE + 0x34)
  30. #define GPIO_REG_GPLEV1(BASE) HWREG32(BASE + 0x38)
  31. #define GPIO_REG_REV3(BASE) HWREG32(BASE + 0x3C)
  32. #define GPIO_REG_GPEDS0(BASE) HWREG32(BASE + 0x40)
  33. #define GPIO_REG_GPEDS1(BASE) HWREG32(BASE + 0x44)
  34. #define GPIO_REG_REV4(BASE) HWREG32(BASE + 0x48)
  35. #define GPIO_REG_GPREN0(BASE) HWREG32(BASE + 0x4C)
  36. #define GPIO_REG_GPREN1(BASE) HWREG32(BASE + 0x50)
  37. #define GPIO_REG_REV5(BASE) HWREG32(BASE + 0x54)
  38. #define GPIO_REG_GPFEN0(BASE) HWREG32(BASE + 0x58)
  39. #define GPIO_REG_GPFEN1(BASE) HWREG32(BASE + 0x5C)
  40. #define GPIO_REG_REV6(BASE) HWREG32(BASE + 0x60)
  41. #define GPIO_REG_GPHEN0(BASE) HWREG32(BASE + 0x64)
  42. #define GPIO_REG_GPHEN1(BASE) HWREG32(BASE + 0x68)
  43. #define GPIO_REG_REV7(BASE) HWREG32(BASE + 0x6C)
  44. #define GPIO_REG_GPLEN0(BASE) HWREG32(BASE + 0x70)
  45. #define GPIO_REG_GPLEN1(BASE) HWREG32(BASE + 0x74)
  46. #define GPIO_REG_REV8(BASE) HWREG32(BASE + 0x78)
  47. #define GPIO_REG_GPAREN0(BASE) HWREG32(BASE + 0x7C)
  48. #define GPIO_REG_GPAREN1(BASE) HWREG32(BASE + 0x80)
  49. #define GPIO_REG_REV11(BASE) HWREG32(BASE + 0x84)
  50. #define GPIO_REG_GPAFEN0(BASE) HWREG32(BASE + 0x88)
  51. #define GPIO_REG_GPAFEN1(BASE) HWREG32(BASE + 0x8C)
  52. #define GPIO_REG_REV10(BASE) HWREG32(BASE + 0x90)
  53. #define GPIO_REG_GPPUD(BASE) HWREG32(BASE + 0x94)
  54. #define GPIO_REG_GPPUDCLK0(BASE) HWREG32(BASE + 0x98)
  55. #define GPIO_REG_GPPUDCLK1(BASE) HWREG32(BASE + 0x9C)
  56. #define GPIO_REG_REV9(BASE) HWREG32(BASE + 0xA0)
  57. #define GPIO_REG_TEST(BASE) HWREG32(BASE + 0xA4)
  58. typedef enum {
  59. INPUT = 0b000,
  60. OUTPUT = 0b001,
  61. ALT0 = 0b100,
  62. ALT1 = 0b101,
  63. ALT2 = 0b110,
  64. ALT3 = 0b111,
  65. ALT4 = 0b011,
  66. ALT5 = 0b010
  67. } GPIO_FUNC;
  68. int rt_hw_gpio_init(void);
  69. #endif /* __DRV_GPIO_H__ */