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

📄 uart.c

📁 专门针对avr系列的单片机优化的fft算法
💻 C
字号:
#include "uart.h"
#include "LCD.h"

extern volatile unsigned char backlight;;

void sentchar1 (unsigned char datasent)
{
	while (!( UCSR1A & (1<<UDRE)));
	UDR1 = datasent;
}

void printPRGstr1 (const char *str)
{
	unsigned char tmpchar;

	tmpchar = pgm_read_byte(str++);
	while (tmpchar!='\0')
	{
		sentchar1(tmpchar);
		tmpchar = pgm_read_byte(str++);
	}
}

void uart_initial (void)
{
	unsigned int bauddiv;
		
	/* Set baud rate */
	bauddiv = fosc/(baudrate*16L)-1;
	UBRR1H = (unsigned char)(bauddiv>>8);
	UBRR1L = (unsigned char)bauddiv;

	/* Enable RxD/TxD and interrupts of USART1*/
	UCSR1B = (1<<RXEN1)|(1<<TXEN1)|(1<<RXCIE1);//|(1<<TXCIE1);

	// enable interrupts
	sei();
	
	print("UART1: 57600 bps @ 8n1\r\n");
}

SIGNAL(SIG_UART1_RECV)
{
	unsigned char charrev;
	
	charrev = UDR1;			
	switch (charrev)
	{
		case 'l':	// LCD backlight
			{
				BKLIGHT;
			}break;
		default:
			{
				;
			}
	}
}

⌨️ 快捷键说明

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