fprintf() to serial port on AVR

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderator: tfAteba

Post Reply
JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

fprintf() to serial port on AVR

Post by JetForMe »

I'm thinking it would be nice to be able to call fprintf() and print directly to a serial port on the AVR. I don't know if there's already support for this or not.

Otherwise, I have to either malloc() or permanently assign space for a buffer to build the string (either statically, or by statically allocating a bigger stack). I figure internally, fprintf() outputs a byte at a time into the FILE structure, I just have to associate one with a call to sdWrite() somehow.

Any suggestions?

TIA!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: fprintf() to serial port on AVR

Post by Giovanni »

You should read the WinAVR C library documentation, I did something like that for ARM using newlib, a mechanism must exist for WinAVR too.

Be careful that the prinft-like functions can eat a lot of stack space.

Giovanni
Post Reply