📄 uart.c
字号:
#include <avr/io.h>
#include <avr/wdt.h>
#include <stdio.h>
#include <avr/delay.h>
#include <avr/signal.h>
#include "MyDef.h"
#include "Uart.h"
#ifdef Debug
FILE mystd = FDEV_SETUP_STREAM(System_putchar, System_getchar,_FDEV_SETUP_RW); //虚拟设备
void Uart_Init(void)
{
UCSRB=_BV(RXEN)|_BV(TXEN);
UBRRL=25; //8M 19200
stdout=&mystd;
stdin=&mystd;
SetPrintfConvertMode=0;
}
int System_putchar(char c, FILE *stream)
{
if(SetPrintfConvertMode==1)
{
}
else
{
if (c == '\n')
System_putchar('\r', stream);
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
}
return 0;
}
int System_getchar( FILE *stream)
{
loop_until_bit_is_set(UCSRA,RXC);
return UDR;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -