#![no_std]
#![deny(missing_docs)]
#![allow(incomplete_features)]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub use fugit;
pub use rtic_time::{
self, monotonic::TimerQueueBasedMonotonic, timer_queue::TimerQueueBackend, Monotonic,
TimeoutError,
};
#[cfg(feature = "esp32c3-systimer")]
pub mod esp32c3;
#[cfg(feature = "esp32c6-systimer")]
pub mod esp32c6;
#[cfg(feature = "cortex-m-systick")]
pub mod systick;
#[cfg(feature = "rp2040")]
pub mod rp2040;
#[cfg(feature = "rp235x")]
pub mod rp235x;
#[cfg(feature = "imxrt")]
pub mod imxrt;
#[cfg(any(
feature = "nrf52805",
feature = "nrf52810",
feature = "nrf52811",
feature = "nrf52832",
feature = "nrf52833",
feature = "nrf52840",
feature = "nrf5340-app",
feature = "nrf5340-net",
feature = "nrf9160-ns",
feature = "nrf9160-s",
feature = "nrf9151-ns",
feature = "nrf9151-s",
feature = "nrf9161-ns",
feature = "nrf9161-s",
))]
pub mod nrf;
#[cfg(stm32)]
pub mod stm32;
#[cfg(feature = "silabs")]
pub mod silabs;
#[allow(dead_code)]
pub(crate) const fn cortex_logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 {
((1 << nvic_prio_bits) - logical) << (8 - nvic_prio_bits)
}
#[cfg(any(
feature = "silabs",
feature = "rp235x",
feature = "rp2040",
feature = "nrf52805",
feature = "nrf52810",
feature = "nrf52811",
feature = "nrf52832",
feature = "nrf52833",
feature = "nrf52840",
feature = "nrf5340-app",
feature = "nrf5340-net",
feature = "nrf9160-ns",
feature = "nrf9160-s",
feature = "nrf9151-ns",
feature = "nrf9151-s",
feature = "nrf9161-ns",
feature = "nrf9161-s",
feature = "imxrt",
stm32,
))]
pub(crate) unsafe fn set_monotonic_prio(
prio_bits: u8,
interrupt: impl cortex_m::interrupt::InterruptNumber,
) {
extern "C" {
static RTIC_ASYNC_MAX_LOGICAL_PRIO: u8;
}
let max_prio = RTIC_ASYNC_MAX_LOGICAL_PRIO.max(1).min(1 << prio_bits);
let hw_prio = crate::cortex_logical2hw(max_prio, prio_bits);
let mut nvic: cortex_m::peripheral::NVIC = core::mem::transmute(());
nvic.set_priority(interrupt, hw_prio);
}