📄 console.c
字号:
#include <stdio.h>
#include "Option.h"
#include "2460lib.h"
#if !SEMIHOSTING
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */};
FILE __stdout;
FILE __stdin;
FILE __stderr;
//NOTE.
//1. If __FILE is redefined by user, the fgetc(),fputc(),ferror(),defined by user,are used.
//2. __stdout,__stdin should be redefined .
// If the semihosting is not used,
// redefine fputc(),fgetc(),ferror() for printf/scanf through UART
int fputc(int ch, FILE *f)
{
/* Place your implementation of fputc here */
/* e.g. write a character to a UART, or to the debugger console with SWI WriteC */
Uart_putc(ch);
return ch;
}
int ferror(FILE *f)
{ /* Your implementation of ferror */
return EOF;
}
int fgetc(FILE *f)
{
int ch;
ch=Uart_getc();
Uart_putc(ch);
switch(ch){
case 0xd : ch=0xa;
break;
case '\b' : Uart_putc(' ');
Uart_putc('\b');
break;
}
return ch;
}
char *gets( char *s)
{
int c;
int i=0;
while((c = getchar())!=0xa) {
if(c=='\b') {
if (i>0) i--;
} else {
s[i++]=(char)c;
}
}
s[i]='\0';
return s;
}
void _ttywrch(int ch)
{
Uart_putc(ch);
}
void _sys_exit(int return_code)
{
while(1);
}
#endif //!SEMIHOSTING
void Init_LogicalConsole( void)
{
#if !SEMIHOSTING
Uart_Init(0,115200);
#else
setbuf(stdin,NULL);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -