uart.h
Go to the documentation of this file.
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 //
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 //
120 //
121 //*****************************************************************************
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;
134 
135 //*****************************************************************************
136 //
205 //
206 //*****************************************************************************
207 extern bool UART_initModule(uint32_t moduleInstance,
208  const eUSCI_UART_Config *config);
209 
210 //*****************************************************************************
211 //
230 //
231 //*****************************************************************************
232 extern void UART_transmitData(uint32_t moduleInstance,
233  uint_fast8_t transmitData);
234 
235 //*****************************************************************************
236 //
255 //
256 //*****************************************************************************
257 extern uint8_t UART_receiveData(uint32_t moduleInstance);
258 
259 //*****************************************************************************
260 //
278 //
279 //*****************************************************************************
280 extern void UART_enableModule(uint32_t moduleInstance);
281 
282 //*****************************************************************************
283 //
301 //
302 //*****************************************************************************
303 extern void UART_disableModule(uint32_t moduleInstance);
304 
305 //*****************************************************************************
306 //
336 //
337 //*****************************************************************************
338 extern uint_fast8_t UART_queryStatusFlags(uint32_t moduleInstance,
339  uint_fast8_t mask);
340 
341 //*****************************************************************************
342 //
363 //
364 //*****************************************************************************
365 extern void UART_setDormant(uint32_t moduleInstance);
366 
367 //*****************************************************************************
368 //
386 //
387 //*****************************************************************************
388 extern void UART_resetDormant(uint32_t moduleInstance);
389 
390 //*****************************************************************************
391 //
409 //
410 //*****************************************************************************
411 extern void UART_transmitAddress(uint32_t moduleInstance,
412  uint_fast8_t transmitAddress);
413 
414 //*****************************************************************************
415 //
436 //
437 //*****************************************************************************
438 extern void UART_transmitBreak(uint32_t moduleInstance);
439 
440 //*****************************************************************************
441 //
458 //
459 //*****************************************************************************
460 extern uint32_t UART_getReceiveBufferAddressForDMA(uint32_t moduleInstance);
461 
462 //*****************************************************************************
463 //
480 //
481 //*****************************************************************************
482 extern uint32_t UART_getTransmitBufferAddressForDMA(uint32_t moduleInstance);
483 
484 //*****************************************************************************
485 //
509 //
510 //*****************************************************************************
511 extern void UART_selectDeglitchTime(uint32_t moduleInstance,
512  uint32_t deglitchTime);
513 
514 //*****************************************************************************
515 //
545 //
546 //*****************************************************************************
547 extern void UART_enableInterrupt(uint32_t moduleInstance, uint_fast8_t mask);
548 
549 //*****************************************************************************
550 //
579 //
580 //*****************************************************************************
581 extern void UART_disableInterrupt(uint32_t moduleInstance, uint_fast8_t mask);
582 
583 //*****************************************************************************
584 //
607 //
608 //*****************************************************************************
609 extern uint_fast8_t UART_getInterruptStatus(uint32_t moduleInstance,
610  uint8_t mask);
611 
612 //*****************************************************************************
613 //
618 
633 //
634 //*****************************************************************************
635 extern uint_fast8_t UART_getEnabledInterruptStatus(uint32_t moduleInstance);
636 
637 //*****************************************************************************
638 //
662 //
663 //*****************************************************************************
664 extern void UART_clearInterruptFlag(uint32_t moduleInstance, uint_fast8_t mask);
665 
666 //*****************************************************************************
667 //
690 //
691 //*****************************************************************************
692 extern void UART_registerInterrupt(uint32_t moduleInstance,
693  void (*intHandler)(void));
694 
695 //*****************************************************************************
696 //
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.
752 //
753 //*****************************************************************************
754 
755 #endif /* UART_H_ */
void UART_resetDormant(uint32_t moduleInstance)
Definition: uart.c:170
uint_fast8_t UART_queryStatusFlags(uint32_t moduleInstance, uint_fast8_t mask)
Definition: uart.c:150
void UART_disableInterrupt(uint32_t moduleInstance, uint_fast8_t mask)
Definition: uart.c:254
void UART_selectDeglitchTime(uint32_t moduleInstance, uint32_t deglitchTime)
Definition: uart.c:214
void UART_transmitData(uint32_t moduleInstance, uint_fast8_t transmitData)
Definition: uart.c:118
bool UART_initModule(uint32_t moduleInstance, const eUSCI_UART_Config *config)
Definition: uart.c:37
uint_fast8_t overSampling
Definition: uart.h:132
void UART_unregisterInterrupt(uint32_t moduleInstance)
Definition: uart.c:364
uint_fast8_t parity
Definition: uart.h:128
uint_fast8_t UART_getInterruptStatus(uint32_t moduleInstance, uint8_t mask)
Definition: uart.c:279
uint_fast16_t uartMode
Definition: uart.h:131
uint_fast8_t secondModReg
Definition: uart.h:127
uint32_t UART_getReceiveBufferAddressForDMA(uint32_t moduleInstance)
Definition: uart.c:204
uint8_t UART_receiveData(uint32_t moduleInstance)
Definition: uart.c:128
uint_fast8_t selectClockSource
Definition: uart.h:124
void UART_enableInterrupt(uint32_t moduleInstance, uint_fast8_t mask)
Definition: uart.c:228
void UART_transmitBreak(uint32_t moduleInstance)
Definition: uart.c:184
void UART_clearInterruptFlag(uint32_t moduleInstance, uint_fast8_t mask)
Definition: uart.c:322
uint_fast16_t msborLsbFirst
Definition: uart.h:129
uint32_t UART_getTransmitBufferAddressForDMA(uint32_t moduleInstance)
Definition: uart.c:209
uint_fast8_t firstModReg
Definition: uart.h:126
void UART_transmitAddress(uint32_t moduleInstance, uint_fast8_t transmitAddress)
Definition: uart.c:175
uint_fast8_t UART_getEnabledInterruptStatus(uint32_t moduleInstance)
Definition: uart.c:291
void UART_setDormant(uint32_t moduleInstance)
Definition: uart.c:165
void UART_enableModule(uint32_t moduleInstance)
Definition: uart.c:138
void UART_registerInterrupt(uint32_t moduleInstance, void(*intHandler)(void))
Definition: uart.c:335
uint_fast16_t numberofStopBits
Definition: uart.h:130
Type definition for _eUSCI_UART_Config structure.
Definition: uart.h:122
uint_fast16_t clockPrescalar
Definition: uart.h:125
struct _eUSCI_eUSCI_UART_Config eUSCI_UART_Config
void UART_disableModule(uint32_t moduleInstance)
Definition: uart.c:144

Copyright 2018, Texas Instruments Incorporated