To wrap printf() output to a specific character-put function to make use of string formatting, variable input and so forth.
I have implemented the USB CDC on an SAMD11 chip and want to be able to write variable data to the USB serial port. The USB CDC currently permits two functions udi_cdc_putc() which writes a single character, and udi_cdc_write_buf() which puts an entire string but must know the size.
If this were a c++ implementation I would likely create a new class and override the printf() virtual function to pass the data to udi_cdc_putc().
I am not familiar with how to accomplish something similar here. What method is the proffered method? I will need to format floating point variables and text primarily.
- sprintf() to a char buffer, loop through until \0 or \n with udi_cdc_putc()
- Use a stream override similar to virtual function
- Something else??