zoukankan      html  css  js  c++  java
  • HI3531ARM调试printf的实现 分类: HI3531 arm-linux-Ubuntu 2013-12-16 15:56 501人阅读 评论(0) 收藏

    void UART_Putc(char c)
    {
        if (c == ' ')
      *(unsigned int *)(UART0_ADDR  + 0X00) =  ' ';
        delay_x(0x800);
     *(unsigned int *)(UART0_ADDR  + 0X00) = c;
     
    }
    unsigned int val_i=0;
    void UART_Print(const char *str,...)
    {
        va_list unnamed_p;
        char *sval;
        unsigned int tmp=0;
        va_start( unnamed_p, str);


        while (*str)
     {
         //
         if(*str=='%')
         {
           switch(*++str)
           {
               case 'd'://输出十进制
                   break;
               case 'c'://输出字符
                   break;
               case 's'://输出字符串
                   for(sval = va_arg(unnamed_p,char*);*sval;sval++)
                   {
                       UART_Putc(*sval);
                   }
                   str++;
                   break;
               case 'X'://输出16十进制
               case 'x'://输出16十进制
                   val_i = va_arg(unnamed_p,unsigned int);
                   //
                   UART_Putc('0');delay_x(0X800);
                   UART_Putc('x');delay_x(0X800);
                   for(i=0;i<8;i++)
                   {
                       delay_x(0X800);
                       tmp = val_i>>(4*(7-i));
                       val_i = val_i&(~(0xff<<(4*(7-i))));
                       //
                       if(tmp<10)
                           UART_Putc('0'+tmp);
                       else
                           UART_Putc('A'+tmp-10);
                       //
                   }
                   //
                   str++;
                   break;
              default://输出字符
                   break;
             
           }
         }
         //
      UART_Putc(*str++);
      
     }
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    shell语句for循环
    ls命令详解
    计算机相关概念总结(3)
    计算机相关概念总结(2)
    计算机相关概念总结(1)
    devops的概念
    jenkins无法连接gitlab
    Jenkins创建镜像后无法推送到harbor的问题
    Jenkins+gitlab+maven持续集成
    jenkins打完包在哪里
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706694.html
Copyright © 2011-2022 走看看