Asynchronous serial communication.
More...
|
| file | UART2.h |
| | Initialize UART2, no transmit, interrupt on receive timeout.
|
| |
|
|
#define | CR 0x0D |
| | CR is carriage return.
|
| |
|
#define | LF 0x0A |
| | LF is line feed.
|
| |
|
#define | BS 0x08 |
| | BS is back space.
|
| |
|
#define | ESC 0x1B |
| | ESC is escape character.
|
| |
|
#define | SP 0x20 |
| | SP is space.
|
| |
|
#define | DEL 0x7F |
| | DEL is delete.
|
| |
Asynchronous serial communication.
UART pins on the MSPM0G3507
| Pin | Description |
| PA10 | UART0 Tx to XDS Rx |
| PA11 | UART0 Rx from XDS Tx |
UART pins on the MSPM0G3507
| Pin | Description |
| PA22 | UART1 Rx from other microcontroller PA8 Tx |
◆ UART2_InChar()
| char UART2_InChar |
( |
void |
| ) |
|
get data from FIFO1
Get new serial port receive data from FIFO1
Return 0 if the FIFO1 is empty
Return nonzero data from the FIFO1 if available
- Parameters
-
- Returns
- char ASCII code from other computer
◆ UART2_Init()
Initialize UART1.
initialize UART2 for 2000 bps baud rate.
PA22 UART2 Rx from other microcontroller PA8 Tx
no transmit, interrupt on receive timeout
- Parameters
-
- Returns
- none
◆ UART_Fix2()
| void UART_Fix2 |
( |
long |
number | ) |
|
output a fixed-point number to UART0
Output a 32-bit number in 0.01 fixed-point format Fixed format
12345 to " 123.45"
-22100 to "-221.00"
-102 to " -1.02"
31 to " 0.31"
error " ***.**"
- Parameters
-
| number32-bit | number to be transferred -99999 to +99999 |
- Returns
- none
◆ UART_InChar()
| char UART_InChar |
( |
void |
| ) |
|
input from UART0
Wait for new serial port input
- Parameters
-
- Returns
- char ASCII code for key typed
◆ UART_Init()
| void UART_Init |
( |
uint32_t |
priority | ) |
|
Initialize UART0.
initialize 0 for 115200 baud rate.
- PA10 = UART0 Tx to XDS Rx
- PA11 = UART0 Rx from XDS Tx
There are two implementations:
- UART_Init in UARTbusywait.c implements busy-wait synchronization
- UART_Init in UARTints.c implements interrupt synchronization
- Parameters
-
| priority | 0 for highest, 3 for lowest |
- Returns
- none
◆ UART_InitPrintf()
| void UART_InitPrintf |
( |
void |
| ) |
|
Initialize UART0 to use printf.
Initialize the UART for 115,200 baud rate (assuming 48 MHz bus clock), 8 bit word length, no parity bits, one stop bit. Calls UART_Init()
- Parameters
-
- Returns
- none
◆ UART_InString()
| void UART_InString |
( |
char * |
bufPt, |
|
|
uint16_t |
max |
|
) |
| |
input a string from UART0
Accepts ASCII characters from the serial port and adds them to a string until <enter> is typed or until max length of the string is reached. It echoes each character as it is inputted. If a backspace is inputted, the string is modified and the backspace is echoed terminates the string with a null character Calls UART_InChar
- Parameters
-
| bufPt | is a pointer to empty buffer, |
| max | is the size of the buffer |
- Returns
- none
- Note
- Modified by Agustinus Darmawan + Mingjie Qiu –
◆ UART_InUDec()
| uint32_t UART_InUDec |
( |
void |
| ) |
|
input a number from UART0
InUDec accepts ASCII input in unsigned decimal format and converts to a 32-bit unsigned number valid range is 0 to 4294967295 (2^32-1)
- Parameters
-
- Returns
- 32-bit unsigned number
- Note
- If you enter a number above 4294967295, it will return an incorrect value Backspace will remove last digit typed
◆ UART_InUHex()
| uint32_t UART_InUHex |
( |
void |
| ) |
|
input a hex number from UART0
Accepts ASCII input in unsigned hexadecimal (base 16) format No '$' or '0x' need be entered, just the 1 to 8 hex digits It will convert lower case a-f to uppercase A-F and converts to a 16 bit unsigned number value range is 0 to FFFFFFFF If you enter a number above FFFFFFFF, it will return an incorrect value Backspace will remove last digit typed
- Parameters
-
- Returns
- 32-bit unsigned number
◆ UART_OutChar()
| void UART_OutChar |
( |
char |
data | ) |
|
output character to UART0
Output 8-bit to serial port
- Parameters
-
| data | is an 8-bit ASCII character to be transferred |
- Returns
- none
◆ UART_OutSDec()
| void UART_OutSDec |
( |
int32_t |
n | ) |
|
output a signed number to UART0
Output a 32-bit number in signed decimal format
- Parameters
-
| n | 32-bit number to be transferred |
- Returns
- none
- Note
- Variable format 1-10 digits with no space before or after
◆ UART_OutString()
| void UART_OutString |
( |
char * |
pt | ) |
|
output string to UART0
Output String with NULL termination
- Parameters
-
| pt | is pointer to a NULL-terminated string to be transferred |
- Returns
- none
◆ UART_OutUDec()
| void UART_OutUDec |
( |
uint32_t |
n | ) |
|
output a number to UART0
Output a 32-bit number in unsigned decimal format
- Parameters
-
| n | 32-bit number to be transferred |
- Returns
- none
- Note
- Variable format 1-10 digits with no space before or after
◆ UART_OutUDec3()
| void UART_OutUDec3 |
( |
uint32_t |
n | ) |
|
output a number to UART0
Output a 32-bit number in unsigned decimal format
- Parameters
-
| n | 32-bit number to be transferred |
- Returns
- none
- Note
- fixed format 3 digits with no space before or after
◆ UART_OutUDec5()
| void UART_OutUDec5 |
( |
uint32_t |
n | ) |
|
output a number to UART0
Output a 32-bit number in unsigned decimal format
- Parameters
-
| n | 32-bit number to be transferred |
- Returns
- none
- Note
- Variable fixed format 5 digits with no space before or after
◆ UART_OutUHex()
| void UART_OutUHex |
( |
uint32_t |
number | ) |
|
output a hex number to UART0
Output a 32-bit number in unsigned hexadecimal format
- Parameters
-
| number | 32-bit number to be transferred |
- Returns
- none
- Note
- Variable format 1 to 8 digits with no space before or after
◆ UART_OutUHex2()
| void UART_OutUHex2 |
( |
uint32_t |
number | ) |
|
output a 2-digit hex number to UART0
Output an 8-bit number in unsigned hexadecimal format
- Parameters
-
| number | 32-bit number to be transferred |
- Returns
- none
- Note
- Fixed format, 5 characters e.g., " 0x1A"