野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10519|回复: 1

RTC实时时钟

[复制链接]
发表于 2015-8-15 21:00:16 | 显示全部楼层 |阅读模式
static uint8_t USART_Scanf(uint32_t value)
{
          uint32_t index = 0;
          uint32_t tmp[2] = {0, 0};
       
          while (index < 2)
          {
            /* Loop until RXNE = 1 */
            while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET)
            {
                        }
               
            tmp[index++] = (USART_ReceiveData(USART1));
            if ((tmp[index - 1] < 0x30) || (tmp[index - 1] > 0x39))   /*êy×&#214;0μ&#189;9μ&#196;ASCII&#194;&#235;&#206;a0x30&#214;á0x39*/
            {                   
                      printf("\n\rPlease enter valid number between 0 and %d -->:  ",value);
              index--;                  
            }
          }
          
          /* &#188;&#198;&#203;&#227;ê&#228;è&#235;×&#214;·&#251;μ&#196;ASCII&#194;&#235;×a&#187;&#187;&#206;aêy×&#214;*/
          index = (tmp[1] - 0x30) + ((tmp[0] - 0x30) * 10);
               
          /* Checks */
          if (index > value)
          {
            printf("\n\rPlease enter valid number between 0 and %d", value);
            return 0xFF;
          }
          return index;
}
这段代码有点看不懂啊  求解

回复

使用道具 举报

发表于 2015-8-16 12:29:37 | 显示全部楼层
接收串口发送过来的字符串,用来设置时间
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-6 07:20 , Processed in 0.024370 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表