mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 19:31:12 +00:00
util: Utilize BPMP sleep when usleep is out of bounds
This commit is contained in:
parent
23e246f224
commit
252a57ef6a
2 changed files with 14 additions and 6 deletions
|
@ -61,8 +61,12 @@ void usleep(u32 us)
|
||||||
{
|
{
|
||||||
#ifdef USE_RTC_TIMER
|
#ifdef USE_RTC_TIMER
|
||||||
u32 start = TMR(TIMERUS_CNTR_1US);
|
u32 start = TMR(TIMERUS_CNTR_1US);
|
||||||
// Casting to u32 is important!
|
|
||||||
while ((u32)(TMR(TIMERUS_CNTR_1US) - start) <= us)
|
// Check if timer is at upper limits and use BPMP sleep so it doesn't wake up immediately.
|
||||||
|
if ((start + us) < start)
|
||||||
|
bpmp_usleep(us);
|
||||||
|
else
|
||||||
|
while ((u32)(TMR(TIMERUS_CNTR_1US) - start) <= us) // Casting to u32 is important!
|
||||||
;
|
;
|
||||||
#else
|
#else
|
||||||
bpmp_usleep(us);
|
bpmp_usleep(us);
|
||||||
|
|
|
@ -60,8 +60,12 @@ void usleep(u32 us)
|
||||||
{
|
{
|
||||||
#ifdef USE_RTC_TIMER
|
#ifdef USE_RTC_TIMER
|
||||||
u32 start = TMR(TIMERUS_CNTR_1US);
|
u32 start = TMR(TIMERUS_CNTR_1US);
|
||||||
// Casting to u32 is important!
|
|
||||||
while ((u32)(TMR(TIMERUS_CNTR_1US) - start) <= us)
|
// Check if timer is at upper limits and use BPMP sleep so it doesn't wake up immediately.
|
||||||
|
if ((start + us) < start)
|
||||||
|
bpmp_usleep(us);
|
||||||
|
else
|
||||||
|
while ((u32)(TMR(TIMERUS_CNTR_1US) - start) <= us) // Casting to u32 is important!
|
||||||
;
|
;
|
||||||
#else
|
#else
|
||||||
bpmp_usleep(us);
|
bpmp_usleep(us);
|
||||||
|
|
Loading…
Reference in a new issue