Fixed the doc
[cerebrum.git] / msp / uart_io_internal.h
blob6f4b8b858e906031e1a4f2ac283f09ab1aa65a66
1 /*
2 * Copyright (c) 2012, Alexander I. Mykyta
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 /**
27 * \addtogroup MOD_UART
28 * \{
29 **/
31 /**
32 * \file
33 * \brief Internal include for \ref MOD_UART "UART IO".
34 * Abstracts register names between MSP430 devices
35 * \author Alex Mykyta (amykyta3@gmail.com)
36 **/
38 ///\}
40 #ifndef __UART_IO_INTERNAL_H__
41 #define __UART_IO_INTERNAL_H__
43 //==================================================================================================
45 #if UIO_CLK_SRC > 2
46 #error "Invalid UIO_CLK_SRC in uart_io_config.h"
47 #endif
49 //--------------------------------------------------------------------------------------------------
50 #if UIO_USE_DEV == 0
51 #if defined(__MSP430_HAS_USCI_A0__)
52 // Registers
53 #define UIO_CTL0 UCA0CTL0
54 #define UIO_CTL1 UCA0CTL1
55 #define UIO_BR0 UCA0BR0
56 #define UIO_BR1 UCA0BR1
57 #define UIO_MCTL UCA0MCTL
58 #define UIO_STAT UCA0STAT
59 #define UIO_RXBUF UCA0RXBUF
60 #define UIO_TXBUF UCA0TXBUF
61 #define UIO_ABCTL UCA0ABCTL
62 #define UIO_IE UCA0IE
63 #define UIO_IFG UCA0IFG
64 #define UIO_IV UCA0IV
66 // ISR
67 #define UIO_ISR_SPLIT 0
68 #define UIO_ISR_VECTOR USCI_A0_VECTOR
70 #define __MSP430_HAS_USCI__
71 //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72 #elif defined(UCA0CTL0_) // Older variant of USCI
73 // Registers
74 #define UIO_CTL0 UCA0CTL0
75 #define UIO_CTL1 UCA0CTL1
76 #define UIO_BR0 UCA0BR0
77 #define UIO_BR1 UCA0BR1
78 #define UIO_MCTL UCA0MCTL
79 #define UIO_STAT UCA0STAT
80 #define UIO_RXBUF UCA0RXBUF
81 #define UIO_TXBUF UCA0TXBUF
82 #define UIO_ABCTL UCA0ABCTL
84 #define UIO_IE IE2
85 #define UIO_UCATXIE UCA0TXIE
86 #define UIO_UCARXIE UCA0RXIE
88 #define UIO_IFG IFG2
89 #define UIO_UCATXIFG UCA0TXIFG
90 #define UIO_UCARXIFG UCA0RXIFG
92 // ISR
93 #define UIO_ISR_SPLIT 1
94 #define UIO_TXISR_VECTOR USCIAB0TX_VECTOR
95 #define UIO_RXISR_VECTOR USCIAB0RX_VECTOR
97 #define __MSP430_HAS_UCA__
98 #else
99 #error "Invalid UIO_USE_DEV in uart_io_config.h"
100 #endif
101 //--------------------------------------------------------------------------------------------------
102 #elif UIO_USE_DEV == 1
103 #if defined(__MSP430_HAS_USCI_A1__)
104 // Registers
105 #define UIO_CTL0 UCA1CTL0
106 #define UIO_CTL1 UCA1CTL1
107 #define UIO_BR0 UCA1BR0
108 #define UIO_BR1 UCA1BR1
109 #define UIO_MCTL UCA1MCTL
110 #define UIO_STAT UCA1STAT
111 #define UIO_RXBUF UCA1RXBUF
112 #define UIO_TXBUF UCA1TXBUF
113 #define UIO_ABCTL UCA1ABCTL
114 #define UIO_IE UCA1IE
115 #define UIO_IFG UCA1IFG
116 #define UIO_IV UCA1IV
118 // ISR
119 #define UIO_ISR_SPLIT 0
120 #define UIO_ISR_VECTOR USCI_A1_VECTOR
122 #define __MSP430_HAS_USCI__
123 //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
124 #elif defined(UCA1CTL0_) // Older variant of USCI
125 // Registers
126 #define UIO_CTL0 UCA1CTL0
127 #define UIO_CTL1 UCA1CTL1
128 #define UIO_BR0 UCA1BR0
129 #define UIO_BR1 UCA1BR1
130 #define UIO_MCTL UCA1MCTL
131 #define UIO_STAT UCA1STAT
132 #define UIO_RXBUF UCA1RXBUF
133 #define UIO_TXBUF UCA1TXBUF
134 #define UIO_ABCTL UCA1ABCTL
136 #define UIO_IE UC1IE
137 #define UIO_UCATXIE UCA1TXIE
138 #define UIO_UCARXIE UCA1RXIE
140 #define UIO_IFG UC1IFG
141 #define UIO_UCATXIFG UCA1TXIFG
142 #define UIO_UCARXIFG UCA1RXIFG
144 // ISR
145 #define UIO_ISR_SPLIT 1
146 #define UIO_TXISR_VECTOR USCIAB1TX_VECTOR
147 #define UIO_RXISR_VECTOR USCIAB1RX_VECTOR
149 #define __MSP430_HAS_UCA__
150 #else
151 #error "Invalid UIO_USE_DEV in uart_io_config.h"
152 #endif
153 //--------------------------------------------------------------------------------------------------
154 #elif UIO_USE_DEV == 2
155 #if defined(__MSP430_HAS_USCI_A2__)
156 // Registers
157 #define UIO_CTL0 UCA2CTL0
158 #define UIO_CTL1 UCA2CTL1
159 #define UIO_BR0 UCA2BR0
160 #define UIO_BR1 UCA2BR1
161 #define UIO_MCTL UCA2MCTL
162 #define UIO_STAT UCA2STAT
163 #define UIO_RXBUF UCA2RXBUF
164 #define UIO_TXBUF UCA2TXBUF
165 #define UIO_ABCTL UCA2ABCTL
166 #define UIO_IE UCA2IE
167 #define UIO_IFG UCA2IFG
168 #define UIO_IV UCA2IV
170 // ISR
171 #define UIO_ISR_SPLIT 0
172 #define UIO_ISR_VECTOR USCI_A2_VECTOR
174 #define __MSP430_HAS_USCI__
175 #else
176 #error "Invalid UIO_USE_DEV in uart_io_config.h"
177 #endif
178 //--------------------------------------------------------------------------------------------------
179 #elif UIO_USE_DEV == 3
180 #if defined(__MSP430_HAS_USCI_A3__)
181 // Registers
182 #define UIO_CTL0 UCA3CTL0
183 #define UIO_CTL1 UCA3CTL1
184 #define UIO_BR0 UCA3BR0
185 #define UIO_BR1 UCA3BR1
186 #define UIO_MCTL UCA3MCTL
187 #define UIO_STAT UCA3STAT
188 #define UIO_RXBUF UCA3RXBUF
189 #define UIO_TXBUF UCA3TXBUF
190 #define UIO_ABCTL UCA3ABCTL
191 #define UIO_IE UCA3IE
192 #define UIO_IFG UCA3IFG
193 #define UIO_IV UCA3IV
195 // ISR
196 #define UIO_ISR_SPLIT 0
197 #define UIO_ISR_VECTOR USCI_A3_VECTOR
199 #define __MSP430_HAS_USCI__
200 #else
201 #error "Invalid UIO_USE_DEV in uart_io_config.h"
202 #endif
203 //--------------------------------------------------------------------------------------------------
204 #else
205 #error "Invalid UIO_USE_DEV in uart_io_config.h"
206 #endif
208 #endif