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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.