8 Replies Latest reply on Sep 20, 2015 12:09 PM by user_14586677

    Printf with USBUART

    dude.notmyname

      Hi,

         

      So, I'm trying to get the USBUART on a CY8CKIT-059 to act as a virtual COM port and I have everything working except being able to use printf().  

         

      I've read through other forum posts on the subject that recommend "modifying _write" function, but I'm not sure how to do that.  I think maybe the example was for a true UART or something because it didn't make much sense to me; like I'm missing some other declaration or header in the beginning to tie it all together.  I've been referring to:
      http://www.cypress.com/forum/psoc-5-device-programming/how-do-i-do-printf-function-psoc5

         

       

         

      I have attached my whole test code, but below is the beginning:

         

       

         

      #include <device.h>
      #include "stdio.h"

         

      #if (CY_PSOC5LP)
      /* For GCC compiler revise _write() function */
      int _write(int file, char *ptr, int len)
          {
              int i;
              for (i = 0; i < len; i++)
              {
                  USBUART_1_PutChar(*ptr++);
              }
              return(len);
          }
      #endif /* CY_PSOC5 */