18.2. Handling printf

18.2.1. Overview

Based on the examples in the previous section, we can create our own string printing function to handling printing of text strings, as shown below.
// Uart string output
void UART_puts(char  mytext)
{
  char CurrChar;
  CurrChar = ∗mytext;
  while (CurrChar != (char) 0x0){
    UART_putc(CurrChar);  // Normal data
    mytext++;
    CurrChar = ∗mytext;
    }
  return;
}
This works great for printing constant strings. We can also use this function to print other information by using sprint function to print the information to a text buffer, and then output it using UART_puts, the string output function we created:
char txt_buf[30];
sprintf(txt_buf,"%d∖n",1234);
UART_puts(txt_buf);
However, it would also be useful if we can ...

Get The Definitive Guide to ARM® Cortex®-M0 and Cortex-M0+ Processors, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.