3-W806-Delay_Us_Ms

void Delay_Us(uint8_t freq,uint32_t time)
{
    uint32_t i;
    uint16_t num = 90;
    switch(freq)
    {
        case 240: num = 80;break;
        case 160: num = 53;break;
        default: printf("delay input freq err...default set 240MHZ us time \r\n ");break;
    }
    
    for (i = 0; i < (num)*time; i++)
    {
        __NOP();
    }
}
void Delay_Ms(uint8_t freq,uint32_t time)
{
    uint32_t i;
    uint16_t num = 90;
    switch(freq)
    {
        case 240: num = 80;break;
        case 160: num = 53;break;
        default: printf("delay input freq err...default set 240MHZ us time \r\n ");break;
    }
    
    for (i = 0; i < (num)*time*1000; i++)
    {
        __NOP();
    }
}

你可能感兴趣的:(W801_W806学习记录,单片机)