gpio_mcf51cn.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 INTERRUPTEON) 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. #include <stdint.h>
  36. /*
  37. * GPIO Port Definitions
  38. */
  39. #define PORTA 0
  40. #define PORTB 1
  41. #define PORTC 2
  42. #define PORTD 3
  43. #define PORTE 4
  44. #define PORTF 5
  45. #define PORTG 6
  46. #define PORTH 7
  47. #define PORTJ 8
  48. /*
  49. * GPIO PortPin Definitions
  50. */
  51. #define PTA0 0
  52. #define PTA1 1
  53. #define PTA2 2
  54. #define PTA3 3
  55. #define PTA4 4
  56. #define PTA5 5
  57. #define PTA6 6
  58. #define PTA7 7
  59. #define PTB0 10
  60. #define PTB1 11
  61. #define PTB2 12
  62. #define PTB3 13
  63. #define PTB4 14
  64. #define PTB5 15
  65. #define PTB6 16
  66. #define PTB7 17
  67. #define PTC0 20
  68. #define PTC1 21
  69. #define PTC2 22
  70. #define PTC3 23
  71. #define PTC4 24
  72. #define PTC5 25
  73. #define PTC6 26
  74. #define PTC7 27
  75. #define PTD0 30
  76. #define PTD1 31
  77. #define PTD2 32
  78. #define PTD3 33
  79. #define PTD4 34
  80. #define PTD5 35
  81. #define PTD6 36
  82. #define PTD7 37
  83. #define PTE0 40
  84. #define PTE1 41
  85. #define PTE2 42
  86. #define PTE3 43
  87. #define PTE4 44
  88. #define PTE5 45
  89. #define PTE6 46
  90. #define PTE7 47
  91. #define PTF0 60
  92. #define PTF1 61
  93. #define PTF2 62
  94. #define PTF3 63
  95. #define PTF4 64
  96. #define PTF5 65
  97. #define PTF6 66
  98. #define PTF7 67
  99. #define PTG0 80
  100. #define PTG1 81
  101. #define PTG2 82
  102. #define PTG3 83
  103. #define PTG4 84
  104. #define PTG5 85
  105. #define PTG6 86
  106. #define PTG7 87
  107. #define PTH0 100
  108. #define PTH1 101
  109. #define PTH2 102
  110. #define PTH3 103
  111. #define PTH4 104
  112. #define PTH5 105
  113. #define PTH6 106
  114. #define PTH7 107
  115. #define PTJ0 110
  116. #define PTJ1 111
  117. #define PTJ2 112
  118. #define PTJ3 113
  119. #define PTJ4 114
  120. #define PTJ5 115
  121. #define PTJ6 116
  122. #define PTJ7 117
  123. /*
  124. * GPIO PortPins Initialization
  125. */
  126. #include "gpio_mcf51cn_iic1.h"
  127. #include "gpio_mcf51cn_iic2.h"
  128. #include "gpio_mcf51cn_sci1.h"
  129. #include "gpio_mcf51cn_sci2.h"
  130. #include "gpio_mcf51cn_sci3.h"
  131. /*
  132. * GPIO API
  133. */
  134. #define GPIO_CFG_INPUT 0x00000000
  135. #define GPIO_CFG_ALT1 0x00000001
  136. #define GPIO_CFG_ALT2 0x00000002
  137. #define GPIO_CFG_ALT3 0x00000003
  138. #define GPIO_CFG_OUTPUT 0x00000004
  139. #define GPIO_CFG_PULLUP 0x00000010
  140. #define GPIO_CFG_SLEW_RATE 0x00000020
  141. #define GPIO_CFG_DRIVE_STRENGTH 0x00000040
  142. #define GPIO_CFG_INPUT_FILTER 0x00000080
  143. #define GPIO_CFG_DEBOUNCE 0 // not supported
  144. #define GpioPinGet(bank, bit) ((MCF_GPIO_D(bank) >> bit) & 0x1)
  145. #define GpioPinSet(bank, bit, value) (value) ? (GpioPinSetHigh(bank, bit)) : (GpioPinSetLow(bank, bit))
  146. #define GpioPinSetHigh(bank, bit) MCF_GPIO_D(bank) |= _BV(bit)
  147. #define GpioPinSetLow(bank, bit) MCF_GPIO_D(bank) &= ~_BV(bit)
  148. #define GpioPortGet(bank) MCF_GPIO_D(bank)
  149. #define GpioPortSet(bank, value) MCF_GPIO_D(bank) = (value)
  150. #define GpioPortSetHigh(bank, mask) MCF_GPIO_D(bank) |= (mask)
  151. #define GpioPortSetLow(bank, mask) MCF_GPIO_D(bank) &= ~(mask)
  152. extern uint32_t GpioPinConfigGet(int bank, int bit);
  153. extern int GpioPinConfigSet(int bank, int bit, uint32_t flags);
  154. extern int GpioPortConfigSet(int bank, uint32_t mask, uint32_t flags);