#![no_std] #![doc = "Peripheral access API (generated using chiptool v0.1.0 (150ce4a 2023-03-22))"] mod common { use core::marker::PhantomData; #[derive(Copy, Clone, PartialEq, Eq)] pub struct RW; #[derive(Copy, Clone, PartialEq, Eq)] pub struct R; #[derive(Copy, Clone, PartialEq, Eq)] pub struct W; mod sealed { use super::*; pub trait Access {} impl Access for R {} impl Access for W {} impl Access for RW {} } pub trait Access: sealed::Access + Copy {} impl Access for R {} impl Access for W {} impl Access for RW {} pub trait Read: Access {} impl Read for RW {} impl Read for R {} pub trait Write: Access {} impl Write for RW {} impl Write for W {} #[derive(Copy, Clone, PartialEq, Eq)] pub struct Reg { ptr: *mut u8, phantom: PhantomData<*mut (T, A)>, } unsafe impl Send for Reg {} unsafe impl Sync for Reg {} impl Reg { #[inline(always)] pub fn from_ptr(ptr: *mut u8) -> Self { Self { ptr, phantom: PhantomData, } } #[inline(always)] pub fn ptr(&self) -> *mut T { self.ptr as _ } } impl Reg { #[inline(always)] pub unsafe fn read(&self) -> T { (self.ptr as *mut T).read_volatile() } } impl Reg { #[inline(always)] pub unsafe fn write_value(&self, val: T) { (self.ptr as *mut T).write_volatile(val) } } impl Reg { #[inline(always)] pub unsafe fn write(&self, f: impl FnOnce(&mut T) -> R) -> R { let mut val = Default::default(); let res = f(&mut val); self.write_value(val); res } } impl Reg { #[inline(always)] pub unsafe fn modify(&self, f: impl FnOnce(&mut T) -> R) -> R { let mut val = self.read(); let res = f(&mut val); self.write_value(val); res } } } mod TIMER0 mod TIMER1 mod TIMER2