gpio.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * File : gpio.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. */
  24. #ifndef __GPIO_H__
  25. #define __GPIO_H__
  26. #include <rtthread.h>
  27. #include <at91_aic.h>
  28. #define PIN_BASE AIC_IRQS
  29. #define MAX_GPIO_BANKS 3
  30. #define PIN_IRQS (MAX_GPIO_BANKS*32)
  31. /* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */
  32. #define AT91_PIN_PA0 (PIN_BASE + 0x00 + 0)
  33. #define AT91_PIN_PA1 (PIN_BASE + 0x00 + 1)
  34. #define AT91_PIN_PA2 (PIN_BASE + 0x00 + 2)
  35. #define AT91_PIN_PA3 (PIN_BASE + 0x00 + 3)
  36. #define AT91_PIN_PA4 (PIN_BASE + 0x00 + 4)
  37. #define AT91_PIN_PA5 (PIN_BASE + 0x00 + 5)
  38. #define AT91_PIN_PA6 (PIN_BASE + 0x00 + 6)
  39. #define AT91_PIN_PA7 (PIN_BASE + 0x00 + 7)
  40. #define AT91_PIN_PA8 (PIN_BASE + 0x00 + 8)
  41. #define AT91_PIN_PA9 (PIN_BASE + 0x00 + 9)
  42. #define AT91_PIN_PA10 (PIN_BASE + 0x00 + 10)
  43. #define AT91_PIN_PA11 (PIN_BASE + 0x00 + 11)
  44. #define AT91_PIN_PA12 (PIN_BASE + 0x00 + 12)
  45. #define AT91_PIN_PA13 (PIN_BASE + 0x00 + 13)
  46. #define AT91_PIN_PA14 (PIN_BASE + 0x00 + 14)
  47. #define AT91_PIN_PA15 (PIN_BASE + 0x00 + 15)
  48. #define AT91_PIN_PA16 (PIN_BASE + 0x00 + 16)
  49. #define AT91_PIN_PA17 (PIN_BASE + 0x00 + 17)
  50. #define AT91_PIN_PA18 (PIN_BASE + 0x00 + 18)
  51. #define AT91_PIN_PA19 (PIN_BASE + 0x00 + 19)
  52. #define AT91_PIN_PA20 (PIN_BASE + 0x00 + 20)
  53. #define AT91_PIN_PA21 (PIN_BASE + 0x00 + 21)
  54. #define AT91_PIN_PA22 (PIN_BASE + 0x00 + 22)
  55. #define AT91_PIN_PA23 (PIN_BASE + 0x00 + 23)
  56. #define AT91_PIN_PA24 (PIN_BASE + 0x00 + 24)
  57. #define AT91_PIN_PA25 (PIN_BASE + 0x00 + 25)
  58. #define AT91_PIN_PA26 (PIN_BASE + 0x00 + 26)
  59. #define AT91_PIN_PA27 (PIN_BASE + 0x00 + 27)
  60. #define AT91_PIN_PA28 (PIN_BASE + 0x00 + 28)
  61. #define AT91_PIN_PA29 (PIN_BASE + 0x00 + 29)
  62. #define AT91_PIN_PA30 (PIN_BASE + 0x00 + 30)
  63. #define AT91_PIN_PA31 (PIN_BASE + 0x00 + 31)
  64. #define AT91_PIN_PB0 (PIN_BASE + 0x20 + 0)
  65. #define AT91_PIN_PB1 (PIN_BASE + 0x20 + 1)
  66. #define AT91_PIN_PB2 (PIN_BASE + 0x20 + 2)
  67. #define AT91_PIN_PB3 (PIN_BASE + 0x20 + 3)
  68. #define AT91_PIN_PB4 (PIN_BASE + 0x20 + 4)
  69. #define AT91_PIN_PB5 (PIN_BASE + 0x20 + 5)
  70. #define AT91_PIN_PB6 (PIN_BASE + 0x20 + 6)
  71. #define AT91_PIN_PB7 (PIN_BASE + 0x20 + 7)
  72. #define AT91_PIN_PB8 (PIN_BASE + 0x20 + 8)
  73. #define AT91_PIN_PB9 (PIN_BASE + 0x20 + 9)
  74. #define AT91_PIN_PB10 (PIN_BASE + 0x20 + 10)
  75. #define AT91_PIN_PB11 (PIN_BASE + 0x20 + 11)
  76. #define AT91_PIN_PB12 (PIN_BASE + 0x20 + 12)
  77. #define AT91_PIN_PB13 (PIN_BASE + 0x20 + 13)
  78. #define AT91_PIN_PB14 (PIN_BASE + 0x20 + 14)
  79. #define AT91_PIN_PB15 (PIN_BASE + 0x20 + 15)
  80. #define AT91_PIN_PB16 (PIN_BASE + 0x20 + 16)
  81. #define AT91_PIN_PB17 (PIN_BASE + 0x20 + 17)
  82. #define AT91_PIN_PB18 (PIN_BASE + 0x20 + 18)
  83. #define AT91_PIN_PB19 (PIN_BASE + 0x20 + 19)
  84. #define AT91_PIN_PB20 (PIN_BASE + 0x20 + 20)
  85. #define AT91_PIN_PB21 (PIN_BASE + 0x20 + 21)
  86. #define AT91_PIN_PB22 (PIN_BASE + 0x20 + 22)
  87. #define AT91_PIN_PB23 (PIN_BASE + 0x20 + 23)
  88. #define AT91_PIN_PB24 (PIN_BASE + 0x20 + 24)
  89. #define AT91_PIN_PB25 (PIN_BASE + 0x20 + 25)
  90. #define AT91_PIN_PB26 (PIN_BASE + 0x20 + 26)
  91. #define AT91_PIN_PB27 (PIN_BASE + 0x20 + 27)
  92. #define AT91_PIN_PB28 (PIN_BASE + 0x20 + 28)
  93. #define AT91_PIN_PB29 (PIN_BASE + 0x20 + 29)
  94. #define AT91_PIN_PB30 (PIN_BASE + 0x20 + 30)
  95. #define AT91_PIN_PB31 (PIN_BASE + 0x20 + 31)
  96. #define AT91_PIN_PC0 (PIN_BASE + 0x40 + 0)
  97. #define AT91_PIN_PC1 (PIN_BASE + 0x40 + 1)
  98. #define AT91_PIN_PC2 (PIN_BASE + 0x40 + 2)
  99. #define AT91_PIN_PC3 (PIN_BASE + 0x40 + 3)
  100. #define AT91_PIN_PC4 (PIN_BASE + 0x40 + 4)
  101. #define AT91_PIN_PC5 (PIN_BASE + 0x40 + 5)
  102. #define AT91_PIN_PC6 (PIN_BASE + 0x40 + 6)
  103. #define AT91_PIN_PC7 (PIN_BASE + 0x40 + 7)
  104. #define AT91_PIN_PC8 (PIN_BASE + 0x40 + 8)
  105. #define AT91_PIN_PC9 (PIN_BASE + 0x40 + 9)
  106. #define AT91_PIN_PC10 (PIN_BASE + 0x40 + 10)
  107. #define AT91_PIN_PC11 (PIN_BASE + 0x40 + 11)
  108. #define AT91_PIN_PC12 (PIN_BASE + 0x40 + 12)
  109. #define AT91_PIN_PC13 (PIN_BASE + 0x40 + 13)
  110. #define AT91_PIN_PC14 (PIN_BASE + 0x40 + 14)
  111. #define AT91_PIN_PC15 (PIN_BASE + 0x40 + 15)
  112. #define AT91_PIN_PC16 (PIN_BASE + 0x40 + 16)
  113. #define AT91_PIN_PC17 (PIN_BASE + 0x40 + 17)
  114. #define AT91_PIN_PC18 (PIN_BASE + 0x40 + 18)
  115. #define AT91_PIN_PC19 (PIN_BASE + 0x40 + 19)
  116. #define AT91_PIN_PC20 (PIN_BASE + 0x40 + 20)
  117. #define AT91_PIN_PC21 (PIN_BASE + 0x40 + 21)
  118. #define AT91_PIN_PC22 (PIN_BASE + 0x40 + 22)
  119. #define AT91_PIN_PC23 (PIN_BASE + 0x40 + 23)
  120. #define AT91_PIN_PC24 (PIN_BASE + 0x40 + 24)
  121. #define AT91_PIN_PC25 (PIN_BASE + 0x40 + 25)
  122. #define AT91_PIN_PC26 (PIN_BASE + 0x40 + 26)
  123. #define AT91_PIN_PC27 (PIN_BASE + 0x40 + 27)
  124. #define AT91_PIN_PC28 (PIN_BASE + 0x40 + 28)
  125. #define AT91_PIN_PC29 (PIN_BASE + 0x40 + 29)
  126. #define AT91_PIN_PC30 (PIN_BASE + 0x40 + 30)
  127. #define AT91_PIN_PC31 (PIN_BASE + 0x40 + 31)
  128. rt_inline rt_uint32_t gpio_to_irq(rt_uint32_t gpio)
  129. {
  130. return gpio;
  131. }
  132. #endif