serial.c

来自「嵌入式系统 EP93xx处理器」· C语言 代码 · 共 70 行

C
70
字号
//****************************************************************************//// SERIAL.h - The common serial definition for ep93xx//// Copyright (c) 2006 Cirrus Logic, Inc.////****************************************************************************//****************************************************************************//   Platform specific declaration//****************************************************************************#include "ep93xx.h"#include "serial.h"//****************************************************************************//   Function definition//****************************************************************************//****************************************************************************// Name       : Serial_Init// Description: This routine initializes the serial port by setting//              its baud rate & FIFO buffer.// Arguments  : wBaud     - Baud Rate in bit/sec.//              bFifoFlag - FIFO flag.//                          True  - FIFO enabled.//                          False - FIFO disabled.// Return     : none.// Note(s)    ://****************************************************************************void Serial_Init(int wBaud, int bFifoFlag){	// Enable uart 1 clock	set(DEVICECFG, BIT18);	// Clear the status	out(UART1RXSTS, 0);	// Set uart 1	out(UART1LINCTRLHIGH, (BIT6|BIT5|(bFifoFlag<<4)));	out(UART1LINCTRLMID, 0);	out(UART1LINCTRLLOW, wBaud);	// Enable uart 1	out(UART1CTRL, 1);}//****************************************************************************// Name       : Serial_GetChar// Description: This routine waits for a character from the serial port//              & returns it.// Arguments  : none.// Return     : Returns the character read from the serial port.// Note(s)    ://****************************************************************************char Serial_GetChar(void){        while(in(UART1FLAG) & BIT4);        return inb(UART1DATA);}//****************************************************************************// Name       : Serial_SendChar// Description: This routine waits till the character is sent.// Arguments  : bData - Data to be sent.// Return     : none.// Note(s)    ://****************************************************************************void Serial_SendChar(char bData){        while(in(UART1FLAG) & BIT5); //Wait until THR is empty.        outb(UART1DATA, bData);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?