I tried the method suggested for the PSOC3 to replace the putchar() function, but that wouldn't even compile.
That's a PSOC3 specific for Keil compiler, yours is psoc5 and it would be GCC.
Try use sprintf to an array and use putstring to the UART you use.
Using the function sprintf() to get a formatted string would be the way I recommend. This string can be sent to LCD, UART or whatever your preferred output devive is.
I had aready figured that one out, but I was hoping for a more elegant solution.
I got this working on PSoC5LP with the GCC backend provided by PSoC Creator. The GCC backend in PSoC creator is a product "Sourcery G++ Lite" from CodeSourcery. They use NewLib for their libc implementation. NewLib relies on (small) stub functions, which you can define yourself. See https://sites.google.com/site/stm32discovery/open-source-development-wit... for an example of writing these stubs.
You can take a look in the installation directory of PSoC creator:
/cygdrive/c/Program Files (x86)/Cypress/PSoC Creator/2.2/PSoC Creator/import/gnu_cs/arm/4.4.1
$ ls share/doc/arm-arm-none-eabi/pdf/getting-started.pdf
$ ls share/doc/arm-arm-none-eabi/pdf/libc.pdf
That is very interesting. I would like to learn how to do this, Can you tell me what needs to be done?
Say if I have a UART named UART1, what is the procedure to use UART1 as the output of putchar().
As said, you need to write some stub functions, as done here: sites.google.com/site/stm32discovery/open-source-development-with-the-stm32-discovery/getting-newlib-to-work-with-stm32-and-code-sourcery-lite-eabi. So I added that file newlib_stubs.c to my project in PSoC Creator, and did some modifications. For the moment, I have commented out all stubs, except _isatty, _read, _write (I don't think you actually need to comment out the other stubs, but I didn't want to introduce too much new code the first time). I leaved _isatty as is, and modified _read, _write for my usage (i.e. input/output of UART in your case). The line #include "stm32f10x_usart.h" is of course replaced with the Cypress files you need.
Also note that printf with float formatting does not work here. This is good in our embedded environment, otherwise printf would take up more codespace.
I'll try that. :-)
Hmm, this might actually be exactly what I need
I am trying to port over a program that is full of scanf() and printf(). Creator compiles the functions with no errors, but nothing seems to happen when I run them. I will try to modify this to use a UART as stdin and stdout.
You may use printf() with formatting, floats and other things in PSoC5!
Works for me without any errors, just #include <stdio.h>.
Of course it will use some Ram and codespace, there are no such things as free meals.