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