📄 uart.h
字号:
#ifndef _VGUART_H
#define _VGUART_H
/***********************************************
Data types
************************************************/
#define vgNULL 0L
#define vgTRUE 1
#define vgFALSE 0
typedef short int vgBOOL;
typedef signed char S8;
typedef signed short int S16;
typedef signed long S32;
typedef unsigned char U8;
typedef unsigned short int U16;
typedef unsigned long U32;
/***********************************************
* Uart Functions
* *********************************************/
// UART DATA BIT
#define DATABIT7 0x00
#define DATABIT8 0x01
// UART STOP BIT
#define STOPBIT1 0x00
#define STOPBIT2 0x02
// UART PARITY BIT
#define PARITYNONE 0x00
#define PARITYODD 0x0c
#define PARITYEVEN 0x08
// Clock Select
#define INTERCLOCK 0x00
#define EXCLOCK 0x10
// Receive Interrupt
#define RINTDS 0x00
#define RINTEN 0x20
// Send Break
#define NOSENDBK 0x00
#define SDNBK 0x40
// Loop Back Test
#define LOOPNOR 0x00
#define LOOPEN 0x80
// Uart Enable
#define DSUART 0x000
#define ENUART 0x100
// UART COMMUNICATION VELOCITY(bps)
#define BPS1200 1200
#define BPS2400 2400
#define BPS4800 4800
#define BPS9600 9600
#define BPS19200 19200
#define BPS38400 38400
#define BPS57600 57600
#define BPS115200 115200
// Serial Clock
#define CLOCK 3686400 //3.6864MHz
//#define CLOCK 80000000
#define UART_CH0_ON() writew(REG_UCON0, readw(REG_UCON0) | 0x100)
#define UART_CH0_OFF() writew(REG_UCON0, readw(REG_UCON0) & 0xfeff)
#define UART_CH1_ON() writew(REG_UCON1, readw(REG_UCON1) | 0x100)
#define UART_CH1_OFF() writew(REG_UCON1, readw(REG_UCON1) & 0xfef)
U8 UartIsRxCh0(void);
U8 UartIsRxCh1(void);
U8 UartIsTxCh0(void);
U8 UartIsTxCh1(void);
U8 UartRxCharCh0();
U8 UartRxCharCh1();
void UartTxCharCh0(U8 ch);
void UartTxCharCh1(U8 ch);
void UartTxStringCh0(U8* string);
void UartTxStringCh1(U8* string);
void UartPrintfCh0( const char* const message, ... );
void UartPrintfCh1( const char* const message, ... );
void UartConfigCh0(U32 config_data, U32 BaudRate);
void UartConfigCh1(U32 config_data, U32 BaudRate);
#endif /* _VGUART_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -