![]() |
CMSIS-Compiler Support
Version 1.0.0
Standard C Library File, I/O and OS Retargeting
|
CMSIS-Compiler splits low-level I/O retargeting into standard I/O stream related components and file stream related components.
The low-level I/O retarget decision tree is below:
Low-Level I/O retargeting implementation checks whether the incoming stream is a standard stream (i.e. stderr, stdin, stdout) or a file system related stream and redirects incoming request to the appropriate software component. Chapter I/O Components explains these software components in detail.
CMSIS-Compiler:I/O software component can retarget the input/output functions to the following channels:
Component | Description |
---|---|
File | Channel for all file stream related operations. |
STDERR | Standard error stream of the application to output diagnostic messages. |
STDIN | Standard input stream going into the application (scanf etc.). |
STDOUT | Standard output stream of the application (printf etc.). |
TTY | Teletypewriter, which is the last resort for error output. |
Most retargeting channels have various I/O Retarget Variants.
The variant selection allows you to change the target hardware interface of the I/O channel.
The following variants are available:
Variant | Description |
---|---|
File Interface | Use the File Interface API for file related operations. |
Breakpoint | When the I/O channel is used, the application stops with BKPT instruction. No additional code is required. |
The following variants are available:
Variant | Description |
---|---|
Breakpoint | When the I/O channel is used, the application stops with BKPT instruction. No additional code is required. |
ITM | Use Instrumentation Trace Macrocell (ITM) for I/O communication via the debugger (only available for Cortex-M3/M4/M7/M33/M55/M85 processors). Usually, data is shown in a dedicated window. No additional code is required to output or input data through the ITM channel. However, you have to configure the ITM channel for tracing. |
User | Retarget I/O functions to a user defined interface (such as USART or application specific). See I/O Retarget Variant "User" for further details. |
EVR | STDOUT can also be redirected using the Event Recorder (especially interesting for targets without ITM (such as Cortex-M0/M0+/M23)). |
#defines
are set in the header file RTE_Components.h that enable the appropriate code sections in the retarget interface implementation file.The CMSIS-Compiler:I/O component variant User provides code templates that help you to implement the functionality.
In µVision, you can import the templates into a project using the context menu Add New Item to Group from the Project window. Depending on your selection, you get templates that support retargeting via display, USART, or keyboard. Also, a template for a custom implementation is available.
You may use a CMSIS-Driver USART or write your own output routines. The following user code templates are available:
Component | Name | File Name |
---|---|---|
I/O:STDOUT | STDOUT via USART | stdout_USART.c |
I/O:STDIN | STDIN via USART | stdin_USART.c |
I/O:STERR | STDERR via USART | stderr_USART.c |
Use these templates for custom interfaces that are not mentioned above. The following user code templates are available:
Component | Name | File Name |
---|---|---|
I/O:STDOUT | STDOUT User template | stdout_user.c |
I/O:STDIN | STDIN User template | stdin_user.c |
I/O:STERR | STDERR User template | stderr_user.c |
I/O:TTY | TTY User template | tty_user.c |
CMSIS-Compiler:File Interface software component provides generic shim layer interface between the C library and an arbitrary file system implementation.
Standard C library functions interact with files in a same manner as with standard I/O streams and offer the same retargeting interface. The existing interface is split to enable component interchangeability and File Interface API is used to enable quick file system retargeting.
Default component is as follows:
Component | Description |
---|---|
Custom | Placeholder for custom File Interface implementation |
Custom component is available to enable access to File Interface API header file when application provides an custom implementation. Custom implementation is typically needed when file system components do not provide its own implementation. To help you implement the functionality the File Interface:Custom component also provides the code template.