uarttest.c

来自「AVR GCC下的 UART C源代码」· C语言 代码 · 共 87 行

C
87
字号
//uartTest.c : source file for the uartTest project
//

/*
    Title:    AVR-GCC test program #7 for the STK200 eva board
    Authors:  Pieter Conradie, Volker Oth
    Date:     9/1999
    Purpose:  Demonstrates simple printing to and reading from the UART
    needed
    Software: AVR-GCC to compile
    needed
    Hardware: ATs90s08515/8535/Mega603 on STK200/300 board
    Note:     To contact me, mail to
                  volkeroth@gmx.de
              You might find more AVR related stuff at my homepage:
                  http://members.xoom.com/volkeroth
*/

#include "uartTest.h"
#include "uartTestUART.h"

/////////////////////////////////////////////////////////////////////////////
//uartTest

void IO_Init(void)
{
	//{{WIZARD_MAP(Chip)
	// Chip type: AT90S8515
	// Clock frequency: 4.0 MHz
	//}}WIZARD_MAP(Chip)

	//{{WIZARD_MAP(I/O Ports)
	// PortA
	PORTA = 0x0;
	DDRA = 0x0;
	// PortB
	PORTB = 0x0;
	DDRB = 0x0;
	// PortC
	PORTC = 0x0;
	DDRC = 0x0;
	// PortD
	PORTD = 0x0;
	DDRD = 0x0;
	//}}WIZARD_MAP(I/O Ports)

	//{{WIZARD_MAP(Watchdog)
	// Watchdog Disabled
	wdt_disable();
	//}}WIZARD_MAP(Watchdog)

	//{{WIZARD_MAP(Analog Comparator)
	// Analog Comparator Disabled
	ACSR = 0x80;
	//}}WIZARD_MAP(Analog Comparator)
}

int main(void)
{
	//{{WIZARD_MAP(Initialization)
	IO_Init();
	UART_Init();
	//}}WIZARD_MAP(Initialization)
	// TODO: Add extra initialization here
	u08 data;
	//{{WIZARD_MAP(Global interrupt)
	sei();
	//}}WIZARD_MAP(Global interrupt)
	PRINT("Hello World !");
	EOL();
	while(1)
	{
		// TODO: Add your code here
		PRINT((u08*)"Press any key...");
        EOL();
    
        data = UART_ReceiveByte();
    
        PRINT("You pressed '");
        UART_SendByte(data);
        PRINT("' which is 0x");
        UART_Printfu08(data);
        PRINT(" in hexadecimal.");
        EOL();
	}
}

⌨️ 快捷键说明

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