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

📄 console.c

📁 三星S3C2460 USB DEVICE /USB HOST 监控代码
💻 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 + -