Skip to Main Content
Programming Embedded Systems, 2nd Edition
book

Programming Embedded Systems, 2nd Edition

by Michael Barr, Anthony Massa
October 2006
Intermediate to advanced content levelIntermediate to advanced
336 pages
9h 13m
English
O'Reilly Media, Inc.
Content preview from Programming Embedded Systems, 2nd Edition

Working with Serial Ports

We looked at a serial driver in Chapter 7. The Monitor and Control program uses the same serial driver with some additional functionality.

One change to the serial driver is the addition of a “put string” function, serialPutStr. This function, which follows, allows strings to be sent out the serial port through a single call rather than having to specify each character in order. This is similar to the standard C printf function, which calls the serialPutChar function repeatedly until the entire string has been transmitted out the serial port.

/**********************************************************************
 * 
 * Function:    serialPutStr
 *
 * Description: Outputs a string to the serial port.
 *
 * Notes:       
 *
 * Returns:     None.
 *
 **********************************************************************/
void serialPutStr(char const *pOutputStr)
{
    char const *pChar;

    /* Send each character of the string. */
    for (pChar = pOutputStr; *pChar != '\\0'; pChar++)
        serialPutChar(*pChar);
}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming with STM32: Getting Started with the Nucleo Board and C/C++

Programming with STM32: Getting Started with the Nucleo Board and C/C++

Donald Norris

Publisher Resources

ISBN: 0596009836Supplemental ContentErrata Page