ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

[转载]I/O重定向

2022-05-02 17:01:30  阅读:203  来源: 互联网

标签:functions 重定向 level use library system low 转载


原文地址:https://www.keil.com/pack/doc/compiler/RetargetIO/html/_retarget__overview.html

 

 The software component Compiler allows you to retarget I/O functions of the standard C run-time library

Overview

Application code frequently uses standard I/O library functions, such as printf(), scanf(), or fgetc() to perform input/output operations. The structure of these functions in the standard ARM Compiler C run-time library is:

Function Structure

High-level and low-level functions are not target-dependent and use the system I/O functions to interface with hardware. However, the high-level library functions perform input/output by calling the low-level ones, which themselves call the system I/O functions, which are target-dependent.

To retarget input/output, you can:

  • Avoid the high-level library functions.
  • Redefine the low-level library functions.
  • Redefine the system I/O functions.

Whether redefining the low-level library functions or the system I/O functions is a better solution, depends on your use case. For example, UARTs write a single character at a time and the default fputc() uses buffering, so redefining this function without a buffer might suit a UART. However, where buffer operations are possible, redefining the system I/O functions would probably be more appropriate.

The MicroLib of the ARM Compiler C run-time library interfaces to the hardware via low-level functions. It implements a reduced set of high-level functions and therefore does not implement system I/O functions. Thus, in case of using the MicroLib, you cannot redefine the system I/O functions. Using any of the features of the ARM Compiler component provides the assert facility for MicroLib.

The page Retargeting Channels and Variants explains the details about how retargeting is done using the ARM Compiler component.

Semihosting

Semihosting is a mechanism that enables code running on an ARM target to communicate and use the Input/Output facilities on a host computer that is running a debugger.

Semihosting is not supported by µVision. Thus, you cannot use semihosting SWI operations. In case you have to write your own retarget code, ensure that no semihosting functions of the C library get linked into your application. This is done by importing the symbol __use_no_semihosting_swi. This can be done in any C or assembler source file in your project. In a C module, use the #pragma directive:

#pragma import(__use_no_semihosting_swi)

In an assembler module, use the IMPORT directive:

IMPORT __use_no_semihosting_swi

 

标签:functions,重定向,level,use,library,system,low,转载
来源: https://www.cnblogs.com/l0ne1y/p/16216149.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有