![]() |
MSPM0_ValvanoWare
1.0
ECE445L starter code
|
Asynchronous serial communication. More...
Files | |
| file | UART.h |
| Initialize UART0. | |
Macros | |
| #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. | |
Functions | |
| void | UART_Init (void) |
| Initialize UART0. More... | |
| char | UART_InChar (void) |
| input from UART0 More... | |
| char | UART_InCharNonBlock (void) |
| non blocking input from UART0 More... | |
| void | UART_OutChar (char data) |
| output character to UART0 More... | |
| void | UART_OutString (char *pt) |
| output string to UART0 More... | |
| uint32_t | UART_InUDec (void) |
| input a number from UART0 More... | |
| void | UART_OutUDec (uint32_t n) |
| output a number to UART0 More... | |
| void | UART_OutSDec (int32_t n) |
| output a signed number to UART0 More... | |
| uint32_t | UART_InUHex (void) |
| input a hex number from UART0 More... | |
| void | UART_OutUHex (uint32_t number) |
| output a hex number to UART0 More... | |
| void | UART_InString (char *bufPt, uint16_t max) |
| input a string from UART0 More... | |
| void | UART_Fix2 (long number) |
| Fixed-point output. More... | |
| void | UART_Fix3 (uint32_t number) |
| void | UART_OutUFix1 (uint16_t n) |
| void | UART_InitPrintf (void) |
| Initialize UART0 to use printf. More... | |
| void | UART1_Init (void) |
| char | UART1_InChar (void) |
| void | UART1_OutChar (char data) |
Asynchronous serial communication.
| Pin | Description |
|---|---|
| PA10 | UART0 Tx to XDS Rx |
| PA11 | UART0 Rx from XDS Tx |
| void UART_Fix2 | ( | long | number | ) |
Fixed-point output.
Output a 32-bit number in 0.01 fixed-point format
| number | 32-bit signed number to be transferred, -99999 to +99999 |
| char UART_InChar | ( | void | ) |
input from UART0
Wait for new serial port input
| none |
| char UART_InCharNonBlock | ( | void | ) |
non blocking input from UART0
Return new serial port input
| none |
| void UART_Init | ( | void | ) |
Initialize UART0.
initialize 0 for 115200 baud rate.
There are two implementations:
| none |
| 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()
| none |
| 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
| bufPt | is a pointer to empty buffer, |
| max | is the size of the buffer |
| 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)
| none |
| 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
| none |
| void UART_OutChar | ( | char | data | ) |
output character to UART0
Output 8-bit to serial port
| data | is an 8-bit ASCII character to be transferred |
| void UART_OutSDec | ( | int32_t | n | ) |
output a signed number to UART0
Output a 32-bit number in signed decimal format
| n | 32-bit number to be transferred |
| void UART_OutString | ( | char * | pt | ) |
output string to UART0
Output String with NULL termination
| pt | is pointer to a NULL-terminated string to be transferred |
| void UART_OutUDec | ( | uint32_t | n | ) |
output a number to UART0
Output a 32-bit number in unsigned decimal format
| n | 32-bit number to be transferred |
| void UART_OutUHex | ( | uint32_t | number | ) |
output a hex number to UART0
Output a 32-bit number in unsigned hexadecimal format
| number | 32-bit number to be transferred |