?? serial.c
字號:
#include <io.h>
#include <stdlib.h>
#include <sig-avr.h>
#include <interrupt.h>
#include "serial.h"
#include "StdDefs.h"
#define ESC 0x1b
#define BUFF_SIZE 64
unsigned char CLR[] = {ESC, '[','H', ESC, '[', '2', 'J',0};
unsigned char UART_buffer[BUFF_SIZE];
unsigned char *inptr, *outptr;
unsigned char buff_cnt;
void init_uart(void)
{
inptr = UART_buffer;
outptr = UART_buffer;
buff_cnt = 0;
}
void clr(void)
{
//putstr(CLR); // Send a 'clear screen' to a VT100 terminal
}
int putchar(int c)
{
if (buff_cnt<BUFF_SIZE)
{
*inptr = c; // Put character into buffer
inptr++; // Increment pointer
buff_cnt++;
if (inptr >= UART_buffer + BUFF_SIZE) // Pointer wrapping
inptr = UART_buffer;
UART_CONTROL_REG = 0x38; // Enable UART Data register
// empty interrupt
return 1;
} else {
return 0; // Buffer is full
}
}
// Interrupt driven transmitter
SIGNAL(UART_REG_EMPTY_INT_VECTOR)
{
UART_DATA_REG = *outptr; // Send next byte
outptr++; // Increment pointer
if (outptr >= UART_buffer + BUFF_SIZE) // Pointer wrapping
outptr = UART_buffer;
if(--buff_cnt == 0) // If buffer is empty:
UART_CONTROL_REG = UART_CONTROL_REG && (1<<UDRIE); // disable interrupt
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -