📄 retarget.c
字号:
/*
* This provides implementations of _sys_exit(), _ttywrch() and ___stackheap(), which are
* the bare minimum required to enable use of the ARM C libraries. Only some of the
* functionality of the libraries is available, for example any call to printf will cause
* a linker error as the libraries do not know how to output the characters.
*
* Please see Chapter 4 of the ARM Developer Suite Tools guide for more information
*
* Author: Paul
* =========================================================
*
* This is based opon the embed/rom example supplied with the ARM Developer Suite, so
* it's partly
*
* Copyright (C) ARM Limited, 1999. All rights reserved.
*
* and partly
*
* Copyright (c) Altera Corporation 2000.
* All rights reserved.
*
*/
#include <stdio.h>
#include <rt_misc.h>
#include "serial.h"
//struct __FILE { int handle; /* Add whatever you need here */};
//FILE __stdout;
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
void _ttywrch(int ch)
{
/*
* This function is supposed to output a character to the console
* given that we don't have one, we can't really do very much
*/
char tempch = ch;
sendchar( &tempch );
}
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 */
char tempch = ch;
sendchar( &tempch );
return ch;
}
int fgetc(FILE *f)
{
/* Place your implementation of fgetc here */
/* e.g. read a character from a UART */
char ch;
ch = receivechar();
// echo ???
sendchar((char *)&ch);
return (int)ch;
}
__value_in_regs struct __initial_stackheap __user_initial_stackheap(
unsigned R0, unsigned SP, unsigned R2, unsigned SL)
{
extern unsigned int Image$$COND_BIN_ARRAY$$Limit;
struct __initial_stackheap config;
/* Start the Heap at the end of the zero initialised data */
config.heap_base = (unsigned int)&Image$$COND_BIN_ARRAY$$Limit;
config.stack_base = SP;
return config;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -