?? uart.h
字號:
/* *****************************************************************************
* based on software from:
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to learn what has to be done to enable and use UART0
*****************************************************************************/
#ifndef INC_UART_H
#define INC_UART_H
#include <lpc2119.h>
#include "lpcUART.h"
#include "config.h"
///////////////////////////////////////////////////////////////////////////////
// use the following macros to determine the 'baud' parameter values
// for uart0Init() and uart1Init()
// CAUTION - 'baud' SHOULD ALWAYS BE A CONSTANT or
// a lot of code will be generated.
// Baud-Rate is calculated based on pclk (VPB-clock)
// the devisor must be 16 times the desired baudrate
#define UART_BAUD(baud) (unsigned int)(((FOSC*PLL_M/VPBDIV_VAL) / ((baud) * 16.0)) + 0.5)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'baud' settings
#define B1200 UART_BAUD(1200)
#define B9600 UART_BAUD(9600)
#define B19200 UART_BAUD(19200)
#define B38400 UART_BAUD(38400)
#define B57600 UART_BAUD(57600)
#define B115200 UART_BAUD(115200)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'mode' settings
#define UART_8N1 (unsigned char)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_7N1 (unsigned char)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_8N2 (unsigned char)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_7N2 (unsigned char)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_8E1 (unsigned char)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_7E1 (unsigned char)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_8E2 (unsigned char)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_7E2 (unsigned char)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_8O1 (unsigned char)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_7O1 (unsigned char)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_8O2 (unsigned char)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2)
#define UART_7O2 (unsigned char)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'fmode' settings
#define UART_FIFO_OFF (0x00)
#define UART_FIFO_1 (unsigned char)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)
#define UART_FIFO_4 (unsigned char)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)
#define UART_FIFO_8 (unsigned char)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)
#define UART_FIFO_14 (unsigned char)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)
void uart0Init(unsigned int baud, unsigned char mode, unsigned char fmode);
int uart0Putch(int ch);
unsigned int uart0Space(void);
const char *uart0Puts(const char *string);
int uart0TxEmpty(void);
void uart0TxFlush(void);
int uart0Getch(void);
void uart_sendchar(char c);
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -