添加cpu时钟周期延时
This commit is contained in:
@@ -65,6 +65,26 @@ void IRAM_ATTR iot_delay_us_cpu_cycle(uint32_t us)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR iot_delay_cpu_cycle(uint32_t c)
|
||||||
|
{
|
||||||
|
uint64_t start, now;
|
||||||
|
uint64_t cycle = c;
|
||||||
|
|
||||||
|
start = cpu_get_mcycle();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
now = cpu_get_mcycle();
|
||||||
|
if (now >= start) {
|
||||||
|
if((now - start) > cycle)
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if(((uint64_t)(-1) - start + now) > cycle)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void system_cpu_sleep(bool_t tick)
|
void system_cpu_sleep(bool_t tick)
|
||||||
{
|
{
|
||||||
clk_sys_sleep(tick);
|
clk_sys_sleep(tick);
|
||||||
|
@@ -36,6 +36,8 @@ void iot_delay_us(uint32_t us);
|
|||||||
*/
|
*/
|
||||||
void iot_delay_us_cpu_cycle(uint32_t us);
|
void iot_delay_us_cpu_cycle(uint32_t us);
|
||||||
|
|
||||||
|
void iot_delay_cpu_cycle(uint32_t c);
|
||||||
|
|
||||||
void system_cpu_sleep();
|
void system_cpu_sleep();
|
||||||
|
|
||||||
void system_cpu_wakeup();
|
void system_cpu_wakeup();
|
||||||
|
Reference in New Issue
Block a user