mcf5225x_uart.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 MCF5225X_UART_H_
  33. #define MCF5225X_UART_H_
  34. /* Duplex modes */
  35. #define HALF 0
  36. #define FULL 1
  37. /* UART control structure used for write only registers */
  38. typedef struct _UARTWREGS UARTWREGS;
  39. struct _UARTWREGS {
  40. uint8_t uimr; /* UISR/UIMR register, write from one, red from other => write only */
  41. uint8_t ubg1; /* Write only */
  42. uint8_t ubg2; /* Write only */
  43. uint8_t umr1; /* Write/ Read after RESET MODE REGISTER POINTER */
  44. uint8_t umr2; /* Write/ Read after Write/ Read from UMR1 register */
  45. };
  46. /* UART Registers */
  47. #define MCF_UART_UMR(x) (*(volatile uint8_t *)(0x40000200 + ((x) * 0x40)))
  48. #define MCF_UART_USR(x) (*(volatile uint8_t *)(0x40000204 + ((x) * 0x40)))
  49. #define MCF_UART_UCSR(x) (*(volatile uint8_t *)(0x40000204 + ((x) * 0x40)))
  50. #define MCF_UART_UCR(x) (*(volatile uint8_t *)(0x40000208 + ((x) * 0x40)))
  51. #define MCF_UART_URB(x) (*(volatile uint8_t *)(0x4000020C + ((x) * 0x40)))
  52. #define MCF_UART_UTB(x) (*(volatile uint8_t *)(0x4000020C + ((x) * 0x40)))
  53. #define MCF_UART_UIPCR(x) (*(volatile uint8_t *)(0x40000210 + ((x) * 0x40)))
  54. #define MCF_UART_UACR(x) (*(volatile uint8_t *)(0x40000210 + ((x) * 0x40)))
  55. #define MCF_UART_UIMR(x) (*(volatile uint8_t *)(0x40000214 + ((x) * 0x40)))
  56. #define MCF_UART_UISR(x) (*(volatile uint8_t *)(0x40000214 + ((x) * 0x40)))
  57. #define MCF_UART_UBG1(x) (*(volatile uint8_t *)(0x40000218 + ((x) * 0x40)))
  58. #define MCF_UART_UBG2(x) (*(volatile uint8_t *)(0x4000021C + ((x) * 0x40)))
  59. #define MCF_UART_UIP(x) (*(volatile uint8_t *)(0x40000234 + ((x) * 0x40)))
  60. #define MCF_UART_UOP1(x) (*(volatile uint8_t *)(0x40000238 + ((x) * 0x40)))
  61. #define MCF_UART_UOP0(x) (*(volatile uint8_t *)(0x4000023C + ((x) * 0x40)))
  62. /* MCF_UART_UMR */
  63. #define MCF_UART_UMR_BC(x) (((x) & 0x3) << 0)
  64. #define MCF_UART_UMR_BC_5 0
  65. #define MCF_UART_UMR_BC_6 0x1
  66. #define MCF_UART_UMR_BC_7 0x2
  67. #define MCF_UART_UMR_BC_8 0x3
  68. #define MCF_UART_UMR_PT 0x4
  69. #define MCF_UART_UMR_PM(x) (((x) & 0x3) << 0x3)
  70. #define MCF_UART_UMR_ERR 0x20
  71. #define MCF_UART_UMR_RXIRQ 0x40
  72. #define MCF_UART_UMR_RXRTS 0x80
  73. #define MCF_UART_UMR_PM_MULTI_ADDR 0x1C
  74. #define MCF_UART_UMR_PM_MULTI_DATA 0x18
  75. #define MCF_UART_UMR_PM_NONE 0x10
  76. #define MCF_UART_UMR_PM_FORCE_HI 0xC
  77. #define MCF_UART_UMR_PM_FORCE_LO 0x8
  78. #define MCF_UART_UMR_PM_ODD 0x4
  79. #define MCF_UART_UMR_PM_EVEN 0
  80. #define MCF_UART_UMR_SB(x) (((x) & 0xF) << 0)
  81. #define MCF_UART_UMR_SB_STOP_BITS_1 0x7
  82. #define MCF_UART_UMR_SB_STOP_BITS_15 0x8
  83. #define MCF_UART_UMR_SB_STOP_BITS_2 0xF
  84. #define MCF_UART_UMR_TXCTS 0x10
  85. #define MCF_UART_UMR_TXRTS 0x20
  86. #define MCF_UART_UMR_CM(x) (((x) & 0x3) << 0x6)
  87. #define MCF_UART_UMR_CM_NORMAL 0
  88. #define MCF_UART_UMR_CM_ECHO 0x40
  89. #define MCF_UART_UMR_CM_LOCAL_LOOP 0x80
  90. #define MCF_UART_UMR_CM_REMOTE_LOOP 0xC0
  91. /* MCF_UART_USR */
  92. #define MCF_UART_USR_RXRDY 0x1
  93. #define MCF_UART_USR_FFULL 0x2
  94. #define MCF_UART_USR_TXRDY 0x4
  95. #define MCF_UART_USR_TXEMP 0x8
  96. #define MCF_UART_USR_OE 0x10
  97. #define MCF_UART_USR_PE 0x20
  98. #define MCF_UART_USR_FE 0x40
  99. #define MCF_UART_USR_RB 0x80
  100. /* MCF_UART_UCSR */
  101. #define MCF_UART_UCSR_TCS(x) (((x) & 0xF) << 0)
  102. #define MCF_UART_UCSR_TCS_SYS_CLK 0xD
  103. #define MCF_UART_UCSR_TCS_CTM16 0xE
  104. #define MCF_UART_UCSR_TCS_CTM 0xF
  105. #define MCF_UART_UCSR_RCS(x) (((x) & 0xF) << 0x4)
  106. #define MCF_UART_UCSR_RCS_SYS_CLK 0xD0
  107. #define MCF_UART_UCSR_RCS_CTM16 0xE0
  108. #define MCF_UART_UCSR_RCS_CTM 0xF0
  109. /* MCF_UART_UCR */
  110. #define MCF_UART_UCR_RC(x) (((x) & 0x3) << 0)
  111. #define MCF_UART_UCR_RX_ENABLED 0x1
  112. #define MCF_UART_UCR_RX_DISABLED 0x2
  113. #define MCF_UART_UCR_TC(x) (((x) & 0x3) << 0x2)
  114. #define MCF_UART_UCR_TX_ENABLED 0x4
  115. #define MCF_UART_UCR_TX_DISABLED 0x8
  116. #define MCF_UART_UCR_MISC(x) (((x) & 0x7) << 0x4)
  117. #define MCF_UART_UCR_NONE 0
  118. #define MCF_UART_UCR_RESET_MR 0x10
  119. #define MCF_UART_UCR_RESET_RX 0x20
  120. #define MCF_UART_UCR_RESET_TX 0x30
  121. #define MCF_UART_UCR_RESET_ERROR 0x40
  122. #define MCF_UART_UCR_RESET_BKCHGINT 0x50
  123. #define MCF_UART_UCR_START_BREAK 0x60
  124. #define MCF_UART_UCR_STOP_BREAK 0x70
  125. /* MCF_UART_URB */
  126. #define MCF_UART_URB_RB(x) (((x) & 0xFF) << 0)
  127. /* MCF_UART_UTB */
  128. #define MCF_UART_UTB_TB(x) (((x) & 0xFF) << 0)
  129. /* MCF_UART_UIPCR */
  130. #define MCF_UART_UIPCR_CTS 0x1
  131. #define MCF_UART_UIPCR_COS 0x10
  132. /* MCF_UART_UACR */
  133. #define MCF_UART_UACR_IEC 0x1
  134. /* MCF_UART_UIMR */
  135. #define MCF_UART_UIMR_TXRDY 0x1
  136. #define MCF_UART_UIMR_FFULL_RXRDY 0x2
  137. #define MCF_UART_UIMR_DB 0x4
  138. #define MCF_UART_UIMR_COS 0x80
  139. /* MCF_UART_UISR */
  140. #define MCF_UART_UISR_TXRDY 0x1
  141. #define MCF_UART_UISR_FFULL_RXRDY 0x2
  142. #define MCF_UART_UISR_DB 0x4
  143. #define MCF_UART_UISR_COS 0x80
  144. /* MCF_UART_UBG1 */
  145. #define MCF_UART_UBG1_Divider_MSB(x) (((x) & 0xFF) << 0)
  146. /* MCF_UART_UBG2 */
  147. #define MCF_UART_UBG2_Divider_LSB(x) (((x) & 0xFF) << 0)
  148. /* MCF_UART_UIP */
  149. #define MCF_UART_UIP_CTS 0x1
  150. /* MCF_UART_UOP1 */
  151. #define MCF_UART_UOP1_RTS 0x1
  152. /* MCF_UART_UOP0 */
  153. #define MCF_UART_UOP0_RTS 0x1
  154. #endif /* MCF5225X_UART_H_ */