zoukankan      html  css  js  c++  java
  • arm平台的printf.

    void Uart_Printf(char *fmt, ...)
    {
        va_list ap;
        char string[256];

        va_start(ap, fmt);
        vsprintf(string, fmt, ap);

        Uart_SendString(string);

        va_end(ap);
    }
    //只考虑一个字符串。
    简化版

    void Uart0_Printf(char *fmt)
    {

        char string[256];

        Uart0_SendString(string);
    }

    void Uart0_SendString(char *pt)
    {
        while (*pt)
            Uart0_SendByte(*pt++);
    }

    void Uart0_SendByte(int data)
    {

            if (data == '\n')
            {
                while (!(rUTRSTAT0 & 0x2));
                Delay(10);    //because the slow response of hyper_terminal
                WrUTXH0('\r');
            }
            while (!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
            Delay(10);
            WrUTXH0(data);

    }

    //缺点只有串口1;
    //寻找delay的替代,先不要管。粘贴入代码的时候删去

  • 相关阅读:
    摩根斯坦利面试
    Interview Preparation IV
    Interview Preparation III
    Interview Preparation II
    Interview Preparation I
    ASCII Characters
    Java Serialization
    贝莱德伦敦分部面试
    SVG基本知识
    前端知识整理(四)【HTTP相关】
  • 原文地址:https://www.cnblogs.com/titer1/p/2315995.html
Copyright © 2011-2022 走看看