mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +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,9 +61,13 @@ 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);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,9 +60,13 @@ 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);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue