This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to rework "printf" function to use for two UARTS in the cygnal's MCU?

Hi,everyone!
A problem here:The cygnal's MCU has two
serial ports,so "printf" function must be reworked.But I don't know how to do it.
Give me a hand!
Thanks a lot!

Parents
  • Instead of if (debug) clauses, try this:

    #ifdef DBG
    #    define debug
    #else
    #    define debug while (0)
    #endif
    
    // Usage: single line
    debug printf("Got here\n");
    
    // Usage: multiple line
    debug
    {
        g_errno = 12;
        printf("Got error, %d\n", g_errno);
    }

    Now watch the magic happen when you don't define DBG.

    Regards.

    - Mark

Reply
  • Instead of if (debug) clauses, try this:

    #ifdef DBG
    #    define debug
    #else
    #    define debug while (0)
    #endif
    
    // Usage: single line
    debug printf("Got here\n");
    
    // Usage: multiple line
    debug
    {
        g_errno = 12;
        printf("Got error, %d\n", g_errno);
    }

    Now watch the magic happen when you don't define DBG.

    Regards.

    - Mark

Children