]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/board/arm/lpc17xx-common/libs/bspbase/uart.h
Contributed support for LCP17xx devices and PiKRON's LMC1 board.
[lincan.git] / embedded / board / arm / lpc17xx-common / libs / bspbase / uart.h
1 /******************************************************************************
2  * based on software from:
3  * Copyright 2004, R O SoftWare
4  * No guarantees, warrantees, or promises, implied or otherwise.
5  * May be used for hobby or commercial purposes provided copyright
6  * notice remains intact.
7  * 
8  * reduced to learn what has to be done to enable and use UART0
9  *****************************************************************************/
10 #ifndef INC_UART_H
11 #define INC_UART_H
12
13 #include <system_def.h>
14 #include "serial_reg.h"
15
16
17 ///////////////////////////////////////////////////////////////////////////////
18 // Prehistoric solutions slect baudrates according to some magic constants
19 // Use SI defined Hz/Baud units for selection of baudrate directly for
20 // uart0Init() and uart1Init()
21 #define UART_BAUD(baud) (baud)
22
23 ///////////////////////////////////////////////////////////////////////////////
24 // Definitions for typical UART 'baud' settings
25 #define B1200         UART_BAUD(1200)
26 #define B9600         UART_BAUD(9600)
27 #define B19200        UART_BAUD(19200)
28 #define B38400        UART_BAUD(38400)
29 #define B57600        UART_BAUD(57600)
30 #define B115200       UART_BAUD(115200)
31
32 ///////////////////////////////////////////////////////////////////////////////
33 // Definitions for typical UART 'mode' settings
34 #define UART_8N1      (uint8_t)(UART_LCR_WLEN8 )
35 #define UART_7N1      (uint8_t)(UART_LCR_WLEN7 )
36 #define UART_8N2      (uint8_t)(UART_LCR_WLEN8 | UART_LCR_STOP)
37 #define UART_7N2      (uint8_t)(UART_LCR_WLEN7 | UART_LCR_STOP)
38 #define UART_8E1      (uint8_t)(UART_LCR_WLEN8 | UART_LCR_PARITY | UART_LCR_EPAR)
39 #define UART_7E1      (uint8_t)(UART_LCR_WLEN7 | UART_LCR_PARITY | UART_LCR_EPAR)
40 #define UART_8E2      (uint8_t)(UART_LCR_WLEN8 | UART_LCR_PARITY | UART_LCR_EPAR | UART_LCR_STOP)
41 #define UART_7E2      (uint8_t)(UART_LCR_WLEN7 | UART_LCR_PARITY | UART_LCR_EPAR | UART_LCR_STOP)
42 #define UART_8O1      (uint8_t)(UART_LCR_WLEN8 | UART_LCR_PARITY )
43 #define UART_7O1      (uint8_t)(UART_LCR_WLEN7 | UART_LCR_PARITY )
44 #define UART_8O2      (uint8_t)(UART_LCR_WLEN8 | UART_LCR_PARITY | UART_LCR_STOP)
45 #define UART_7O2      (uint8_t)(UART_LCR_WLEN7 | UART_LCR_PARITY | UART_LCR_STOP)
46
47 ///////////////////////////////////////////////////////////////////////////////
48 // Definitions for typical UART 'fmode' settings
49 #define UART_FIFO_OFF (0x00)
50 #define UART_FIFO_1   (uint8_t)(UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1)
51 #define UART_FIFO_4   (uint8_t)(UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_4)
52 #define UART_FIFO_8   (uint8_t)(UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8)
53 #define UART_FIFO_14  (uint8_t)(UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_14)
54
55 void uart0Init(uint32_t baud, uint8_t mode, uint8_t fmode);
56 int uart0Putch(int ch);
57 uint16_t uart0Space(void);
58 const char *uart0Puts(const char *string);
59 int uart0TxEmpty(void);
60 void uart0TxFlush(void);
61 int uart0Getch(void);
62 int uart0GetchW(void);
63
64 #endif