[mw_shl_code=c,true]void delay_ms(u16 nms)
{
u32 temp;
if( SysTick->CTRL==0x00 )
{
SysTick->LOAD=(u32)nms*fac_ms;
SysTick->VAL =0x00;
SysTick->CTRL=0x01;
do
{
temp=SysTick->CTRL;
}
while((temp&0x01)&&!(temp&(1<<16)));
SysTick->CTRL=0x00;
SysTick->VAL =0X00
}
else
{
temp = SysTick->VAL;
SysTick->CTRL=0x00;
SysTick->VAL =0X00;
delay_ms(nms);
if(nms*fac_ms<temp)
{
SysTick->LOAD = temp - nms*fac_ms;
SysTick->CTRL = 0x01;
}
}
}[/mw_shl_code] |