打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
embedded To make printf(), puts() etc work on an embedded platform

To make printf(), puts()etc work on an embedded platform, you need to implement some hooks thatwork with the C library. This is typically dependent on the C librariesprovided with your compiler, so is probably compiler-dependent. But inmany cases the library just requires you to provide a putc() function (or similar name), which takes a character (generated by the printf() library function) and sends it to your chosen output device. That could be a memory buffer, serial port, USB message, whatever.

From the point of view of the C library, the putc()function would be run-to-completion, so it's up to you whether youimplement it to be a simple blocking function (waiting until the serialport is free and sending the character), or non-blocking (putting itinto a buffer, to be sent by a background interrupt task; but the buffermight fill up if you output enough bytes fast enough, and then you haveto either block or discard characters). You can also make it workproperly with your RTOS if you have one, implementing a blocking writethat sleeps on a semaphore until the serial port is available.

So, in summary, read the documentation for your compiler and its C library, and it should tell you what you need to do to make printf() work.

Example links for AVR micro with GCC compiler:

ARM GCC compiler using newlib C library:

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
lua
Cross-Platform GUI Library 介紹
[Python]HOWTO Cross Compile Python for ARM
qt-embedded-linux-opensource-src-4.5.1成功移植到micro2440
一些免费的Fortran编译器
游戏开发中免费的3D、2D引擎和图像软件包
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服