📄 serial.c
字号:
//****************************************************************************//// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -