/******************************************************************************* * Function Name : DS18B20_Delay * Description : 精确延时us,参数范围0~1000.利用SysTick延时 * Input : 延时时间 * Output : None * Return : None *******************************************************************************/ void OWDelay(unsigned int t) { unsigned int start,total,diff = 0; unsigned int count = 0; unsigned int temp; #if OS_CRITICAL_METHOD == 3 OS_CPU_SR cpu_sr = 0; #endif temp = 10000*SYSCLK_1US; OS_ENTER_CRITICAL(); start = SysTick_GetCounter(); total = t*SYSCLK_1US; while(diff < total) { count = SysTick_GetCounter(); if(start < count) { diff = temp - (count - start); } else { diff = start -count; } } OS_EXIT_CRITICAL(); }
void stop() { enabled = 0; us_counter_end = SysTick_GetCounter(); }
void start() { us_counter = SysTick_GetCounter(); enabled = 1; }