⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uartecho.c

📁 Cirrus Logic EP7312处理器部分控制程序。
💻 C
字号:
//****************************************************************************
//
// UARTECHO.C - Echos characters received on a UART port.
//
// Copyright (c) 1998-1999 Cirrus Logic, Inc.
//
//****************************************************************************
#include "lib7312.h"

//****************************************************************************
//
// PORT is the UART port on which to echo characters.  It can be either 1 or
// 2.
//
//****************************************************************************
#define PORT 1

//****************************************************************************
//
// This program reads characters from a UART port and sends them back out to
// the same UART port, until a '-' character is received (which is not
// sent back out the UART).
//
//****************************************************************************
void
entry(void)
{
    char *pcMsg = "\r\nType data to be echo-ed:\r\n";
    char cChar;

    //
    // Enable the UART at 9600 baud, 8-N-1.
    //
    UARTEnable(PORT, 9600, 8, 1, 0, 0);

    //
    // Send out our usage message to the UART.
    //
    while(*pcMsg)
    {
        UARTSendChar(PORT, *pcMsg++);
    }

    //
    // Read characters from the UART until a '-' is read.
    //
    while((cChar = UARTReceiveChar(PORT)) != '-')
    {
        //
        // Send the character which we've just read back out to the same UART.
        //
        UARTSendChar(PORT, cChar);

        //
        // If the character was a line feed, then send a carriage return as
        // well.
        //
        if(cChar == '\r')
        {
            UARTSendChar(PORT, '\n');
        }
    }

    //
    // Disable the UART.
    //
    UARTDisable(PORT);
}

⌨️ 快捷键说明

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