#![no_std] pub type Instance = ral_registers::Instance; #[repr(C)] #[allow(non_snake_case)] pub struct RegisterBlock { pub REG0: u32, pub REG1: u32, pub REG2: u32, pub REG3: u32, } pub type DCDC = ral_registers::Instance; /// Set the target value of `VDD_SOC`, in millivolts /// /// Values are clamped between 800mV and 1575mV, with 25mV step /// sizes. pub fn set_target_vdd_soc(dcdc: DCDC, millivolts: u32) { let mv = millivolts.clamp(800, 1575); let trg = (mv - 800) / 25; ral_registers::modify_reg!(self, dcdc, REG3, TRG: trg); while ral_registers::read_reg!(self, dcdc, REG0, STS_DC_OK == 0) {} } /// Returns the target value of `VDD_SOC`, in millivolts. pub fn target_vdd_soc(dcdc: DCDC) -> u32 { let trg = ral_registers::read_reg!(self, dcdc, REG3, TRG); trg * 25 + 800 } ral_registers::register! { pub REG3 RW [ TRG start(0) width(5) RW {} ] } ral_registers::register! { pub REG0 RW [ STS_DC_OK start(31) width(1) RW {} ] }