mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ulp-riscv: made ulp_riscv_delay_cycles more accurate
This commit is contained in:
parent
b823831a26
commit
4f1046a292
@ -94,7 +94,16 @@ void ulp_riscv_timer_resume(void);
|
|||||||
*
|
*
|
||||||
* @param cycles Number of cycles to busy wait
|
* @param cycles Number of cycles to busy wait
|
||||||
*/
|
*/
|
||||||
void ulp_riscv_delay_cycles(uint32_t cycles);
|
void static inline ulp_riscv_delay_cycles(uint32_t cycles)
|
||||||
|
{
|
||||||
|
uint32_t start = ULP_RISCV_GET_CCOUNT();
|
||||||
|
/* Off with an estimate of cycles in this function to improve accuracy */
|
||||||
|
uint32_t end = start + cycles - 20;
|
||||||
|
|
||||||
|
while (ULP_RISCV_GET_CCOUNT() < end) {
|
||||||
|
/* Wait */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the GPIO wakeup interrupt bit
|
* @brief Clears the GPIO wakeup interrupt bit
|
||||||
|
@ -35,15 +35,6 @@ void ulp_riscv_halt(void)
|
|||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ulp_riscv_delay_cycles(uint32_t cycles)
|
|
||||||
{
|
|
||||||
uint32_t start = ULP_RISCV_GET_CCOUNT();
|
|
||||||
|
|
||||||
while ((ULP_RISCV_GET_CCOUNT() - start) < cycles) {
|
|
||||||
/* Wait */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ulp_riscv_timer_stop(void)
|
void ulp_riscv_timer_stop(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_TIMER_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_TIMER_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user