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