PebbleOS
Loading...
Searching...
No Matches
Functions
Idle and tick

Interface between the kernel and the SoC's tickless idle code. More...

Functions

void pbl_soc_idle (pbl_tick_t max_ticks)
 Idle the CPU.
 
bool pbl_soc_tick_enable (void)
 Set up the tick interrupt.
 
bool pbl_idle_confirm (void)
 Confirm that the CPU may still go to sleep.
 
void pbl_idle_slept (pbl_tick_t elapsed)
 Account for a sleep during which no tick interrupt ran.
 
void pbl_kernel_tick_isr (void)
 Tick interrupt body, for SoCs that own the SysTick handler.
 

Detailed Description

Interface between the kernel and the SoC's tickless idle code.

The SoC implements pbl_soc_idle() and pbl_soc_tick_enable(); the kernel provides the rest. A typical pbl_soc_idle():

void pbl_soc_idle(pbl_tick_t max_ticks) {
__disable_irq();
prv_timer_stop_tick();
prv_sleep_until(max_ticks);
pbl_idle_slept(prv_ticks_elapsed());
prv_timer_start_tick();
}
__enable_irq();
}
bool pbl_idle_confirm(void)
Confirm that the CPU may still go to sleep.
void pbl_idle_slept(pbl_tick_t elapsed)
Account for a sleep during which no tick interrupt ran.
void pbl_soc_idle(pbl_tick_t max_ticks)
Idle the CPU.
uint32_t pbl_tick_t
Kernel tick count.
Definition types.h:29

Function Documentation

◆ pbl_idle_confirm()

bool pbl_idle_confirm ( void  )

Confirm that the CPU may still go to sleep.

Call with interrupts masked.

Returns
false if something became runnable since the idle thread decided to sleep.

◆ pbl_idle_slept()

void pbl_idle_slept ( pbl_tick_t  elapsed)

Account for a sleep during which no tick interrupt ran.

Advances the tick count and expires the timeouts that fell due.

Parameters
elapsedTicks slept.

◆ pbl_kernel_tick_isr()

void pbl_kernel_tick_isr ( void  )

Tick interrupt body, for SoCs that own the SysTick handler.

◆ pbl_soc_idle()

void pbl_soc_idle ( pbl_tick_t  max_ticks)

Idle the CPU.

Implemented by the SoC. Runs on the idle thread when nothing is runnable, only for gaps of at least two ticks; may sleep. Once interrupts are masked it must check pbl_idle_confirm() before sleeping, and report through pbl_idle_slept() any ticks that passed while the tick interrupt was off.

Parameters
max_ticksTicks until the next timeout, PBL_TICK_FOREVER if none.

◆ pbl_soc_tick_enable()

bool pbl_soc_tick_enable ( void  )

Set up the tick interrupt.

Implemented by the SoC; called when the scheduler starts. A SoC that drives the tick itself calls pbl_kernel_tick_isr() from its handler.

Returns
true if the SoC set up the tick, false to let the kernel program SysTick itself.