#![doc = "Peripheral access API for NEORV32 microcontrollers (generated using svd2rust v0.37.1 ( ))\n\nYou can find an overview of the generated API [here].\n\nAPI features to be included in the [next] svd2rust release can be generated by cloning the svd2rust [repository], checking out the above commit, and running `cargo doc --open`.\n\n[here]: https://docs.rs/svd2rust/0.37.1/svd2rust/#peripheral-api\n[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]: https://github.com/rust-embedded/svd2rust"]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[doc = r"Number available in the NVIC for configuring priority"]
pub const NVIC_PRIO_BITS: u8 = 4;
#[allow(unused_imports)]
use generic::*;
#[doc = r"Common register and bit access and modify traits"]
pub mod generic;
#[doc = r" Interrupt numbers, priority levels, and HART IDs."]
pub mod interrupt;
riscv_peripheral :: clint_codegen ! (Clint , base 0xFFF40000 , mtime_freq 0 , harts [crate :: interrupt :: Hart :: H0 => 0 , crate :: interrupt :: Hart :: H1 => 1]);
impl Clint {
#[doc = r" Steal an instance of this peripheral"]
#[doc = r""]
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" Ensure that the new instance of the peripheral cannot be used in a way"]
#[doc = r" that may race with any existing instances, for example by only"]
#[doc = r" accessing read-only or write-only registers, or by consuming the"]
#[doc = r" original peripheral and using critical sections to coordinate"]
#[doc = r" access between multiple new instances."]
#[doc = r""]
#[doc = r" Additionally, other software such as HALs may rely on only one"]
#[doc = r" peripheral instance existing to ensure memory safety; ensure"]
#[doc = r" no stolen instances are passed to such software."]
#[inline]
pub unsafe fn steal() -> Self {
Self::new()
}
}
#[doc = "Custom functions subsystem"]
pub type Cfs = crate::Periph<cfs::RegisterBlock, 0xffeb_0000>;
impl core::fmt::Debug for Cfs {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cfs").finish()
}
}
#[doc = "Custom functions subsystem"]
pub mod cfs;
#[doc = "Serial data interface controller"]
pub type Sdi = crate::Periph<sdi::RegisterBlock, 0xfff7_0000>;
impl core::fmt::Debug for Sdi {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sdi").finish()
}
}
#[doc = "Serial data interface controller"]
pub mod sdi;
#[doc = "Stream Link Interface"]
pub type Slink = crate::Periph<slink::RegisterBlock, 0xffec_0000>;
impl core::fmt::Debug for Slink {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Slink").finish()
}
}
#[doc = "Stream Link Interface"]
pub mod slink;
#[doc = "Direct memory access controller"]
pub type Dma = crate::Periph<dma::RegisterBlock, 0xffed_0000>;
impl core::fmt::Debug for Dma {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dma").finish()
}
}
#[doc = "Direct memory access controller"]
pub mod dma;
#[doc = "Pulse-width modulation controller"]
pub type Pwm = crate::Periph<pwm::RegisterBlock, 0xfff0_0000>;
impl core::fmt::Debug for Pwm {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pwm").finish()
}
}
#[doc = "Pulse-width modulation controller"]
pub mod pwm;
#[doc = "General purpose timer"]
pub type Gptmr = crate::Periph<gptmr::RegisterBlock, 0xfff1_0000>;
impl core::fmt::Debug for Gptmr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Gptmr").finish()
}
}
#[doc = "General purpose timer"]
pub mod gptmr;
#[doc = "1-Wire Interface Controller"]
pub type Onewire = crate::Periph<onewire::RegisterBlock, 0xfff2_0000>;
impl core::fmt::Debug for Onewire {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Onewire").finish()
}
}
#[doc = "1-Wire Interface Controller"]
pub mod onewire;
#[doc = "Primary universal asynchronous receiver and transmitter"]
pub type Uart0 = crate::Periph<uart0::RegisterBlock, 0xfff5_0000>;
impl core::fmt::Debug for Uart0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Uart0").finish()
}
}
#[doc = "Primary universal asynchronous receiver and transmitter"]
pub mod uart0;
#[doc = "Secondary universal asynchronous receiver and transmitter"]
pub type Uart1 = crate::Periph<uart0::RegisterBlock, 0xfff6_0000>;
impl core::fmt::Debug for Uart1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Uart1").finish()
}
}
#[doc = "Secondary universal asynchronous receiver and transmitter"]
pub use self::uart0 as uart1;
#[doc = "Serial peripheral interface controller"]
pub type Spi = crate::Periph<spi::RegisterBlock, 0xfff8_0000>;
impl core::fmt::Debug for Spi {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Spi").finish()
}
}
#[doc = "Serial peripheral interface controller"]
pub mod spi;
#[doc = "Two-wire interface controller"]
pub type Twi = crate::Periph<twi::RegisterBlock, 0xfff9_0000>;
impl core::fmt::Debug for Twi {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Twi").finish()
}
}
#[doc = "Two-wire interface controller"]
pub mod twi;
#[doc = "Two-wire device controller"]
pub type Twd = crate::Periph<twd::RegisterBlock, 0xffea_0000>;
impl core::fmt::Debug for Twd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Twd").finish()
}
}
#[doc = "Two-wire device controller"]
pub mod twd;
#[doc = "True random number generator"]
pub type Trng = crate::Periph<trng::RegisterBlock, 0xfffa_0000>;
impl core::fmt::Debug for Trng {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Trng").finish()
}
}
#[doc = "True random number generator"]
pub mod trng;
#[doc = "Watchdog timer"]
pub type Wdt = crate::Periph<wdt::RegisterBlock, 0xfffb_0000>;
impl core::fmt::Debug for Wdt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Wdt").finish()
}
}
#[doc = "Watchdog timer"]
pub mod wdt;
#[doc = "General purpose input/output port"]
pub type Gpio = crate::Periph<gpio::RegisterBlock, 0xfffc_0000>;
impl core::fmt::Debug for Gpio {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Gpio").finish()
}
}
#[doc = "General purpose input/output port"]
pub mod gpio;
#[doc = "Smart LED hardware interface"]
pub type Neoled = crate::Periph<neoled::RegisterBlock, 0xfffd_0000>;
impl core::fmt::Debug for Neoled {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Neoled").finish()
}
}
#[doc = "Smart LED hardware interface"]
pub mod neoled;
#[doc = "Execution Trace Buffer"]
pub type Tracer = crate::Periph<tracer::RegisterBlock, 0xfff3_0000>;
impl core::fmt::Debug for Tracer {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tracer").finish()
}
}
#[doc = "Execution Trace Buffer"]
pub mod tracer;
#[doc = "System configuration information memory"]
pub type Sysinfo = crate::Periph<sysinfo::RegisterBlock, 0xfffe_0000>;
impl core::fmt::Debug for Sysinfo {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sysinfo").finish()
}
}
#[doc = "System configuration information memory"]
pub mod sysinfo;
#[unsafe(no_mangle)]
static mut DEVICE_PERIPHERALS: bool = false;
#[doc = r" All the peripherals."]
#[allow(non_snake_case)]
pub struct Peripherals {
#[doc = "CFS"]
pub cfs: Cfs,
#[doc = "SDI"]
pub sdi: Sdi,
#[doc = "SLINK"]
pub slink: Slink,
#[doc = "DMA"]
pub dma: Dma,
#[doc = "PWM"]
pub pwm: Pwm,
#[doc = "GPTMR"]
pub gptmr: Gptmr,
#[doc = "ONEWIRE"]
pub onewire: Onewire,
#[doc = "CLINT"]
pub clint: Clint,
#[doc = "UART0"]
pub uart0: Uart0,
#[doc = "UART1"]
pub uart1: Uart1,
#[doc = "SPI"]
pub spi: Spi,
#[doc = "TWI"]
pub twi: Twi,
#[doc = "TWD"]
pub twd: Twd,
#[doc = "TRNG"]
pub trng: Trng,
#[doc = "WDT"]
pub wdt: Wdt,
#[doc = "GPIO"]
pub gpio: Gpio,
#[doc = "NEOLED"]
pub neoled: Neoled,
#[doc = "TRACER"]
pub tracer: Tracer,
#[doc = "SYSINFO"]
pub sysinfo: Sysinfo,
}
impl Peripherals {
#[doc = r" Returns all the peripherals *once*."]
#[cfg(feature = "critical-section")]
#[inline]
pub fn take() -> Option<Self> {
critical_section::with(|_| {
if unsafe { DEVICE_PERIPHERALS } {
return None;
}
Some(unsafe { Peripherals::steal() })
})
}
#[doc = r" Unchecked version of `Peripherals::take`."]
#[doc = r""]
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" Each of the returned peripherals must be used at most once."]
#[inline]
pub unsafe fn steal() -> Self {
unsafe { DEVICE_PERIPHERALS = true }
Peripherals {
cfs: unsafe { Cfs::steal() },
sdi: unsafe { Sdi::steal() },
slink: unsafe { Slink::steal() },
dma: unsafe { Dma::steal() },
pwm: unsafe { Pwm::steal() },
gptmr: unsafe { Gptmr::steal() },
onewire: unsafe { Onewire::steal() },
clint: unsafe { Clint::steal() },
uart0: unsafe { Uart0::steal() },
uart1: unsafe { Uart1::steal() },
spi: unsafe { Spi::steal() },
twi: unsafe { Twi::steal() },
twd: unsafe { Twd::steal() },
trng: unsafe { Trng::steal() },
wdt: unsafe { Wdt::steal() },
gpio: unsafe { Gpio::steal() },
neoled: unsafe { Neoled::steal() },
tracer: unsafe { Tracer::steal() },
sysinfo: unsafe { Sysinfo::steal() },
}
}
}