大学生
最后登录1970-1-1
在线时间 小时
注册时间2015-7-23
|
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×Ö0μ½9μÄASCIIÂëÎa0x30Öá0x39*/
{
printf("\n\rPlease enter valid number between 0 and %d -->: ",value);
index--;
}
}
/* ¼ÆËãêäèë×Ö·ûμÄASCIIÂë×a»»Îaêy×Ö*/
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;
}
这段代码有点看不懂啊 求解
|
|