1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
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
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef UART_H_
33 #define UART_H_
34 
35 //*****************************************************************************
36 //
37 //! \addtogroup uart_api
38 //! @{
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #include <stdint.h>
54 #include <stdbool.h>
55 
56 #include <ti/devices/msp432p4xx/inc/msp.h>
57 #include <ti/devices/msp432p4xx/driverlib/eusci.h>
58 
59 #define DEFAULT_SYNC                                    0x00
60 #define EUSCI_A_UART_AUTOMATICBAUDRATE_SYNC             0x55
61 
62 #define EUSCI_A_UART_NO_PARITY                          0x00
63 #define EUSCI_A_UART_ODD_PARITY                         0x01
64 #define EUSCI_A_UART_EVEN_PARITY                        0x02
65 
66 #define EUSCI_A_UART_MSB_FIRST                          EUSCI_A_CTLW0_MSB
67 #define EUSCI_A_UART_LSB_FIRST                          0x00
68 
69 #define EUSCI_A_UART_MODE                               EUSCI_A_CTLW0_MODE_0
70 #define EUSCI_A_UART_IDLE_LINE_MULTI_PROCESSOR_MODE        EUSCI_A_CTLW0_MODE_1
71 #define EUSCI_A_UART_ADDRESS_BIT_MULTI_PROCESSOR_MODE   EUSCI_A_CTLW0_MODE_2
72 #define EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE  EUSCI_A_CTLW0_MODE_3
73 
74 #define EUSCI_A_UART_CLOCKSOURCE_SMCLK                  EUSCI_A_CTLW0_SSEL__SMCLK
75 #define EUSCI_A_UART_CLOCKSOURCE_ACLK                   EUSCI_A_CTLW0_SSEL__ACLK
76 
77 #define EUSCI_A_UART_ONE_STOP_BIT                       0x00
78 #define EUSCI_A_UART_TWO_STOP_BITS                      EUSCI_A_CTLW0_SPB
79 
80 #define EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION   0x01
81 #define EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION  0x00
82 
83 #define EUSCI_A_UART_RECEIVE_INTERRUPT                  EUSCI_A_IE_RXIE
84 #define EUSCI_A_UART_TRANSMIT_INTERRUPT                 EUSCI_A_IE_TXIE
85 #define EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT    EUSCI_A_CTLW0_RXEIE
86 #define EUSCI_A_UART_BREAKCHAR_INTERRUPT                EUSCI_A_CTLW0_BRKIE
87 #define EUSCI_A_UART_STARTBIT_INTERRUPT                 EUSCI_A_IE_STTIE
88 #define EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT        EUSCI_B_IE_STPIE
89 
90 #define EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG             EUSCI_A_IFG_RXIFG
91 #define EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG            EUSCI_A_IFG_TXIFG
92 #define EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG            EUSCI_A_IFG_STTIFG
93 #define EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG   EUSCI_A_IFG_TXCPTIFG
94 
95 #define EUSCI_A_UART_LISTEN_ENABLE                      EUSCI_A_STATW_LISTEN
96 #define EUSCI_A_UART_FRAMING_ERROR                      EUSCI_A_STATW_FE
97 #define EUSCI_A_UART_OVERRUN_ERROR                      EUSCI_A_STATW_OE
98 #define EUSCI_A_UART_PARITY_ERROR                       EUSCI_A_STATW_PE
99 #define EUSCI_A_UART_BREAK_DETECT                       EUSCI_A_STATW_BRK
100 #define EUSCI_A_UART_RECEIVE_ERROR                      EUSCI_A_STATW_RXERR
101 #define EUSCI_A_UART_ADDRESS_RECEIVED                   EUSCI_A_STATW_ADDR_IDLE
102 #define EUSCI_A_UART_IDLELINE                           EUSCI_A_STATW_ADDR_IDLE
103 #define EUSCI_A_UART_BUSY                               EUSCI_A_STATW_BUSY
104 
105 #define EUSCI_A_UART_DEGLITCH_TIME_2ns                  0x00
106 #define EUSCI_A_UART_DEGLITCH_TIME_50ns                 0x0001
107 #define EUSCI_A_UART_DEGLITCH_TIME_100ns                0x0002
108 #define EUSCI_A_UART_DEGLITCH_TIME_200ns                (0x0001 + 0x0002)
109 
110 //*****************************************************************************
111 //
112 //!     ypedef eUSCI_eUSCI_UART_Config
113 //! \brief Type definition for \link _eUSCI_UART_Config \endlink
114 //!     structure
115 //!
116 //! \struct _eUSCI_eUSCI_UART_Config
117 //! \brief Configuration structure for compare mode in the \b UART module. See
118 //!          \link UART_initModule \endlink for parameter
119 //!                 documentation.
120 //
121 //*****************************************************************************
122 typedef struct _eUSCI_eUSCI_UART_Config
123 {
124     uint_fast8_t selectClockSource;
125     uint_fast16_t clockPrescalar;
126     uint_fast8_t firstModReg;
127     uint_fast8_t secondModReg;
128     uint_fast8_t parity;
129     uint_fast16_t msborLsbFirst;
130     uint_fast16_t numberofStopBits;
131     uint_fast16_t uartMode;
132     uint_fast8_t overSampling;
133 } eUSCI_UART_Config;
134 
135 //*****************************************************************************
136 //
137 //! Initialization routine for the UART block. The values to be written
138 //! into the UCAxBRW and UCAxMCTLW registers should be pre-computed and passed
139 //! into the initialization function
140 //!
141 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
142 //! Valid parameters vary from part to part, but can include:
143 //!         - \b EUSCI_A0_BASE
144 //!         - \b EUSCI_A1_BASE
145 //!         - \b EUSCI_A2_BASE
146 //!         - \b EUSCI_A3_BASE
147 //! \param config Configuration structure for the UART module
148 //!
149 //! <hr>
150 //! <b>Configuration options for \link eUSCI_UART_Config \endlink
151 //!         structure.</b>
152 //! <hr>
153 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
154 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
155 //!  UART mode.
156 //! \param selectClockSource selects Clock source. Valid values are
157 //!       - \b EUSCI_A_UART_CLOCKSOURCE_SMCLK
158 //!       - \b EUSCI_A_UART_CLOCKSOURCE_ACLK
159 //! \param clockPrescalar is the value to be written into UCBRx bits
160 //! \param firstModReg  is First modulation stage register setting. This
161 //!     value is a pre-calculated value which can be obtained from the Device
162 //!     User Guide.This value is written into UCBRFx bits of UCAxMCTLW.
163 //! \param secondModReg is Second modulation stage register setting.
164 //!     This value is a pre-calculated value which can be obtained from the
165 //!     Device User Guide. This value is written into UCBRSx bits of
166 //!     UCAxMCTLW.
167 //! \param parity is the desired parity. Valid values are
168 //!      - \b EUSCI_A_UART_NO_PARITY  [Default Value],
169 //!      - \b EUSCI_A_UART_ODD_PARITY,
170 //!      - \b EUSCI_A_UART_EVEN_PARITY
171 //! \param msborLsbFirst controls direction of receive and transmit shift
172 //!     register. Valid values are
173 //!      - \b EUSCI_A_UART_MSB_FIRST
174 //!      - \b EUSCI_A_UART_LSB_FIRST [Default Value]
175 //! \param numberofStopBits indicates one/two STOP bits
176 //!      Valid values are
177 //!      - \b EUSCI_A_UART_ONE_STOP_BIT [Default Value]
178 //!      - \b EUSCI_A_UART_TWO_STOP_BITS
179 //! \param uartMode selects the mode of operation
180 //!      Valid values are
181 //!      - \b EUSCI_A_UART_MODE  [Default Value],
182 //!      - \b EUSCI_A_UART_IDLE_LINE_MULTI_PROCESSOR_MODE,
183 //!      - \b EUSCI_A_UART_ADDRESS_BIT_MULTI_PROCESSOR_MODE,
184 //!      - \b EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE
185 //! \param overSampling indicates low frequency or oversampling baud
186 //!      generation
187 //!     Valid values are
188 //!      - \b EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION
189 //!      - \b EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION
190 //!
191 //! Upon successful initialization of the UART block, this function
192 //! will have initialized the module, but the UART block still remains
193 //! disabled and must be enabled with UART_enableModule()
194 //!
195 //! Refer to
196 //! <a href="http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html">
197 //! this calculator </a> for help on calculating values for the parameters.
198 //!
199 //! Modified bits are \b UCPEN, \b UCPAR, \b UCMSB, \b UC7BIT, \b UCSPB,
200 //! \b UCMODEx, \b UCSYNC bits of \b UCAxCTL0 and \b UCSSELx,
201 //! \b UCSWRST bits of \b UCAxCTL1
202 //!
203 //! \return true or
204 //!         false of the initialization process
205 //
206 //*****************************************************************************
207 extern bool UART_initModule(uint32_t moduleInstance,
208         const eUSCI_UART_Config *config);
209 
210 //*****************************************************************************
211 //
212 //! Transmits a byte from the UART Module.
213 //!
214 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
215 //! Valid parameters vary from part to part, but can include:
216 //!         - \b EUSCI_A0_BASE
217 //!         - \b EUSCI_A1_BASE
218 //!         - \b EUSCI_A2_BASE
219 //!         - \b EUSCI_A3_BASE
220 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
221 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
222 //!  UART mode
223 //! \param transmitData data to be transmitted from the UART module
224 //!
225 //! This function will place the supplied data into UART transmit data register
226 //! to start transmission
227 //!
228 //! Modified register is \b UCAxTXBUF
229 //! \return None.
230 //
231 //*****************************************************************************
232 extern void UART_transmitData(uint32_t moduleInstance,
233         uint_fast8_t transmitData);
234 
235 //*****************************************************************************
236 //
237 //! Receives a byte that has been sent to the UART Module.
238 //!
239 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
240 //! Valid parameters vary from part to part, but can include:
241 //!         - \b EUSCI_A0_BASE
242 //!         - \b EUSCI_A1_BASE
243 //!         - \b EUSCI_A2_BASE
244 //!         - \b EUSCI_A3_BASE
245 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
246 //!  as  EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
247 //!  UART mode
248 //!
249 //! This function reads a byte of data from the UART receive data Register.
250 //!
251 //! Modified register is \b UCAxRXBUF
252 //!
253 //! \return Returns the byte received from by the UART module, cast as an
254 //! uint8_t.
255 //
256 //*****************************************************************************
257 extern uint8_t UART_receiveData(uint32_t moduleInstance);
258 
259 //*****************************************************************************
260 //
261 //! Enables the UART block.
262 //!
263 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
264 //! Valid parameters vary from part to part, but can include:
265 //!         - \b EUSCI_A0_BASE
266 //!         - \b EUSCI_A1_BASE
267 //!         - \b EUSCI_A2_BASE
268 //!         - \b EUSCI_A3_BASE
269 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
270 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
271 //!  UART mode
272 //!
273 //! This will enable operation of the UART block.
274 //!
275 //! Modified register is \b UCAxCTL1
276 //!
277 //! \return None.
278 //
279 //*****************************************************************************
280 extern void UART_enableModule(uint32_t moduleInstance);
281 
282 //*****************************************************************************
283 //
284 //! Disables the UART block.
285 //!
286 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
287 //! Valid parameters vary from part to part, but can include:
288 //!         - \b EUSCI_A0_BASE
289 //!         - \b EUSCI_A1_BASE
290 //!         - \b EUSCI_A2_BASE
291 //!         - \b EUSCI_A3_BASE
292 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
293 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
294 //!  UART mode
295 //!
296 //! This will disable operation of the UART block.
297 //!
298 //! Modified register is \b UCAxCTL1
299 //!
300 //! \return None.
301 //
302 //*****************************************************************************
303 extern void UART_disableModule(uint32_t moduleInstance);
304 
305 //*****************************************************************************
306 //
307 //! Gets the current UART status flags.
308 //!
309 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
310 //! Valid parameters vary from part to part, but can include:
311 //!         - \b EUSCI_A0_BASE
312 //!         - \b EUSCI_A1_BASE
313 //!         - \b EUSCI_A2_BASE
314 //!         - \b EUSCI_A3_BASE
315 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
316 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
317 //!  UART mode
318 //! \param mask is the masked interrupt flag status to be returned.
319 //!
320 //! This returns the status for the UART  module based on which
321 //! flag is passed. mask parameter can be either any of the following
322 //! selection.
323 //! - \b EUSCI_A_UART_LISTEN_ENABLE
324 //! - \b EUSCI_A_UART_FRAMING_ERROR
325 //! - \b EUSCI_A_UART_OVERRUN_ERROR
326 //! - \b EUSCI_A_UART_PARITY_ERROR
327 //! - \b eUARTBREAK_DETECT
328 //! - \b EUSCI_A_UART_RECEIVE_ERROR
329 //! - \b EUSCI_A_UART_ADDRESS_RECEIVED
330 //! - \b EUSCI_A_UART_IDLELINE
331 //! - \b EUSCI_A_UART_BUSY
332 //!
333 //! Modified register is \b UCAxSTAT
334 //!
335 //! \return the masked status flag
336 //
337 //*****************************************************************************
338 extern uint_fast8_t UART_queryStatusFlags(uint32_t moduleInstance,
339         uint_fast8_t mask);
340 
341 //*****************************************************************************
342 //
343 //! Sets the UART module in dormant mode
344 //!
345 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
346 //! Valid parameters vary from part to part, but can include:
347 //!         - \b EUSCI_A0_BASE
348 //!         - \b EUSCI_A1_BASE
349 //!         - \b EUSCI_A2_BASE
350 //!         - \b EUSCI_A3_BASE
351 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
352 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
353 //!  UART mode
354 //!
355 //! Puts USCI in sleep mode
356 //! Only characters that are preceded by an idle-line or with address bit set
357 //! UCRXIFG. In UART mode with automatic baud-rate detection, only the
358 //! combination of a break and synch field sets UCRXIFG.
359 //!
360 //! Modified register is \b UCAxCTL1
361 //!
362 //! \return None.
363 //
364 //*****************************************************************************
365 extern void UART_setDormant(uint32_t moduleInstance);
366 
367 //*****************************************************************************
368 //
369 //! Re-enables UART module from dormant mode
370 //!
371 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
372 //! Valid parameters vary from part to part, but can include:
373 //!         - \b EUSCI_A0_BASE
374 //!         - \b EUSCI_A1_BASE
375 //!         - \b EUSCI_A2_BASE
376 //!         - \b EUSCI_A3_BASE
377 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
378 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
379 //!  UART mode
380 //!
381 //! Not dormant. All received characters set UCRXIFG.
382 //!
383 //! Modified bits are \b UCDORM of \b UCAxCTL1 register.
384 //!
385 //! \return None.
386 //
387 //*****************************************************************************
388 extern void UART_resetDormant(uint32_t moduleInstance);
389 
390 //*****************************************************************************
391 //
392 //! Transmits the next byte to be transmitted marked as address depending on
393 //! selected multiprocessor mode
394 //!
395 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
396 //! Valid parameters vary from part to part, but can include:
397 //!         - \b EUSCI_A0_BASE
398 //!         - \b EUSCI_A1_BASE
399 //!         - \b EUSCI_A2_BASE
400 //!         - \b EUSCI_A3_BASE
401 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
402 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
403 //!  UART mode
404 //! \param transmitAddress is the next byte to be transmitted
405 //!
406 //! Modified register is \b UCAxCTL1, \b UCAxTXBUF
407 //!
408 //! \return None.
409 //
410 //*****************************************************************************
411 extern void UART_transmitAddress(uint32_t moduleInstance,
412         uint_fast8_t transmitAddress);
413 
414 //*****************************************************************************
415 //
416 //! Transmit break. Transmits a break with the next write to the transmit
417 //! buffer. In UART mode with automatic baud-rate detection,
418 //! EUSCI_A_UART_AUTOMATICBAUDRATE_SYNC(0x55) must be written into UCAxTXBUF to
419 //! generate the required break/synch fields.
420 //! Otherwise, DEFAULT_SYNC(0x00) must be written into the transmit buffer.
421 //! Also ensures module is ready for transmitting the next data
422 //!
423 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
424 //! Valid parameters vary from part to part, but can include:
425 //!         - \b EUSCI_A0_BASE
426 //!         - \b EUSCI_A1_BASE
427 //!         - \b EUSCI_A2_BASE
428 //!         - \b EUSCI_A3_BASE
429 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
430 //!  asEUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
431 //!  UART mode
432 //!
433 //! Modified register is \b UCAxCTL1, \b UCAxTXBUF
434 //!
435 //! \return None.
436 //
437 //*****************************************************************************
438 extern void UART_transmitBreak(uint32_t moduleInstance);
439 
440 //*****************************************************************************
441 //
442 //! Returns the address of the RX Buffer of the UART for the DMA module.
443 //!
444 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
445 //! Valid parameters vary from part to part, but can include:
446 //!         - \b EUSCI_A0_BASE
447 //!         - \b EUSCI_A1_BASE
448 //!         - \b EUSCI_A2_BASE
449 //!         - \b EUSCI_A3_BASE
450 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
451 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
452 //!  UART mode
453 //!
454 //! Returns the address of the UART RX Buffer. This can be used in conjunction
455 //! with the DMA to store the received data directly to memory.
456 //!
457 //! \return None
458 //
459 //*****************************************************************************
460 extern uint32_t UART_getReceiveBufferAddressForDMA(uint32_t moduleInstance);
461 
462 //*****************************************************************************
463 //
464 //! Returns the address of the TX Buffer of the UART for the DMA module.
465 //!
466 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
467 //! Valid parameters vary from part to part, but can include:
468 //!         - \b EUSCI_A0_BASE
469 //!         - \b EUSCI_A1_BASE
470 //!         - \b EUSCI_A2_BASE
471 //!         - \b EUSCI_A3_BASE
472 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
473 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
474 //!  UART mode
475 //!
476 //! Returns the address of the UART TX Buffer. This can be used in conjunction
477 //! with the DMA to obtain transmitted data directly from memory.
478 //!
479 //! \return None
480 //
481 //*****************************************************************************
482 extern uint32_t UART_getTransmitBufferAddressForDMA(uint32_t moduleInstance);
483 
484 //*****************************************************************************
485 //
486 //! Sets the deglitch time
487 //!
488 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
489 //! Valid parameters vary from part to part, but can include:
490 //!         - \b EUSCI_A0_BASE
491 //!         - \b EUSCI_A1_BASE
492 //!         - \b EUSCI_A2_BASE
493 //!         - \b EUSCI_A3_BASE
494 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
495 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
496 //!  UART mode
497 //! \param deglitchTime is the selected deglitch time
498 //!     Valid values are
499 //!         - \b EUSCI_A_UART_DEGLITCH_TIME_2ns
500 //!         - \b EUSCI_A_UART_DEGLITCH_TIME_50ns
501 //!         - \b EUSCI_A_UART_DEGLITCH_TIME_100ns
502 //!         - \b EUSCI_A_UART_DEGLITCH_TIME_200ns
503 //!
504 //!
505 //! Returns the address of the UART TX Buffer. This can be used in conjunction
506 //! with the DMA to obtain transmitted data directly from memory.
507 //!
508 //! \return None
509 //
510 //*****************************************************************************
511 extern void UART_selectDeglitchTime(uint32_t moduleInstance,
512         uint32_t deglitchTime);
513 
514 //*****************************************************************************
515 //
516 //! Enables individual UART interrupt sources.
517 //!
518 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
519 //! Valid parameters vary from part to part, but can include:
520 //!         - \b EUSCI_A0_BASE
521 //!         - \b EUSCI_A1_BASE
522 //!         - \b EUSCI_A2_BASE
523 //!         - \b EUSCI_A3_BASE
524 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
525 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
526 //!  UART mode
527 //! \param mask is the bit mask of the interrupt sources to be enabled.
528 //!
529 //! Enables the indicated UART interrupt sources.  The interrupt flag is first
530 //! and then the corresponding interrupt is enabled. Only the sources that
531 //! are enabled can be reflected to the processor interrupt; disabled sources
532 //! have no effect on the processor.
533 //!
534 //! The mask parameter is the logical OR of any of the following:
535 //! - \b EUSCI_A_UART_RECEIVE_INTERRUPT -Receive interrupt
536 //! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT - Transmit interrupt
537 //! - \b EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT - Receive
538 //!                             erroneous-character interrupt enable
539 //! - \b EUSCI_A_UART_BREAKCHAR_INTERRUPT - Receive break character interrupt
540 //!                                           enable
541 //!
542 //! Modified register is \b UCAxIFG, \b UCAxIE and \b UCAxCTL1
543 //!
544 //! \return None.
545 //
546 //*****************************************************************************
547 extern void UART_enableInterrupt(uint32_t moduleInstance, uint_fast8_t mask);
548 
549 //*****************************************************************************
550 //
551 //! Disables individual UART interrupt sources.
552 //!
553 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
554 //! Valid parameters vary from part to part, but can include:
555 //!         - \b EUSCI_A0_BASE
556 //!         - \b EUSCI_A1_BASE
557 //!         - \b EUSCI_A2_BASE
558 //!         - \b EUSCI_A3_BASE
559 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
560 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
561 //!  UART mode
562 //! \param mask is the bit mask of the interrupt sources to be
563 //! disabled.
564 //!
565 //! Disables the indicated UART interrupt sources.  Only the sources that
566 //! are enabled can be reflected to the processor interrupt; disabled sources
567 //! have no effect on the processor.
568 //!
569 //! The mask parameter is the logical OR of any of the following:
570 //! - \b EUSCI_A_UART_RECEIVE_INTERRUPT -Receive interrupt
571 //! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT - Transmit interrupt
572 //! - \b EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT - Receive
573 //!                             erroneous-character interrupt enable
574 //! - \b EUSCI_A_UART_BREAKCHAR_INTERRUPT - Receive break character interrupt
575 //!                                             enable
576 //!
577 //! Modified register is \b UCAxIFG, \b UCAxIE and \b UCAxCTL1
578 //! \return None.
579 //
580 //*****************************************************************************
581 extern void UART_disableInterrupt(uint32_t moduleInstance, uint_fast8_t mask);
582 
583 //*****************************************************************************
584 //
585 //! Gets the current UART interrupt status.
586 //!
587 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
588 //! Valid parameters vary from part to part, but can include:
589 //!         - \b EUSCI_A0_BASE
590 //!         - \b EUSCI_A1_BASE
591 //!         - \b EUSCI_A2_BASE
592 //!         - \b EUSCI_A3_BASE
593 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
594 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
595 //!  UART mode
596 //! \param mask is the masked interrupt flag status to be returned.
597 //!        Mask value is the logical OR of any of the following:
598 //!        - \b EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG
599 //!        - \b EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG
600 //!        - \b EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG
601 //!        - \b EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG
602 //!
603 //!
604 //! \return The current interrupt status as an ORed bit mask:
605 //! - \b EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG -Receive interrupt flag
606 //! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG - Transmit interrupt flag
607 //
608 //*****************************************************************************
609 extern uint_fast8_t UART_getInterruptStatus(uint32_t moduleInstance,
610         uint8_t mask);
611 
612 //*****************************************************************************
613 //
614 //! Gets the current UART interrupt status masked with the enabled interrupts.
615 //! This function is useful to call in ISRs to get a list of pending
616 //! interrupts that are actually enabled and could have caused
617 //! the ISR.
618 
619 //!
620 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
621 //! Valid parameters vary from part to part, but can include:
622 //!         - \b EUSCI_A0_BASE
623 //!         - \b EUSCI_A1_BASE
624 //!         - \b EUSCI_A2_BASE
625 //!         - \b EUSCI_A3_BASE
626 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
627 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
628 //!  UART mode
629 //!
630 //! \return The current interrupt status as an ORed bit mask:
631 //! - \b EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG -Receive interrupt flag
632 //! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG - Transmit interrupt flag
633 //
634 //*****************************************************************************
635 extern uint_fast8_t UART_getEnabledInterruptStatus(uint32_t moduleInstance);
636 
637 //*****************************************************************************
638 //
639 //! Clears UART interrupt sources.
640 //!
641 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
642 //! Valid parameters vary from part to part, but can include:
643 //!         - \b EUSCI_A0_BASE
644 //!         - \b EUSCI_A1_BASE
645 //!         - \b EUSCI_A2_BASE
646 //!         - \b EUSCI_A3_BASE
647 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
648 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
649 //!  UART mode
650 //! \param mask is a bit mask of the interrupt sources to be cleared.
651 //!
652 //! The UART interrupt source is cleared, so that it no longer asserts.
653 //! The highest interrupt flag is automatically cleared when an interrupt vector
654 //! generator is used.
655 //!
656 //! The mask parameter has the same definition as the mask parameter to
657 //! EUSCI_A_UART_enableInterrupt().
658 //!
659 //! Modified register is \b UCAxIFG
660 //!
661 //! \return None.
662 //
663 //*****************************************************************************
664 extern void UART_clearInterruptFlag(uint32_t moduleInstance, uint_fast8_t mask);
665 
666 //*****************************************************************************
667 //
668 //! Registers an interrupt handler for UART interrupts.
669 //!
670 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
671 //! Valid parameters vary from part to part, but can include:
672 //!         - \b EUSCI_A0_BASE
673 //!         - \b EUSCI_A1_BASE
674 //!         - \b EUSCI_A2_BASE
675 //!         - \b EUSCI_A3_BASE
676 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
677 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
678 //!  UART mode.
679 //!
680 //! \param intHandler is a pointer to the function to be called when the
681 //! timer capture compare interrupt occurs.
682 //!
683 //! This function registers the handler to be called when an UART
684 //! interrupt occurs. This function enables the global interrupt in the
685 //! interrupt controller; specific UART interrupts must be enabled
686 //! via UART_enableInterrupt().  It is the interrupt handler's responsibility to
687 //! clear the interrupt source via UART_clearInterruptFlag().
688 //!
689 //! \return None.
690 //
691 //*****************************************************************************
692 extern void UART_registerInterrupt(uint32_t moduleInstance,
693         void (*intHandler)(void));
694 
695 //*****************************************************************************
696 //
697 //! Unregisters the interrupt handler for the UART module
698 //!
699 //! \param moduleInstance is the instance of the eUSCI A (UART) module.
700 //! Valid parameters vary from part to part, but can include:
701 //!         - \b EUSCI_A0_BASE
702 //!         - \b EUSCI_A1_BASE
703 //!         - \b EUSCI_A2_BASE
704 //!         - \b EUSCI_A3_BASE
705 //!  <br> It is important to note that for eUSCI modules, only "A" modules such
706 //!  as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the
707 //!  UART mode.
708 //!
709 //! This function unregisters the handler to be called when timer
710 //! interrupt occurs.  This function also masks off the interrupt in the
711 //! interrupt controller so that the interrupt handler no longer is called.
712 //!
713 //! \sa Interrupt_registerInterrupt() for important information about
714 //! registering interrupt handlers.
715 //!
716 //! \return None.
717 //
718 //*****************************************************************************
719 extern void UART_unregisterInterrupt(uint32_t moduleInstance);
720 
721 /* Backwards Compatibility Layer */
722 #define EUSCI_A_UART_transmitData UART_transmitData
723 #define EUSCI_A_UART_receiveData UART_receiveData
724 #define EUSCI_A_UART_enableInterrupt UART_enableInterrupt
725 #define EUSCI_A_UART_disableInterrupt UART_disableInterrupt
726 #define EUSCI_A_UART_getInterruptStatus UART_getInterruptStatus
727 #define EUSCI_A_UART_clearInterruptFlag UART_clearInterruptFlag
728 #define EUSCI_A_UART_enable UART_enableModule
729 #define EUSCI_A_UART_disable UART_disableModule
730 #define EUSCI_A_UART_queryStatusFlags UART_queryStatusFlags
731 #define EUSCI_A_UART_setDormant UART_setDormant
732 #define EUSCI_A_UART_resetDormant UART_resetDormant
733 #define EUSCI_A_UART_transmitAddress UART_transmitAddress
734 #define EUSCI_A_UART_transmitBreak UART_transmitBreak
735 #define EUSCI_A_UART_getReceiveBufferAddressForDMA UART_getReceiveBufferAddressForDMA
736 #define EUSCI_A_UART_getTransmitBufferAddressForDMA UART_getTransmitBufferAddressForDMA
737 #define EUSCI_A_UART_selectDeglitchTime UART_selectDeglitchTime
738 
739 //*****************************************************************************
740 //
741 // Mark the end of the C bindings section for C++ compilers.
742 //
743 //*****************************************************************************
744 #ifdef __cplusplus
745 }
746 #endif
747 
748 //*****************************************************************************
749 //
750 // Close the Doxygen group.
751 //! @}
752 //
753 //*****************************************************************************
754 
755 #endif /* UART_H_ */
756