gpio_mcf5225x.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright 2012 by Embedded Technologies s.r.o
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. */
  32. #ifndef _DEV_GPIO_H_
  33. #error "Do not include this file directly. Use dev/gpio.h instead!"
  34. #endif
  35. /*
  36. * GPIO PortPins Initialization
  37. */
  38. #include "gpio_mcf5225x_i2c0.h"
  39. #include "gpio_mcf5225x_i2c1.h"
  40. #include "gpio_mcf5225x_uart0.h"
  41. #include "gpio_mcf5225x_uart1.h"
  42. #include "gpio_mcf5225x_uart2.h"
  43. /*
  44. * GPIO Port Definitions
  45. */
  46. #define PORTTE 0
  47. #define PORTTF 1
  48. #define PORTTG 2
  49. #define PORTTH 3
  50. #define PORTTI 4
  51. #define PORTTJ 6
  52. #define PORTNQ 8
  53. #define PORTAN 10
  54. #define PORTAS 11
  55. #define PORTQS 12
  56. #define PORTTA 14
  57. #define PORTTC 15
  58. #define PORTUA 17
  59. #define PORTUB 18
  60. #define PORTUC 19
  61. #define PORTDD 20
  62. /*
  63. * GPIO PortPin Definitions
  64. */
  65. #define PTE0 0
  66. #define PTE1 1
  67. #define PTE2 2
  68. #define PTE3 3
  69. #define PTE4 4
  70. #define PTE5 5
  71. #define PTE6 6
  72. #define PTE7 7
  73. #define PTF0 10
  74. #define PTF1 11
  75. #define PTF2 12
  76. #define PTF3 13
  77. #define PTF4 14
  78. #define PTF5 15
  79. #define PTF6 16
  80. #define PTF7 17
  81. #define PTG0 20
  82. #define PTG1 21
  83. #define PTG2 22
  84. #define PTG3 23
  85. #define PTG4 24
  86. #define PTG5 25
  87. #define PTG6 26
  88. #define PTG7 27
  89. #define PTH0 30
  90. #define PTH1 31
  91. #define PTH2 32
  92. #define PTH3 33
  93. #define PTH4 34
  94. #define PTH5 35
  95. #define PTH6 36
  96. #define PTH7 37
  97. #define PTI0 40
  98. #define PTI1 41
  99. #define PTI2 42
  100. #define PTI3 43
  101. #define PTI4 44
  102. #define PTI5 45
  103. #define PTI6 46
  104. #define PTI7 47
  105. #define PTJ0 60
  106. #define PTJ1 61
  107. #define PTJ2 62
  108. #define PTJ3 63
  109. #define PTJ4 64
  110. #define PTJ5 65
  111. #define PTJ6 66
  112. #define PTJ7 67
  113. #define PNQ0 80
  114. #define PNQ1 81
  115. #define PNQ2 82
  116. #define PNQ3 83
  117. #define PNQ4 84
  118. #define PNQ5 85
  119. #define PNQ6 86
  120. #define PNQ7 87
  121. #define PAN0 100
  122. #define PAN1 101
  123. #define PAN2 102
  124. #define PAN3 103
  125. #define PAN4 104
  126. #define PAN5 105
  127. #define PAN6 106
  128. #define PAN7 107
  129. #define PAS0 110
  130. #define PAS1 111
  131. #define PAS2 112
  132. #define PAS3 113
  133. #define PAS4 114
  134. #define PAS5 115
  135. #define PAS6 116
  136. #define PAS7 117
  137. #define PQS0 120
  138. #define PQS1 121
  139. #define PQS2 122
  140. #define PQS3 123
  141. #define PQS4 124
  142. #define PQS5 125
  143. #define PQS6 126
  144. #define PQS7 127
  145. #define PTA0 140
  146. #define PTA1 141
  147. #define PTA2 142
  148. #define PTA3 143
  149. #define PTA4 144
  150. #define PTA5 145
  151. #define PTA6 146
  152. #define PTA7 147
  153. #define PTC0 150
  154. #define PTC1 151
  155. #define PTC2 152
  156. #define PTC3 153
  157. #define PTC4 154
  158. #define PTC5 155
  159. #define PTC6 156
  160. #define PTC7 157
  161. #define PUA0 170
  162. #define PUA1 171
  163. #define PUA2 172
  164. #define PUA3 173
  165. #define PUA4 174
  166. #define PUA5 175
  167. #define PUA6 176
  168. #define PUA7 177
  169. #define PUB0 180
  170. #define PUB1 181
  171. #define PUB2 182
  172. #define PUB3 183
  173. #define PUB4 184
  174. #define PUB5 185
  175. #define PUB6 186
  176. #define PUB7 187
  177. #define PUC0 190
  178. #define PUC1 191
  179. #define PUC2 192
  180. #define PUC3 193
  181. #define PUC4 194
  182. #define PUC5 195
  183. #define PUC6 196
  184. #define PUC7 197
  185. #define PDD0 200
  186. #define PDD1 201
  187. #define PDD2 202
  188. #define PDD3 203
  189. #define PDD4 204
  190. #define PDD5 205
  191. #define PDD6 206
  192. #define PDD7 207
  193. /*
  194. * GPIO API
  195. */
  196. #define GPIO_CFG_PERIPHERAL_MASK 0x00000003
  197. #define GPIO_CFG_INPUT 0x00000000
  198. #define GPIO_CFG_OUTPUT 0x00000004
  199. #define GPIO_CFG_PERIPHERAL0 0x00000001
  200. #define GPIO_CFG_PERIPHERAL1 0x00000002
  201. #define GPIO_CFG_PERIPHERAL2 0x00000003
  202. #define GPIO_CFG_DEBOUNCE 0
  203. #define GPIO_CFG_PULLUP 0
  204. #define GpioPinGet(bank, bit) ((MCF_GPIO_PIN(bank) >> bit) & 0x1)
  205. #define GpioPinSet(bank, bit, value) (value) ? (GpioPinSetHigh(bank, bit)) : (GpioPinSetLow(bank, bit))
  206. #define GpioPinSetHigh(bank, bit) MCF_GPIO_SET(bank) = _BV(bit)
  207. #define GpioPinSetLow(bank, bit) MCF_GPIO_CLR(bank) = _BV(bit)
  208. #define GpioPortGet(bank) MCF_GPIO_PIN(bank)
  209. #define GpioPortSet(bank, value) MCF_GPIO_PORT(bank) = (value)
  210. #define GpioPortSetHigh(bank, mask) MCF_GPIO_SET(bank) = (mask)
  211. #define GpioPortSetLow(bank, mask) MCF_GPIO_CLR(bank) = (mask)
  212. extern uint32_t GpioPinConfigGet(int bank, int bit);
  213. extern int GpioPinConfigSet(int bank, int bit, uint32_t flags);
  214. extern int GpioPortConfigSet(int bank, uint32_t mask, uint32_t flags);