Function determine_prio_bits

Source
pub unsafe fn determine_prio_bits<T: InterruptNumber>(
    nvic: &mut NVIC,
    placeholder_interrupt: T,
) -> u8
Expand description

Determine the amount of priority bits available on the current MCU.

This function determines the amount of priority bits available on a Cortex-M MCU by setting the priority of an interrupt to the maximum value 0xFF, and reading the resulting priority.

The count of leading ones in the resulting value indicates the amount of priority-level bits available.

After performing this calculation, the priority of the placeholder interrupt is not restored.

It is guaranteed that all non-implemented priority bits will be read back as zero for any NVIC implementation that conforms to the GIC (see section 3.5.1), which includes at least all armv7m (see section B1.5.4) and armv6m (see section B3.4) cores.

ยงSafety

This function should only be called from a critical section, as it alters the priority of an interrupt.

The caller must restore the priority of placeholder_interrupt to a known-and-valid priority after calling this function, as determine_prio_bits does not restore the overwritten priority.