SikendeRTOS
RTOS for ARM Cortex M3+ SoCs designed and written from scratch
UART0.h
Go to the documentation of this file.
1
11// UART.h
12// Runs on LM4F120/TM4C123
13// Use UART0 to implement bidirectional data transfer to and from a
14// computer running HyperTerminal. This time, interrupts and FIFOs
15// are used.
16// Daniel Valvano
17// September 11, 2013
18
19/* This example accompanies the book
20 "Embedded Systems: Real Time Interfacing to Arm Cortex M Microcontrollers",
21 ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2015
22 Program 5.11 Section 5.6, Program 3.10
23
24 Copyright 2015 by Jonathan W. Valvano, valvano@mail.utexas.edu
25 You may use, edit, run or distribute this file
26 as long as the above copyright notice remains
27 THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
28 OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
29 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
30 VALVANO SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
31 OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
32 For more information about my classes, my research, and my books, see
33 http://users.ece.utexas.edu/~valvano/
34 */
35#include <stdint.h>
36#include "OS.h"
37// U0Rx (VCP receive) connected to PA0
38// U0Tx (VCP transmit) connected to PA1
39
40// standard ASCII symbols
41#define CR 0x0D
42#define LF 0x0A
43#define BS 0x08
44#define ESC 0x1B
45#define SP 0x20
46#define DEL 0x7F
47
48//------------UART_Init------------
49// Initialize the UART for 115,200 baud rate (assuming 50 MHz clock),
50// 8 bit word length, no parity bits, one stop bit, FIFOs enabled
51// Input: none
52// Output: none
53void UART_Init(void);
54
55//------------UART_InChar------------
56// Wait for new serial port input
57// Input: none
58// Output: ASCII code for key typed
59char UART_InChar(void);
60
61//------------UART_OutChar------------
62// Output 8-bit to serial port
63// Input: letter is an 8-bit ASCII character to be transferred
64// Output: none
65void UART_OutChar(char data);
66
67//------------UART_OutString------------
68// Output String (NULL termination)
69// Input: pointer to a NULL-terminated string to be transferred
70// Output: none
71void UART_OutString(char *pt);
72
73//------------UART_InUDec------------
74// InUDec accepts ASCII input in unsigned decimal format
75// and converts to a 32-bit unsigned number
76// valid range is 0 to 4294967295 (2^32-1)
77// Input: none
78// Output: 32-bit unsigned number
79// If you enter a number above 4294967295, it will return an incorrect value
80// Backspace will remove last digit typed
81uint32_t UART_InUDec(void);
82
83//-----------------------UART_OutUDec-----------------------
84// Output a 32-bit number in unsigned decimal format
85// Input: 32-bit number to be transferred
86// Output: none
87// Variable format 1-10 digits with no space before or after
88void UART_OutUDec(uint32_t n);
89
90//---------------------UART_InUHex----------------------------------------
91// Accepts ASCII input in unsigned hexadecimal (base 16) format
92// Input: none
93// Output: 32-bit unsigned number
94// No '$' or '0x' need be entered, just the 1 to 8 hex digits
95// It will convert lower case a-f to uppercase A-F
96// and converts to a 16 bit unsigned number
97// value range is 0 to FFFFFFFF
98// If you enter a number above FFFFFFFF, it will return an incorrect value
99// Backspace will remove last digit typed
100uint32_t UART_InUHex(void);
101
102//--------------------------UART_OutUHex----------------------------
103// Output a 32-bit number in unsigned hexadecimal format
104// Input: 32-bit number to be transferred
105// Output: none
106// Variable format 1 to 8 digits with no space before or after
107void UART_OutUHex(uint32_t number);
108
109//------------UART_InString------------
110// Accepts ASCII characters from the serial port
111// and adds them to a string until <enter> is typed
112// or until max length of the string is reached.
113// It echoes each character as it is inputted.
114// If a backspace is inputted, the string is modified
115// and the backspace is echoed
116// terminates the string with a null character
117// uses busy-waiting synchronization on RDRF
118// Input: pointer to empty buffer, size of buffer
119// Output: Null terminated string
120// -- Modified by Agustinus Darmawan + Mingjie Qiu --
121void UART_InString(char *bufPt, uint16_t max);
122
123//---------------------OutCRLF---------------------
124// Output a CR,LF to UART to go to a new line
125// Input: none
126// Output: none
127void OutCRLF(void);
128
Functions for OS.
char UART_InChar(void)
Definition: UART0.c:115
uint32_t UART_InUDec(void)
Definition: UART0.c:174
void UART_OutUHex(uint32_t number)
Definition: UART0.c:260
void UART_OutString(char *pt)
Definition: UART0.c:159
void UART_InString(char *bufPt, uint16_t max)
Definition: UART0.c:289
void UART_OutChar(char data)
Definition: UART0.c:122
uint32_t UART_InUHex(void)
Definition: UART0.c:223
void UART_OutUDec(uint32_t n)
Definition: UART0.c:203
void UART_Init(void)
void OutCRLF(void)
Definition: UART0.c:316