uart.c
来自「ch375读U盘程序」· C语言 代码 · 共 26 行
C
26 行
//Code adapted from Ateml AVR Application Note AVR306
#include <avr/io.h>
//Initialize USART 115200bps at 8MHz
void InitUSART(void)
{
UCSRB = 0x00;
UCSRA = 0x02;
UCSRC = 0x86;
UBRRL = 0x08; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x18;
}
//Write function
void TransmitBytes(unsigned char *data)
{
while(*data != 0)
{
while(!( UCSRA & (1<<UDRE)) ) // 等待知道发送缓冲区空
;
UDR = *data++; // 把数据放入发送缓冲区 //store new index
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?