1 Reply Latest reply on Apr 17, 2020 7:41 PM by MoTa_728816

    Redirecting printf to anywhere I want it to go.

    EdHa_4455331

      I am working on a project that uses a CYBLE-416045 module. This particular module only brings out a relatively small number of I/O pins, and the system design has used them all up (plus needing an I/O expander IC). I do not have room to place a UART to use as the console port for printf(). But I really really want to be able to have a console output for when we are doing characterization and calibration of the sensors in the system. I have two solutions I can use:

       

      1) I found a UART IC that I can hang on the I2C bus and could use it as the UART that would go to an external PC.

      2) I can sometimes also redirect the output to the LCD that is in my system.

       

      Now, if I understand the overall system correctly, this should be relatively easy to implement (or at least straight forward). All I have to do is replace the _write function in retarget.c with functions that would understand my system's hardware and send the input string to where ever I want it to go - through the I2C bus to the UART IC or to the LCD.

       

      My first question is - Am I correct so far?

       

      There is one other point I need to check on. Right now, retarget.c is down in the Generated_Source section of the project. I could modify the code in retarget.c itself, but that code would get wiped out by a clean/generate operation. So, do I move a copy of retarget.c from the Generated_Source to my source code folder and then modify it there? But if I do that, how do I prevent the build process from finding multiple definitions for _write()?

       

      Thanks,

       

      Ed H.