diff --git a/docs/expanded_stm32f0xx.rs b/docs/expanded_stm32f0xx.rs deleted file mode 100644 index 1fef411..0000000 --- a/docs/expanded_stm32f0xx.rs +++ /dev/null @@ -1,3894 +0,0 @@ -#![feature(prelude_import)] -#![no_std] -#![allow(non_camel_case_types)] -#![allow(clippy::uninit_assumed_init)] -#[prelude_import] -use core::prelude::rust_2018::*; -#[macro_use] -extern crate core; -#[macro_use] -extern crate compiler_builtins; -pub use stm32f0; -#[cfg(any(feature = "stm32f030", feature = "stm32f070"))] -pub use stm32f0::stm32f0x0 as pac; -#[cfg(feature = "device-selected")] -pub mod adc { - //! # API for the Analog to Digital converter - //! - //! Currently implements oneshot conversion with variable sampling times. - //! Also references for the internal temperature sense, voltage - //! reference and battery sense are provided. - //! - //! ## Example - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::pac; - //! use crate::hal::prelude::*; - //! use crate::hal::adc::Adc; - //! - //! cortex_m::interrupt::free(|cs| { - //! let mut p = pac::Peripherals::take().unwrap(); - //! let mut rcc = p.RCC.configure().freeze(&mut p.FLASH); - //! - //! let gpioa = p.GPIOA.split(&mut rcc); - //! - //! let mut led = gpioa.pa1.into_push_pull_pull_output(cs); - //! let mut an_in = gpioa.pa0.into_analog(cs); - //! - //! let mut delay = Delay::new(cp.SYST, &rcc); - //! - //! let mut adc = Adc::new(p.ADC, &mut rcc); - //! - //! loop { - //! let val: u16 = adc.read(&mut an_in).unwrap(); - //! if val < ((1 << 8) - 1) { - //! led.set_low(); - //! } else { - //! led.set_high(); - //! } - //! delay.delay_ms(50_u16); - //! } - //! }); - //! ``` - const VREFCAL: *const u16 = 0x1FFF_F7BA as *const u16; - const VTEMPCAL30: *const u16 = 0x1FFF_F7B8 as *const u16; - const VTEMPCAL110: *const u16 = 0x1FFF_F7C2 as *const u16; - const VDD_CALIB: u16 = 3300; - use core::ptr; - use embedded_hal::{ - adc::{Channel, OneShot}, - blocking::delay::DelayUs, - }; - use crate::{ - delay::Delay, - gpio::*, - pac::{ - adc::{ - cfgr1::{ALIGN_A, RES_A}, - smpr::SMP_A, - }, - ADC, - }, - rcc::Rcc, - }; - /// Analog to Digital converter interface - pub struct Adc { - rb: ADC, - sample_time: AdcSampleTime, - align: AdcAlign, - precision: AdcPrecision, - } - /// ADC Sampling time - /// - /// Options for the sampling time, each is T + 0.5 ADC clock cycles. - pub enum AdcSampleTime { - /// 1.5 cycles sampling time - T_1, - /// 7.5 cycles sampling time - T_7, - /// 13.5 cycles sampling time - T_13, - /// 28.5 cycles sampling time - T_28, - /// 41.5 cycles sampling time - T_41, - /// 55.5 cycles sampling time - T_55, - /// 71.5 cycles sampling time - T_71, - /// 239.5 cycles sampling time - T_239, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for AdcSampleTime { - #[inline] - fn clone(&self) -> AdcSampleTime { - { - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for AdcSampleTime {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for AdcSampleTime { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match (&*self,) { - (&AdcSampleTime::T_1,) => ::core::fmt::Formatter::write_str(f, "T_1"), - (&AdcSampleTime::T_7,) => ::core::fmt::Formatter::write_str(f, "T_7"), - (&AdcSampleTime::T_13,) => ::core::fmt::Formatter::write_str(f, "T_13"), - (&AdcSampleTime::T_28,) => ::core::fmt::Formatter::write_str(f, "T_28"), - (&AdcSampleTime::T_41,) => ::core::fmt::Formatter::write_str(f, "T_41"), - (&AdcSampleTime::T_55,) => ::core::fmt::Formatter::write_str(f, "T_55"), - (&AdcSampleTime::T_71,) => ::core::fmt::Formatter::write_str(f, "T_71"), - (&AdcSampleTime::T_239,) => ::core::fmt::Formatter::write_str(f, "T_239"), - } - } - } - impl ::core::marker::StructuralPartialEq for AdcSampleTime {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for AdcSampleTime { - #[inline] - fn eq(&self, other: &AdcSampleTime) -> bool { - { - let __self_vi = ::core::intrinsics::discriminant_value(&*self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other); - if true && __self_vi == __arg_1_vi { - match (&*self, &*other) { - _ => true, - } - } else { - false - } - } - } - } - impl AdcSampleTime { - /// Get the default sample time (currently 239.5 cycles) - pub fn default() -> Self { - AdcSampleTime::T_239 - } - } - impl From for SMP_A { - fn from(val: AdcSampleTime) -> Self { - match val { - AdcSampleTime::T_1 => SMP_A::CYCLES1_5, - AdcSampleTime::T_7 => SMP_A::CYCLES7_5, - AdcSampleTime::T_13 => SMP_A::CYCLES13_5, - AdcSampleTime::T_28 => SMP_A::CYCLES28_5, - AdcSampleTime::T_41 => SMP_A::CYCLES41_5, - AdcSampleTime::T_55 => SMP_A::CYCLES55_5, - AdcSampleTime::T_71 => SMP_A::CYCLES71_5, - AdcSampleTime::T_239 => SMP_A::CYCLES239_5, - } - } - } - /// ADC Result Alignment - pub enum AdcAlign { - /// Left aligned results (most significant bits) - /// - /// Results in all precisions returning a value in the range 0-65535. - /// Depending on the precision the result will step by larger or smaller - /// amounts. - Left, - /// Right aligned results (least significant bits) - /// - /// Results in all precisions returning values from 0-(2^bits-1) in - /// steps of 1. - Right, - /// Left aligned results without correction of 6bit values. - /// - /// Returns left aligned results exactly as shown in RM0091 Fig.37. - /// Where the values are left aligned within the u16, with the exception - /// of 6 bit mode where the value is left aligned within the first byte of - /// the u16. - LeftAsRM, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for AdcAlign { - #[inline] - fn clone(&self) -> AdcAlign { - { - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for AdcAlign {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for AdcAlign { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match (&*self,) { - (&AdcAlign::Left,) => ::core::fmt::Formatter::write_str(f, "Left"), - (&AdcAlign::Right,) => ::core::fmt::Formatter::write_str(f, "Right"), - (&AdcAlign::LeftAsRM,) => ::core::fmt::Formatter::write_str(f, "LeftAsRM"), - } - } - } - impl ::core::marker::StructuralPartialEq for AdcAlign {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for AdcAlign { - #[inline] - fn eq(&self, other: &AdcAlign) -> bool { - { - let __self_vi = ::core::intrinsics::discriminant_value(&*self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other); - if true && __self_vi == __arg_1_vi { - match (&*self, &*other) { - _ => true, - } - } else { - false - } - } - } - } - impl AdcAlign { - /// Get the default alignment (currently right aligned) - pub fn default() -> Self { - AdcAlign::Right - } - } - impl From for ALIGN_A { - fn from(val: AdcAlign) -> Self { - match val { - AdcAlign::Left => ALIGN_A::LEFT, - AdcAlign::Right => ALIGN_A::RIGHT, - AdcAlign::LeftAsRM => ALIGN_A::LEFT, - } - } - } - /// ADC Sampling Precision - pub enum AdcPrecision { - /// 12 bit precision - B_12, - /// 10 bit precision - B_10, - /// 8 bit precision - B_8, - /// 6 bit precision - B_6, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for AdcPrecision { - #[inline] - fn clone(&self) -> AdcPrecision { - { - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for AdcPrecision {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for AdcPrecision { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match (&*self,) { - (&AdcPrecision::B_12,) => ::core::fmt::Formatter::write_str(f, "B_12"), - (&AdcPrecision::B_10,) => ::core::fmt::Formatter::write_str(f, "B_10"), - (&AdcPrecision::B_8,) => ::core::fmt::Formatter::write_str(f, "B_8"), - (&AdcPrecision::B_6,) => ::core::fmt::Formatter::write_str(f, "B_6"), - } - } - } - impl ::core::marker::StructuralPartialEq for AdcPrecision {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for AdcPrecision { - #[inline] - fn eq(&self, other: &AdcPrecision) -> bool { - { - let __self_vi = ::core::intrinsics::discriminant_value(&*self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other); - if true && __self_vi == __arg_1_vi { - match (&*self, &*other) { - _ => true, - } - } else { - false - } - } - } - } - impl AdcPrecision { - /// Get the default precision (currently 12 bit precision) - pub fn default() -> Self { - AdcPrecision::B_12 - } - } - impl From for RES_A { - fn from(val: AdcPrecision) -> Self { - match val { - AdcPrecision::B_12 => RES_A::TWELVEBIT, - AdcPrecision::B_10 => RES_A::TENBIT, - AdcPrecision::B_8 => RES_A::EIGHTBIT, - AdcPrecision::B_6 => RES_A::SIXBIT, - } - } - } - impl Channel for gpioa::PA0 { - type ID = u8; - fn channel() -> u8 { - 0_u8 - } - } - impl Channel for gpioa::PA1 { - type ID = u8; - fn channel() -> u8 { - 1_u8 - } - } - impl Channel for gpioa::PA2 { - type ID = u8; - fn channel() -> u8 { - 2_u8 - } - } - impl Channel for gpioa::PA3 { - type ID = u8; - fn channel() -> u8 { - 3_u8 - } - } - impl Channel for gpioa::PA4 { - type ID = u8; - fn channel() -> u8 { - 4_u8 - } - } - impl Channel for gpioa::PA5 { - type ID = u8; - fn channel() -> u8 { - 5_u8 - } - } - impl Channel for gpioa::PA6 { - type ID = u8; - fn channel() -> u8 { - 6_u8 - } - } - impl Channel for gpioa::PA7 { - type ID = u8; - fn channel() -> u8 { - 7_u8 - } - } - impl Channel for gpiob::PB0 { - type ID = u8; - fn channel() -> u8 { - 8_u8 - } - } - impl Channel for gpiob::PB1 { - type ID = u8; - fn channel() -> u8 { - 9_u8 - } - } - impl Channel for gpioc::PC0 { - type ID = u8; - fn channel() -> u8 { - 10_u8 - } - } - impl Channel for gpioc::PC1 { - type ID = u8; - fn channel() -> u8 { - 11_u8 - } - } - impl Channel for gpioc::PC2 { - type ID = u8; - fn channel() -> u8 { - 12_u8 - } - } - impl Channel for gpioc::PC3 { - type ID = u8; - fn channel() -> u8 { - 13_u8 - } - } - impl Channel for gpioc::PC4 { - type ID = u8; - fn channel() -> u8 { - 14_u8 - } - } - impl Channel for gpioc::PC5 { - type ID = u8; - fn channel() -> u8 { - 15_u8 - } - } - /// Internal temperature sensor (ADC Channel 16) - pub struct VTemp; - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for VTemp { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - VTemp => ::core::fmt::Formatter::write_str(f, "VTemp"), - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::default::Default for VTemp { - #[inline] - fn default() -> VTemp { - VTemp {} - } - } - /// Internal voltage reference (ADC Channel 17) - pub struct VRef; - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for VRef { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - VRef => ::core::fmt::Formatter::write_str(f, "VRef"), - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::default::Default for VRef { - #[inline] - fn default() -> VRef { - VRef {} - } - } - impl Channel for VTemp { - type ID = u8; - fn channel() -> u8 { - 16_u8 - } - } - impl Channel for VRef { - type ID = u8; - fn channel() -> u8 { - 17_u8 - } - } - impl VTemp { - /// Init a new VTemp - pub fn new() -> Self { - VTemp::default() - } - /// Enable the internal temperature sense, this has a wake up time - /// tSTART which can be found in your micro's datasheet, you - /// must wait at least that long after enabling before taking a reading. - /// Remember to disable when not in use. - pub fn enable(&mut self, adc: &mut Adc) { - adc.rb.ccr.modify(|_, w| w.tsen().set_bit()); - } - /// Disable the internal temperature sense. - pub fn disable(&mut self, adc: &mut Adc) { - adc.rb.ccr.modify(|_, w| w.tsen().clear_bit()); - } - /// Checks if the temperature sensor is enabled, does not account for the - /// tSTART time however. - pub fn is_enabled(&self, adc: &Adc) -> bool { - adc.rb.ccr.read().tsen().bit_is_set() - } - fn convert_temp(vtemp: u16, vdda: u16) -> i16 { - let vtemp30_cal = i32::from(unsafe { ptr::read(VTEMPCAL30) }) * 100; - let vtemp110_cal = i32::from(unsafe { ptr::read(VTEMPCAL110) }) * 100; - let mut temperature = i32::from(vtemp) * 100; - temperature = (temperature * (i32::from(vdda) / i32::from(VDD_CALIB))) - vtemp30_cal; - temperature *= (110 - 30) * 100; - temperature /= vtemp110_cal - vtemp30_cal; - temperature += 3000; - temperature as i16 - } - /// Read the value of the internal temperature sensor and return the - /// result in 100ths of a degree centigrade. - /// - /// Given a delay reference it will attempt to restrict to the - /// minimum delay needed to ensure a 10 us tSTART value. - /// Otherwise it will approximate the required delay using ADC reads. - pub fn read(adc: &mut Adc, delay: Option<&mut Delay>) -> i16 { - let mut vtemp = Self::new(); - let vtemp_preenable = vtemp.is_enabled(adc); - if !vtemp_preenable { - vtemp.enable(adc); - if let Some(dref) = delay { - dref.delay_us(2_u16); - } else { - VRef::read_vdda(adc); - } - } - let vdda = VRef::read_vdda(adc); - let prev_cfg = adc.default_cfg(); - let vtemp_val = adc.read(&mut vtemp).unwrap(); - if !vtemp_preenable { - vtemp.disable(adc); - } - adc.restore_cfg(prev_cfg); - Self::convert_temp(vtemp_val, vdda) - } - } - impl VRef { - /// Init a new VRef - pub fn new() -> Self { - VRef::default() - } - /// Enable the internal voltage reference, remember to disable when not in use. - pub fn enable(&mut self, adc: &mut Adc) { - adc.rb.ccr.modify(|_, w| w.vrefen().set_bit()); - } - /// Disable the internal reference voltage. - pub fn disable(&mut self, adc: &mut Adc) { - adc.rb.ccr.modify(|_, w| w.vrefen().clear_bit()); - } - /// Returns if the internal voltage reference is enabled. - pub fn is_enabled(&self, adc: &Adc) -> bool { - adc.rb.ccr.read().vrefen().bit_is_set() - } - /// Reads the value of VDDA in milli-volts - pub fn read_vdda(adc: &mut Adc) -> u16 { - let vrefint_cal = u32::from(unsafe { ptr::read(VREFCAL) }); - let mut vref = Self::new(); - let prev_cfg = adc.default_cfg(); - let vref_val: u32 = if vref.is_enabled(adc) { - adc.read(&mut vref).unwrap() - } else { - vref.enable(adc); - let ret = adc.read(&mut vref).unwrap(); - vref.disable(adc); - ret - }; - adc.restore_cfg(prev_cfg); - (u32::from(VDD_CALIB) * vrefint_cal / vref_val) as u16 - } - } - /// A stored ADC config, can be restored by using the `Adc::restore_cfg` method - pub struct StoredConfig(AdcSampleTime, AdcAlign, AdcPrecision); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for StoredConfig {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for StoredConfig { - #[inline] - fn clone(&self) -> StoredConfig { - { - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for StoredConfig { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - StoredConfig(ref __self_0_0, ref __self_0_1, ref __self_0_2) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "StoredConfig"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_1)); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_2)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl ::core::marker::StructuralPartialEq for StoredConfig {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for StoredConfig { - #[inline] - fn eq(&self, other: &StoredConfig) -> bool { - match *other { - StoredConfig(ref __self_1_0, ref __self_1_1, ref __self_1_2) => match *self { - StoredConfig(ref __self_0_0, ref __self_0_1, ref __self_0_2) => { - (*__self_0_0) == (*__self_1_0) - && (*__self_0_1) == (*__self_1_1) - && (*__self_0_2) == (*__self_1_2) - } - }, - } - } - #[inline] - fn ne(&self, other: &StoredConfig) -> bool { - match *other { - StoredConfig(ref __self_1_0, ref __self_1_1, ref __self_1_2) => match *self { - StoredConfig(ref __self_0_0, ref __self_0_1, ref __self_0_2) => { - (*__self_0_0) != (*__self_1_0) - || (*__self_0_1) != (*__self_1_1) - || (*__self_0_2) != (*__self_1_2) - } - }, - } - } - } - impl Adc { - /// Init a new Adc - /// - /// Sets all configurable parameters to defaults, enables the HSI14 clock - /// for the ADC if it is not already enabled and performs a boot time - /// calibration. As such this method may take an appreciable time to run. - pub fn new(adc: ADC, rcc: &mut Rcc) -> Self { - let mut s = Self { - rb: adc, - sample_time: AdcSampleTime::default(), - align: AdcAlign::default(), - precision: AdcPrecision::default(), - }; - s.select_clock(rcc); - s.calibrate(); - s - } - /// Saves a copy of the current ADC config - pub fn save_cfg(&mut self) -> StoredConfig { - StoredConfig(self.sample_time, self.align, self.precision) - } - /// Restores a stored config - pub fn restore_cfg(&mut self, cfg: StoredConfig) { - self.sample_time = cfg.0; - self.align = cfg.1; - self.precision = cfg.2; - } - /// Resets the ADC config to default, returning the existing config as - /// a stored config. - pub fn default_cfg(&mut self) -> StoredConfig { - let cfg = self.save_cfg(); - self.sample_time = AdcSampleTime::default(); - self.align = AdcAlign::default(); - self.precision = AdcPrecision::default(); - cfg - } - /// Set the Adc sampling time - /// - /// Options can be found in [AdcSampleTime](crate::adc::AdcSampleTime). - pub fn set_sample_time(&mut self, t_samp: AdcSampleTime) { - self.sample_time = t_samp; - } - /// Set the Adc result alignment - /// - /// Options can be found in [AdcAlign](crate::adc::AdcAlign). - pub fn set_align(&mut self, align: AdcAlign) { - self.align = align; - } - /// Set the Adc precision - /// - /// Options can be found in [AdcPrecision](crate::adc::AdcPrecision). - pub fn set_precision(&mut self, precision: AdcPrecision) { - self.precision = precision; - } - /// Returns the largest possible sample value for the current settings - pub fn max_sample(&self) -> u16 { - match self.align { - AdcAlign::Left => u16::max_value(), - AdcAlign::LeftAsRM => match self.precision { - AdcPrecision::B_6 => u16::from(u8::max_value()), - _ => u16::max_value(), - }, - AdcAlign::Right => match self.precision { - AdcPrecision::B_12 => (1 << 12) - 1, - AdcPrecision::B_10 => (1 << 10) - 1, - AdcPrecision::B_8 => (1 << 8) - 1, - AdcPrecision::B_6 => (1 << 6) - 1, - }, - } - } - /// Read the value of a channel and converts the result to milli-volts - pub fn read_abs_mv>(&mut self, pin: &mut PIN) -> u16 { - let vdda = u32::from(VRef::read_vdda(self)); - let v: u32 = self.read(pin).unwrap(); - let max_samp = u32::from(self.max_sample()); - (v * vdda / max_samp) as u16 - } - fn calibrate(&mut self) { - if self.rb.cr.read().aden().is_enabled() { - self.rb.cr.modify(|_, w| w.addis().disable()); - } - while self.rb.cr.read().aden().is_enabled() {} - self.rb.cfgr1.modify(|_, w| w.dmaen().disabled()); - self.rb.cr.modify(|_, w| w.adcal().start_calibration()); - while self.rb.cr.read().adcal().is_calibrating() {} - } - fn select_clock(&mut self, rcc: &mut Rcc) { - rcc.regs.apb2enr.modify(|_, w| w.adcen().enabled()); - rcc.regs.cr2.modify(|_, w| w.hsi14on().on()); - while rcc.regs.cr2.read().hsi14rdy().is_not_ready() {} - } - fn power_up(&mut self) { - if self.rb.isr.read().adrdy().is_ready() { - self.rb.isr.modify(|_, w| w.adrdy().clear()); - } - self.rb.cr.modify(|_, w| w.aden().enabled()); - while self.rb.isr.read().adrdy().is_not_ready() {} - } - fn power_down(&mut self) { - self.rb.cr.modify(|_, w| w.adstp().stop_conversion()); - while self.rb.cr.read().adstp().is_stopping() {} - self.rb.cr.modify(|_, w| w.addis().disable()); - while self.rb.cr.read().aden().is_enabled() {} - } - fn convert(&mut self, chan: u8) -> u16 { - self.rb.chselr.write(|w| unsafe { w.bits(1_u32 << chan) }); - self.rb - .smpr - .write(|w| w.smp().variant(self.sample_time.into())); - self.rb.cfgr1.modify(|_, w| { - w.res() - .variant(self.precision.into()) - .align() - .variant(self.align.into()) - }); - self.rb.cr.modify(|_, w| w.adstart().start_conversion()); - while self.rb.isr.read().eoc().is_not_complete() {} - let res = self.rb.dr.read().bits() as u16; - if self.align == AdcAlign::Left && self.precision == AdcPrecision::B_6 { - res << 8 - } else { - res - } - } - } - impl OneShot for Adc - where - WORD: From, - PIN: Channel, - { - type Error = (); - fn read(&mut self, _pin: &mut PIN) -> nb::Result { - self.power_up(); - let res = self.convert(PIN::channel()); - self.power_down(); - Ok(res.into()) - } - } -} -#[cfg(feature = "device-selected")] -pub mod delay { - //! API for delays with the systick timer - //! - //! Please be aware of potential overflows when using `delay_us`. - //! E.g. at 48MHz the maximum delay is 89 seconds. - //! - //! Consider using the timers api as a more flexible interface - //! - //! # Example - //! - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::pac; - //! use crate::hal::prelude::*; - //! use crate::hal::delay::Delay; - //! use cortex_m::peripheral::Peripherals; - //! - //! let mut p = pac::Peripherals::take().unwrap(); - //! let mut cp = cortex_m::Peripherals::take().unwrap(); - //! - //! let mut rcc = p.RCC.configure().freeze(&mut p.FLASH); - //! let mut delay = Delay::new(cp.SYST, &rcc); - //! loop { - //! delay.delay_ms(1_000_u16); - //! } - //! ``` - use cast::{u16, u32}; - use cortex_m::peripheral::syst::SystClkSource; - use cortex_m::peripheral::SYST; - use crate::rcc::Rcc; - use embedded_hal::blocking::delay::{DelayMs, DelayUs}; - /// System timer (SysTick) as a delay provider - pub struct Delay { - scale: u32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for Delay { - #[inline] - fn clone(&self) -> Delay { - match *self { - Delay { - scale: ref __self_0_0, - } => Delay { - scale: ::core::clone::Clone::clone(&(*__self_0_0)), - }, - } - } - } - const SYSTICK_RANGE: u32 = 0x0100_0000; - impl Delay { - /// Configures the system timer (SysTick) as a delay provider - pub fn new(mut syst: SYST, rcc: &Rcc) -> Delay { - syst.set_clock_source(SystClkSource::Core); - syst.set_reload(SYSTICK_RANGE - 1); - syst.clear_current(); - syst.enable_counter(); - if !(rcc.clocks.hclk().0 >= 1_000_000) { - ::core::panicking::panic("assertion failed: rcc.clocks.hclk().0 >= 1_000_000") - }; - let scale = rcc.clocks.hclk().0 / 1_000_000; - Delay { scale } - } - } - impl DelayMs for Delay { - fn delay_ms(&mut self, mut ms: u32) { - const MAX_MS: u32 = 0x0000_FFFF; - while ms != 0 { - let current_ms = if ms <= MAX_MS { ms } else { MAX_MS }; - self.delay_us(current_ms * 1_000); - ms -= current_ms; - } - } - } - impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u16) { - self.delay_us(u32(ms) * 1_000); - } - } - impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u8) { - self.delay_ms(u16(ms)); - } - } - impl DelayUs for Delay { - fn delay_us(&mut self, us: u32) { - const MAX_TICKS: u32 = 0x007F_FFFF; - let mut total_ticks = us * self.scale; - while total_ticks != 0 { - let current_ticks = if total_ticks <= MAX_TICKS { - total_ticks - } else { - MAX_TICKS - }; - let start_count = SYST::get_current(); - total_ticks -= current_ticks; - while (start_count.wrapping_sub(SYST::get_current()) % SYSTICK_RANGE) - < current_ticks - {} - } - } - } - impl DelayUs for Delay { - fn delay_us(&mut self, us: u16) { - self.delay_us(u32(us)) - } - } - impl DelayUs for Delay { - fn delay_us(&mut self, us: u8) { - self.delay_us(u32(us)) - } - } -} - -#[cfg(feature = "device-selected")] -pub mod i2c { - use core::ops::Deref; - use embedded_hal::blocking::i2c::{Read, Write, WriteRead}; - use crate::{ - gpio::*, - rcc::Rcc, - time::{KiloHertz, U32Ext}, - }; - /// I2C abstraction - pub struct I2c { - i2c: I2C, - pins: (SCLPIN, SDAPIN), - } - pub trait SclPin {} - pub trait SdaPin {} - impl SclPin for gpiob::PB6> {} - impl SclPin for gpiob::PB8> {} - impl SdaPin for gpiob::PB7> {} - impl SdaPin for gpiob::PB9> {} - pub enum Error { - OVERRUN, - NACK, - BUS, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match (&*self,) { - (&Error::OVERRUN,) => ::core::fmt::Formatter::write_str(f, "OVERRUN"), - (&Error::NACK,) => ::core::fmt::Formatter::write_str(f, "NACK"), - (&Error::BUS,) => ::core::fmt::Formatter::write_str(f, "BUS"), - } - } - } - use crate::pac::I2C1; - impl I2c { - pub fn i2c1(i2c: I2C1, pins: (SCLPIN, SDAPIN), speed: KiloHertz, rcc: &mut Rcc) -> Self - where - SCLPIN: SclPin, - SDAPIN: SdaPin, - { - rcc.regs.apb1enr.modify(|_, w| w.i2c1en().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.i2c1rst().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.i2c1rst().clear_bit()); - I2c { i2c, pins }.i2c_init(speed) - } - } - #[allow(dead_code)] - type I2cRegisterBlock = crate::pac::i2c1::RegisterBlock; - impl I2c - where - I2C: Deref, - { - fn i2c_init(self, speed: KiloHertz) -> Self { - use core::cmp; - self.i2c.cr1.modify(|_, w| w.pe().clear_bit()); - let presc; - let scldel; - let sdadel; - let sclh; - let scll; - const FREQ: u32 = 8_000_000; - if speed <= 100_u32.khz() { - presc = 1; - scll = cmp::max((((FREQ >> presc) >> 1) / speed.0) - 1, 255) as u8; - sclh = scll - 4; - sdadel = 2; - scldel = 4; - } else { - presc = 0; - scll = cmp::max((((FREQ >> presc) >> 1) / speed.0) - 1, 255) as u8; - sclh = scll - 6; - sdadel = 1; - scldel = 3; - } - self.i2c.timingr.write(|w| { - w.presc() - .bits(presc) - .scldel() - .bits(scldel) - .sdadel() - .bits(sdadel) - .sclh() - .bits(sclh) - .scll() - .bits(scll) - }); - self.i2c.cr1.modify(|_, w| w.pe().set_bit()); - self - } - pub fn release(self) -> (I2C, (SCLPIN, SDAPIN)) { - (self.i2c, self.pins) - } - fn check_and_clear_error_flags( - &self, - isr: &crate::stm32::i2c1::isr::R, - ) -> Result<(), Error> { - if isr.ovr().bit_is_set() { - self.i2c.icr.write(|w| w.ovrcf().set_bit()); - return Err(Error::OVERRUN); - } - if isr.arlo().bit_is_set() | isr.berr().bit_is_set() { - self.i2c - .icr - .write(|w| w.arlocf().set_bit().berrcf().set_bit()); - return Err(Error::BUS); - } - if isr.nackf().bit_is_set() { - self.i2c - .icr - .write(|w| w.stopcf().set_bit().nackcf().set_bit()); - return Err(Error::NACK); - } - Ok(()) - } - fn send_byte(&self, byte: u8) -> Result<(), Error> { - loop { - let isr = self.i2c.isr.read(); - self.check_and_clear_error_flags(&isr)?; - if isr.txis().bit_is_set() { - break; - } - } - self.i2c.txdr.write(|w| unsafe { w.bits(u32::from(byte)) }); - self.check_and_clear_error_flags(&self.i2c.isr.read())?; - Ok(()) - } - fn recv_byte(&self) -> Result { - loop { - let isr = self.i2c.isr.read(); - self.check_and_clear_error_flags(&isr)?; - if isr.rxne().bit_is_set() { - break; - } - } - let value = self.i2c.rxdr.read().bits() as u8; - Ok(value) - } - } - impl WriteRead for I2c - where - I2C: Deref, - { - type Error = Error; - fn write_read(&mut self, addr: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Error> { - self.i2c.cr2.modify(|_, w| { - w.sadd() - .bits(u16::from(addr) << 1) - .nbytes() - .bits(bytes.len() as u8) - .rd_wrn() - .clear_bit() - .autoend() - .clear_bit() - }); - self.i2c.cr2.modify(|_, w| w.start().set_bit()); - loop { - let isr = self.i2c.isr.read(); - self.check_and_clear_error_flags(&isr)?; - if isr.txis().bit_is_set() || isr.tc().bit_is_set() { - break; - } - } - for c in bytes { - self.send_byte(*c)?; - } - loop { - let isr = self.i2c.isr.read(); - self.check_and_clear_error_flags(&isr)?; - if isr.tc().bit_is_set() { - break; - } - } - self.i2c.cr2.modify(|_, w| { - w.sadd() - .bits(u16::from(addr) << 1) - .nbytes() - .bits(buffer.len() as u8) - .rd_wrn() - .set_bit() - }); - self.i2c.cr2.modify(|_, w| w.start().set_bit()); - self.i2c.cr2.modify(|_, w| w.autoend().set_bit()); - for c in buffer.iter_mut() { - *c = self.recv_byte()?; - } - self.check_and_clear_error_flags(&self.i2c.isr.read())?; - Ok(()) - } - } - impl Read for I2c - where - I2C: Deref, - { - type Error = Error; - fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Error> { - self.i2c.cr2.modify(|_, w| { - w.sadd() - .bits(u16::from(addr) << 1) - .nbytes() - .bits(buffer.len() as u8) - .rd_wrn() - .set_bit() - }); - self.i2c.cr2.modify(|_, w| w.start().set_bit()); - self.i2c.cr2.modify(|_, w| w.autoend().set_bit()); - for c in buffer.iter_mut() { - *c = self.recv_byte()?; - } - self.check_and_clear_error_flags(&self.i2c.isr.read())?; - Ok(()) - } - } - impl Write for I2c - where - I2C: Deref, - { - type Error = Error; - fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Error> { - self.i2c.cr2.modify(|_, w| { - w.sadd() - .bits(u16::from(addr) << 1) - .nbytes() - .bits(bytes.len() as u8) - .rd_wrn() - .clear_bit() - .autoend() - .set_bit() - }); - self.i2c.cr2.modify(|_, w| w.start().set_bit()); - for c in bytes { - self.send_byte(*c)?; - } - self.check_and_clear_error_flags(&self.i2c.isr.read())?; - Ok(()) - } - } -} -#[cfg(feature = "device-selected")] -pub mod prelude { - pub use embedded_hal::prelude::*; - pub use embedded_hal::watchdog::Watchdog as _stm32f0xx_hal_embedded_hal_watchdog_Watchdog; - pub use embedded_hal::watchdog::WatchdogEnable as _stm32f0xx_hal_embedded_hal_watchdog_WatchdogEnable; - pub use embedded_hal::adc::OneShot as _embedded_hal_adc_OneShot; - pub use embedded_hal::digital::v2::InputPin as _embedded_hal_gpio_InputPin; - pub use embedded_hal::digital::v2::OutputPin as _embedded_hal_gpio_OutputPin; - pub use embedded_hal::digital::v2::StatefulOutputPin as _embedded_hal_gpio_StatefulOutputPin; - pub use embedded_hal::digital::v2::ToggleableOutputPin as _embedded_hal_gpio_ToggleableOutputPin; - pub use crate::gpio::GpioExt as _stm32f0xx_hal_gpio_GpioExt; - pub use crate::rcc::RccExt as _stm32f0xx_hal_rcc_RccExt; - pub use crate::time::U32Ext as _stm32f0xx_hal_time_U32Ext; -} -#[cfg(feature = "device-selected")] -pub mod pwm { - use cast::{u16, u32}; - use core::{marker::PhantomData, mem::MaybeUninit}; - use crate::rcc::Rcc; - use crate::time::Hertz; - use embedded_hal as hal; - pub trait Pins { - const C1: bool = false; - const C2: bool = false; - const C3: bool = false; - const C4: bool = false; - type Channels; - } - use crate::timers::PinC1; - use crate::timers::PinC2; - use crate::timers::PinC3; - use crate::timers::PinC4; - pub struct C1; - pub struct C2; - pub struct C3; - pub struct C4; - pub struct PwmChannels { - _channel: PhantomData, - _tim: PhantomData, - } - #[allow(unused_parens)] - impl Pins for (P1, P2, P3, P4) - where - P1: PinC1, - P2: PinC2, - P3: PinC3, - P4: PinC4, - { - const C1: bool = true; - const C2: bool = true; - const C3: bool = true; - const C4: bool = true; - type Channels = ( - PwmChannels, - PwmChannels, - PwmChannels, - PwmChannels, - ); - } - #[allow(unused_parens)] - impl Pins for (P2, P3, P4) - where - P2: PinC2, - P3: PinC3, - P4: PinC4, - { - const C2: bool = true; - const C3: bool = true; - const C4: bool = true; - type Channels = ( - PwmChannels, - PwmChannels, - PwmChannels, - ); - } - #[allow(unused_parens)] - impl Pins for (P1, P3, P4) - where - P1: PinC1, - P3: PinC3, - P4: PinC4, - { - const C1: bool = true; - const C3: bool = true; - const C4: bool = true; - type Channels = ( - PwmChannels, - PwmChannels, - PwmChannels, - ); - } - #[allow(unused_parens)] - impl Pins for (P1, P2, P4) - where - P1: PinC1, - P2: PinC2, - P4: PinC4, - { - const C1: bool = true; - const C2: bool = true; - const C4: bool = true; - type Channels = ( - PwmChannels, - PwmChannels, - PwmChannels, - ); - } - #[allow(unused_parens)] - impl Pins for (P1, P2, P3) - where - P1: PinC1, - P2: PinC2, - P3: PinC3, - { - const C1: bool = true; - const C2: bool = true; - const C3: bool = true; - type Channels = ( - PwmChannels, - PwmChannels, - PwmChannels, - ); - } - #[allow(unused_parens)] - impl Pins for (P3, P4) - where - P3: PinC3, - P4: PinC4, - { - const C3: bool = true; - const C4: bool = true; - type Channels = (PwmChannels, PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P2, P4) - where - P2: PinC2, - P4: PinC4, - { - const C2: bool = true; - const C4: bool = true; - type Channels = (PwmChannels, PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P2, P3) - where - P2: PinC2, - P3: PinC3, - { - const C2: bool = true; - const C3: bool = true; - type Channels = (PwmChannels, PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P1, P4) - where - P1: PinC1, - P4: PinC4, - { - const C1: bool = true; - const C4: bool = true; - type Channels = (PwmChannels, PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P1, P3) - where - P1: PinC1, - P3: PinC3, - { - const C1: bool = true; - const C3: bool = true; - type Channels = (PwmChannels, PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P1, P2) - where - P1: PinC1, - P2: PinC2, - { - const C1: bool = true; - const C2: bool = true; - type Channels = (PwmChannels, PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P1) - where - P1: PinC1, - { - const C1: bool = true; - type Channels = (PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P2) - where - P2: PinC2, - { - const C2: bool = true; - type Channels = (PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P3) - where - P3: PinC3, - { - const C3: bool = true; - type Channels = (PwmChannels); - } - #[allow(unused_parens)] - impl Pins for (P4) - where - P4: PinC4, - { - const C4: bool = true; - type Channels = (PwmChannels); - } - impl, P2: PinC1> PinC1 for (P1, P2) {} - impl, P2: PinC2> PinC2 for (P1, P2) {} - impl, P2: PinC3> PinC3 for (P1, P2) {} - impl, P2: PinC4> PinC4 for (P1, P2) {} - impl, P2: PinC1, P3: PinC1> PinC1 for (P1, P2, P3) {} - impl, P2: PinC2, P3: PinC2> PinC2 for (P1, P2, P3) {} - impl, P2: PinC3, P3: PinC3> PinC3 for (P1, P2, P3) {} - impl, P2: PinC4, P3: PinC4> PinC4 for (P1, P2, P3) {} - impl, P2: PinC1, P3: PinC1, P4: PinC1> PinC1 - for (P1, P2, P3, P4) - { - } - impl, P2: PinC2, P3: PinC2, P4: PinC2> PinC2 - for (P1, P2, P3, P4) - { - } - impl, P2: PinC3, P3: PinC3, P4: PinC3> PinC3 - for (P1, P2, P3, P4) - { - } - impl, P2: PinC4, P3: PinC4, P4: PinC4> PinC4 - for (P1, P2, P3, P4) - { - } - use crate::pac::*; - pub fn tim1(tim: TIM1, _pins: PINS, rcc: &mut Rcc, freq: T) -> PINS::Channels - where - PINS: Pins, - T: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.tim1en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim1rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim1rst().clear_bit()); - if PINS::C1 { - tim.ccmr1_output() - .modify(|_, w| w.oc1pe().set_bit().oc1m().pwm_mode1()); - } - if PINS::C2 { - tim.ccmr1_output() - .modify(|_, w| w.oc2pe().set_bit().oc2m().pwm_mode1()); - } - if PINS::C3 { - tim.ccmr2_output() - .modify(|_, w| w.oc3pe().set_bit().oc3m().pwm_mode1()); - } - if PINS::C4 { - tim.ccmr2_output() - .modify(|_, w| w.oc4pe().set_bit().oc4m().pwm_mode1()); - } - let tclk = if rcc.clocks.hclk().0 == rcc.clocks.pclk().0 { - rcc.clocks.pclk().0 - } else { - rcc.clocks.pclk().0 * 2 - }; - let ticks = tclk / freq.into().0; - let psc = u16((ticks - 1) / (1 << 16)).unwrap(); - tim.psc.write(|w| w.psc().bits(psc)); - let arr = u16(ticks / u32(psc + 1)).unwrap(); - tim.arr.write(|w| unsafe { w.bits(u32(arr)) }); - tim.cr1.modify(|_, w| w.arpe().set_bit()); - tim.cr1.modify(|_, w| w.urs().set_bit()); - tim.egr.write(|w| w.ug().set_bit()); - tim.cr1.modify(|_, w| w.urs().clear_bit()); - tim.bdtr.modify(|_, w| w.aoe().set_bit()); - tim.cr1.write(|w| { - w.cms() - .bits(0b00) - .dir() - .clear_bit() - .opm() - .clear_bit() - .cen() - .set_bit() - }); - unsafe { MaybeUninit::uninit().assume_init() } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc1e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc1e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).ccr1.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM1::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) } - } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc2e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc2e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).ccr2.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM1::ptr()).ccr2.write(|w| w.ccr().bits(duty.into())) } - } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc3e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc3e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).ccr3.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM1::ptr()).ccr3.write(|w| w.ccr().bits(duty.into())) } - } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc4e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM1::ptr())).ccer.modify(|_, w| w.cc4e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).ccr4.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM1::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM1::ptr()).ccr4.write(|w| w.ccr().bits(duty.into())) } - } - } - pub fn tim3(tim: TIM3, _pins: PINS, rcc: &mut Rcc, freq: T) -> PINS::Channels - where - PINS: Pins, - T: Into, - { - rcc.regs.apb1enr.modify(|_, w| w.tim3en().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim3rst().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim3rst().clear_bit()); - if PINS::C1 { - tim.ccmr1_output() - .modify(|_, w| w.oc1pe().set_bit().oc1m().pwm_mode1()); - } - if PINS::C2 { - tim.ccmr1_output() - .modify(|_, w| w.oc2pe().set_bit().oc2m().pwm_mode1()); - } - if PINS::C3 { - tim.ccmr2_output() - .modify(|_, w| w.oc3pe().set_bit().oc3m().pwm_mode1()); - } - if PINS::C4 { - tim.ccmr2_output() - .modify(|_, w| w.oc4pe().set_bit().oc4m().pwm_mode1()); - } - let tclk = if rcc.clocks.hclk().0 == rcc.clocks.pclk().0 { - rcc.clocks.pclk().0 - } else { - rcc.clocks.pclk().0 * 2 - }; - let ticks = tclk / freq.into().0; - let psc = u16((ticks - 1) / (1 << 16)).unwrap(); - tim.psc.write(|w| w.psc().bits(psc)); - let arr = u16(ticks / u32(psc + 1)).unwrap(); - tim.arr.write(|w| unsafe { w.bits(u32(arr)) }); - tim.cr1.modify(|_, w| w.arpe().set_bit()); - tim.cr1.modify(|_, w| w.urs().set_bit()); - tim.egr.write(|w| w.ug().set_bit()); - tim.cr1.modify(|_, w| w.urs().clear_bit()); - tim.cr1.write(|w| { - w.cms() - .bits(0b00) - .dir() - .clear_bit() - .opm() - .clear_bit() - .cen() - .set_bit() - }); - unsafe { MaybeUninit::uninit().assume_init() } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc1e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc1e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).ccr1.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM3::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) } - } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc2e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc2e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).ccr2.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM3::ptr()).ccr2.write(|w| w.ccr().bits(duty.into())) } - } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc3e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc3e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).ccr3.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM3::ptr()).ccr3.write(|w| w.ccr().bits(duty.into())) } - } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc4e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM3::ptr())).ccer.modify(|_, w| w.cc4e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).ccr4.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM3::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM3::ptr()).ccr4.write(|w| w.ccr().bits(duty.into())) } - } - } - pub fn tim14(tim: TIM14, _pins: PINS, rcc: &mut Rcc, freq: T) -> PINS::Channels - where - PINS: Pins, - T: Into, - { - rcc.regs.apb1enr.modify(|_, w| w.tim14en().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim14rst().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim14rst().clear_bit()); - if PINS::C1 { - tim.ccmr1_output() - .modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6)); - } - let tclk = if rcc.clocks.hclk().0 == rcc.clocks.pclk().0 { - rcc.clocks.pclk().0 - } else { - rcc.clocks.pclk().0 * 2 - }; - let ticks = tclk / freq.into().0; - let psc = u16((ticks - 1) / (1 << 16)).unwrap(); - tim.psc.write(|w| w.psc().bits(psc)); - let arr = u16(ticks / u32(psc + 1)).unwrap(); - tim.arr.write(|w| unsafe { w.bits(u32(arr)) }); - tim.cr1.modify(|_, w| w.arpe().set_bit()); - tim.cr1.modify(|_, w| w.urs().set_bit()); - tim.egr.write(|w| w.ug().set_bit()); - tim.cr1.modify(|_, w| w.urs().clear_bit()); - tim.cr1.write(|w| w.cen().set_bit()); - unsafe { MaybeUninit::uninit().assume_init() } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM14::ptr())).ccer.modify(|_, w| w.cc1e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM14::ptr())).ccer.modify(|_, w| w.cc1e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM14::ptr()).ccr1.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM14::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM14::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) } - } - } - pub fn tim16(tim: TIM16, _pins: PINS, rcc: &mut Rcc, freq: T) -> PINS::Channels - where - PINS: Pins, - T: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.tim16en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim16rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim16rst().clear_bit()); - if PINS::C1 { - tim.ccmr1_output() - .modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6)); - } - let tclk = if rcc.clocks.hclk().0 == rcc.clocks.pclk().0 { - rcc.clocks.pclk().0 - } else { - rcc.clocks.pclk().0 * 2 - }; - let ticks = tclk / freq.into().0; - let psc = u16((ticks - 1) / (1 << 16)).unwrap(); - tim.psc.write(|w| w.psc().bits(psc)); - let arr = u16(ticks / u32(psc + 1)).unwrap(); - tim.arr.write(|w| unsafe { w.bits(u32(arr)) }); - tim.cr1.modify(|_, w| w.arpe().set_bit()); - tim.cr1.modify(|_, w| w.urs().set_bit()); - tim.egr.write(|w| w.ug().set_bit()); - tim.cr1.modify(|_, w| w.urs().clear_bit()); - tim.bdtr.modify(|_, w| w.aoe().set_bit()); - tim.cr1.write(|w| w.opm().clear_bit().cen().set_bit()); - unsafe { MaybeUninit::uninit().assume_init() } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM16::ptr())).ccer.modify(|_, w| w.cc1e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM16::ptr())).ccer.modify(|_, w| w.cc1e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM16::ptr()).ccr1.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM16::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM16::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) } - } - } - pub fn tim17(tim: TIM17, _pins: PINS, rcc: &mut Rcc, freq: T) -> PINS::Channels - where - PINS: Pins, - T: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.tim17en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim17rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim17rst().clear_bit()); - if PINS::C1 { - tim.ccmr1_output() - .modify(|_, w| w.oc1pe().set_bit().oc1m().bits(6)); - } - let tclk = if rcc.clocks.hclk().0 == rcc.clocks.pclk().0 { - rcc.clocks.pclk().0 - } else { - rcc.clocks.pclk().0 * 2 - }; - let ticks = tclk / freq.into().0; - let psc = u16((ticks - 1) / (1 << 16)).unwrap(); - tim.psc.write(|w| w.psc().bits(psc)); - let arr = u16(ticks / u32(psc + 1)).unwrap(); - tim.arr.write(|w| unsafe { w.bits(u32(arr)) }); - tim.cr1.modify(|_, w| w.arpe().set_bit()); - tim.cr1.modify(|_, w| w.urs().set_bit()); - tim.egr.write(|w| w.ug().set_bit()); - tim.cr1.modify(|_, w| w.urs().clear_bit()); - tim.bdtr.modify(|_, w| w.aoe().set_bit()); - tim.cr1.write(|w| w.opm().clear_bit().cen().set_bit()); - unsafe { MaybeUninit::uninit().assume_init() } - } - impl hal::PwmPin for PwmChannels { - type Duty = u16; - fn disable(&mut self) { - unsafe { (*(TIM17::ptr())).ccer.modify(|_, w| w.cc1e().clear_bit()) }; - } - fn enable(&mut self) { - unsafe { (*(TIM17::ptr())).ccer.modify(|_, w| w.cc1e().set_bit()) }; - } - fn get_duty(&self) -> u16 { - unsafe { (*TIM17::ptr()).ccr1.read().ccr().bits() as u16 } - } - fn get_max_duty(&self) -> u16 { - unsafe { (*TIM17::ptr()).arr.read().arr().bits() as u16 } - } - fn set_duty(&mut self, duty: u16) { - unsafe { (*TIM17::ptr()).ccr1.write(|w| w.ccr().bits(duty.into())) } - } - } -} -#[cfg(feature = "device-selected")] -pub mod rcc { - use crate::pac::RCC; - use crate::time::Hertz; - /// Extension trait that sets up the `RCC` peripheral - pub trait RccExt { - /// Configure the clocks of the RCC peripheral - fn configure(self) -> CFGR; - } - impl RccExt for RCC { - fn configure(self) -> CFGR { - CFGR { - hclk: None, - pclk: None, - sysclk: None, - clock_src: SysClkSource::HSI, - #[cfg(feature = "stm32f070")] - usb_src: USBClockSource::Disabled, - rcc: self, - } - } - } - /// Constrained RCC peripheral - pub struct Rcc { - pub clocks: Clocks, - pub(crate) regs: RCC, - } - pub enum HSEBypassMode { - /// Not bypassed: for crystals - NotBypassed, - /// Bypassed: for external clock sources - Bypassed, - } - #[cfg(any( - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f070", - feature = "stm32f072", - feature = "stm32f078", - ))] - pub enum USBClockSource { - #[cfg(feature = "stm32f070")] - /// USB peripheral's tranceiver is disabled - Disabled, - /// PLL output is used as USB peripheral tranceiver clock - PLL, - } - /// RCC for F0x0 devices - #[cfg(any(feature = "stm32f030", feature = "stm32f070",))] - mod inner { - use crate::pac::{rcc::cfgr::SW_A, RCC}; - pub(super) const HSI: u32 = 8_000_000; - #[cfg(any( - feature = "stm32f030x4", - feature = "stm32f030x6", - feature = "stm32f030x8", - feature = "stm32f070", - feature = "stm32f030xc" - ))] - pub(super) const RCC_PLLSRC_PREDIV1_SUPPORT: bool = false; - pub(super) enum SysClkSource { - HSI, - /// High-speed external clock(freq,bypassed) - HSE(u32, super::HSEBypassMode), - } - pub(super) fn get_freq(c_src: &SysClkSource) -> u32 { - match c_src { - SysClkSource::HSE(freq, _) => *freq, - _ => HSI, - } - } - pub(super) fn enable_clock(rcc: &mut RCC, c_src: &SysClkSource) { - match c_src { - SysClkSource::HSE(_, bypassed) => { - match bypassed { - super::HSEBypassMode::NotBypassed => { - rcc.cr - .modify(|_, w| w.csson().on().hseon().on().hsebyp().not_bypassed()); - } - super::HSEBypassMode::Bypassed => { - rcc.cr - .modify(|_, w| w.csson().on().hseon().on().hsebyp().bypassed()); - } - } - while !rcc.cr.read().hserdy().bit_is_set() {} - } - SysClkSource::HSI => { - rcc.cr.write(|w| w.hsion().set_bit()); - while rcc.cr.read().hsirdy().bit_is_clear() {} - } - } - } - pub(super) fn enable_pll( - rcc: &mut RCC, - c_src: &SysClkSource, - pllmul_bits: u8, - ppre_bits: u8, - hpre_bits: u8, - ) { - let pllsrc_bit: bool = match c_src { - SysClkSource::HSI => false, - SysClkSource::HSE(_, _) => true, - }; - rcc.cfgr - .modify(|_, w| w.pllsrc().bit(pllsrc_bit).pllmul().bits(pllmul_bits)); - rcc.cr.modify(|_, w| w.pllon().set_bit()); - while rcc.cr.read().pllrdy().bit_is_clear() {} - rcc.cfgr.modify(|_, w| unsafe { - w.ppre().bits(ppre_bits).hpre().bits(hpre_bits).sw().pll() - }); - } - pub(super) fn get_sww(c_src: &SysClkSource) -> SW_A { - match c_src { - SysClkSource::HSI => SW_A::HSI, - SysClkSource::HSE(_, _) => SW_A::HSE, - } - } - } - use self::inner::SysClkSource; - pub struct CFGR { - hclk: Option, - pclk: Option, - sysclk: Option, - clock_src: SysClkSource, - #[cfg(any( - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f070", - feature = "stm32f072", - feature = "stm32f078", - ))] - usb_src: USBClockSource, - rcc: RCC, - } - impl CFGR { - pub fn hse(mut self, freq: F, bypass: HSEBypassMode) -> Self - where - F: Into, - { - self.clock_src = SysClkSource::HSE(freq.into().0, bypass); - self - } - pub fn hclk(mut self, freq: F) -> Self - where - F: Into, - { - self.hclk = Some(freq.into().0); - self - } - pub fn pclk(mut self, freq: F) -> Self - where - F: Into, - { - self.pclk = Some(freq.into().0); - self - } - pub fn sysclk(mut self, freq: F) -> Self - where - F: Into, - { - self.sysclk = Some(freq.into().0); - self - } - #[cfg(any( - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f070", - feature = "stm32f072", - feature = "stm32f078", - ))] - /// Set the USB clock source (only valid for STM32F0xx with USB) - pub fn usbsrc(mut self, src: USBClockSource) -> Self { - self.usb_src = src; - self - } - pub fn freeze(mut self, flash: &mut crate::pac::FLASH) -> Rcc { - let sysclk = self.sysclk.unwrap_or(self::inner::HSI); - let r_sysclk; - let pllmul_bits; - let src_clk_freq = self::inner::get_freq(&self.clock_src); - if sysclk == src_clk_freq { - pllmul_bits = None; - r_sysclk = src_clk_freq; - } else { - let pllprediv = match (&self.clock_src, self::inner::RCC_PLLSRC_PREDIV1_SUPPORT) { - (self::inner::SysClkSource::HSI, false) => 2, - (_, _) => 1, - }; - let pllmul = (2 * pllprediv * self.sysclk.unwrap_or(src_clk_freq) + src_clk_freq) - / src_clk_freq - / 2; - let pllmul = core::cmp::min(core::cmp::max(pllmul, 2), 16); - r_sysclk = pllmul * src_clk_freq / pllprediv; - pllmul_bits = Some(pllmul as u8 - 2) - } - let hpre_bits = self - .hclk - .map(|hclk| match r_sysclk / hclk { - 0 => ::core::panicking::panic("internal error: entered unreachable code"), - 1 => 0b0111, - 2 => 0b1000, - 3..=5 => 0b1001, - 6..=11 => 0b1010, - 12..=39 => 0b1011, - 40..=95 => 0b1100, - 96..=191 => 0b1101, - 192..=383 => 0b1110, - _ => 0b1111, - }) - .unwrap_or(0b0111); - let hclk = r_sysclk / (1 << (hpre_bits - 0b0111)); - let ppre_bits = self - .pclk - .map(|pclk| match hclk / pclk { - 0 => ::core::panicking::panic("internal error: entered unreachable code"), - 1 => 0b011, - 2 => 0b100, - 3..=5 => 0b101, - 6..=11 => 0b110, - _ => 0b111, - }) - .unwrap_or(0b011); - let ppre: u8 = 1 << (ppre_bits - 0b011); - let pclk = hclk / cast::u32(ppre); - unsafe { - flash.acr.write(|w| { - w.latency().bits(if r_sysclk <= 24_000_000 { - 0b000 - } else if r_sysclk <= 48_000_000 { - 0b001 - } else { - 0b010 - }) - }) - } - self::inner::enable_clock(&mut self.rcc, &self.clock_src); - #[cfg(feature = "stm32f070")] - { - match self.usb_src { - USBClockSource::Disabled => self.rcc.cfgr3.modify(|_, w| w.usbsw().clear_bit()), - USBClockSource::PLL => self.rcc.cfgr3.modify(|_, w| w.usbsw().set_bit()), - } - } - if let Some(pllmul_bits) = pllmul_bits { - self::inner::enable_pll( - &mut self.rcc, - &self.clock_src, - pllmul_bits, - ppre_bits, - hpre_bits, - ); - } else { - let sw_var = self::inner::get_sww(&self.clock_src); - self.rcc.cfgr.modify(|_, w| unsafe { - w.ppre() - .bits(ppre_bits) - .hpre() - .bits(hpre_bits) - .sw() - .variant(sw_var) - }); - } - Rcc { - clocks: Clocks { - hclk: Hertz(hclk), - pclk: Hertz(pclk), - sysclk: Hertz(sysclk), - }, - regs: self.rcc, - } - } - } - /// Frozen clock frequencies - /// - /// The existence of this value indicates that the clock configuration can no longer be changed - pub struct Clocks { - hclk: Hertz, - pclk: Hertz, - sysclk: Hertz, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for Clocks { - #[inline] - fn clone(&self) -> Clocks { - { - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for Clocks {} - impl Clocks { - /// Returns the frequency of the AHB - pub fn hclk(&self) -> Hertz { - self.hclk - } - /// Returns the frequency of the APB - pub fn pclk(&self) -> Hertz { - self.pclk - } - /// Returns the system (core) frequency - pub fn sysclk(&self) -> Hertz { - self.sysclk - } - } -} -#[cfg(feature = "device-selected")] -pub mod serial { - //! API for the integrated USART ports - //! - //! This only implements the usual asynchronous bidirectional 8-bit transfers. - //! - //! It's possible to use a read-only/write-only serial implementation with - //! `usartXrx`/`usartXtx`. - //! - //! # Examples - //! Echo - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::prelude::*; - //! use crate::hal::serial::Serial; - //! use crate::hal::pac; - //! - //! use nb::block; - //! - //! cortex_m::interrupt::free(|cs| { - //! let rcc = p.RCC.configure().sysclk(48.mhz()).freeze(); - //! - //! let gpioa = p.GPIOA.split(&mut rcc); - //! - //! let tx = gpioa.pa9.into_alternate_af1(cs); - //! let rx = gpioa.pa10.into_alternate_af1(cs); - //! - //! let mut serial = Serial::usart1(p.USART1, (tx, rx), 115_200.bps(), &mut rcc); - //! - //! loop { - //! let received = block!(serial.read()).unwrap(); - //! block!(serial.write(received)).ok(); - //! } - //! }); - //! ``` - //! - //! Hello World - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::prelude::*; - //! use crate::hal::serial::Serial; - //! use crate::hal::pac; - //! - //! use nb::block; - //! - //! cortex_m::interrupt::free(|cs| { - //! let rcc = p.RCC.configure().sysclk(48.mhz()).freeze(); - //! - //! let gpioa = p.GPIOA.split(&mut rcc); - //! - //! let tx = gpioa.pa9.into_alternate_af1(cs); - //! - //! let mut serial = Serial::usart1tx(p.USART1, tx, 115_200.bps(), &mut rcc); - //! - //! loop { - //! serial.write_str("Hello World!\r\n"); - //! } - //! }); - //! ``` - use core::{ - convert::Infallible, - fmt::{Result, Write}, - ops::Deref, - }; - use embedded_hal::prelude::*; - use crate::{gpio::*, rcc::Rcc, time::Bps}; - use core::marker::PhantomData; - /// Serial error - #[non_exhaustive] - pub enum Error { - /// Framing error - Framing, - /// Noise error - Noise, - /// RX buffer overrun - Overrun, - /// Parity check error - Parity, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match (&*self,) { - (&Error::Framing,) => ::core::fmt::Formatter::write_str(f, "Framing"), - (&Error::Noise,) => ::core::fmt::Formatter::write_str(f, "Noise"), - (&Error::Overrun,) => ::core::fmt::Formatter::write_str(f, "Overrun"), - (&Error::Parity,) => ::core::fmt::Formatter::write_str(f, "Parity"), - } - } - } - /// Interrupt event - pub enum Event { - /// New data has been received - Rxne, - /// New data can be sent - Txe, - /// Idle line state detected - Idle, - } - pub trait TxPin {} - pub trait RxPin {} - impl TxPin for gpioa::PA9> {} - impl TxPin for gpiob::PB6> {} - impl RxPin for gpioa::PA10> {} - impl RxPin for gpiob::PB7> {} - impl TxPin for gpioa::PA2> {} - impl TxPin for gpioa::PA14> {} - impl RxPin for gpioa::PA3> {} - impl RxPin for gpioa::PA15> {} - /// Serial abstraction - pub struct Serial { - usart: USART, - pins: (TXPIN, RXPIN), - } - type SerialRegisterBlock = crate::pac::usart1::RegisterBlock; - /// Serial receiver - pub struct Rx { - usart: *const SerialRegisterBlock, - _instance: PhantomData, - } - unsafe impl Send for Rx {} - /// Serial transmitter - pub struct Tx { - usart: *const SerialRegisterBlock, - _instance: PhantomData, - } - unsafe impl Send for Tx {} - use crate::pac::USART1; - impl Serial - where - TXPIN: TxPin, - RXPIN: RxPin, - { - /// Creates a new serial instance - pub fn usart1(usart: USART1, pins: (TXPIN, RXPIN), baud_rate: Bps, rcc: &mut Rcc) -> Self { - let mut serial = Serial { usart, pins }; - serial.configure(baud_rate, rcc); - serial - .usart - .cr1 - .modify(|_, w| w.te().set_bit().re().set_bit().ue().set_bit()); - serial - } - } - impl Serial - where - TXPIN: TxPin, - { - /// Creates a new tx-only serial instance - pub fn usart1tx(usart: USART1, txpin: TXPIN, baud_rate: Bps, rcc: &mut Rcc) -> Self { - let rxpin = (); - let mut serial = Serial { - usart, - pins: (txpin, rxpin), - }; - serial.configure(baud_rate, rcc); - serial - .usart - .cr1 - .modify(|_, w| w.te().set_bit().ue().set_bit()); - serial - } - } - impl Serial - where - RXPIN: RxPin, - { - /// Creates a new rx-only serial instance - pub fn usart1rx(usart: USART1, rxpin: RXPIN, baud_rate: Bps, rcc: &mut Rcc) -> Self { - let txpin = (); - let mut serial = Serial { - usart, - pins: (txpin, rxpin), - }; - serial.configure(baud_rate, rcc); - serial - .usart - .cr1 - .modify(|_, w| w.re().set_bit().ue().set_bit()); - serial - } - } - impl Serial { - fn configure(&mut self, baud_rate: Bps, rcc: &mut Rcc) { - rcc.regs.apb2enr.modify(|_, w| w.usart1en().set_bit()); - let brr = rcc.clocks.pclk().0 / baud_rate.0; - self.usart.brr.write(|w| unsafe { w.bits(brr) }); - self.usart.cr2.reset(); - self.usart.cr3.reset(); - } - /// Starts listening for an interrupt event - pub fn listen(&mut self, event: Event) { - match event { - Event::Rxne => self.usart.cr1.modify(|_, w| w.rxneie().set_bit()), - Event::Txe => self.usart.cr1.modify(|_, w| w.txeie().set_bit()), - Event::Idle => self.usart.cr1.modify(|_, w| w.idleie().set_bit()), - } - } - /// Stop listening for an interrupt event - pub fn unlisten(&mut self, event: Event) { - match event { - Event::Rxne => self.usart.cr1.modify(|_, w| w.rxneie().clear_bit()), - Event::Txe => self.usart.cr1.modify(|_, w| w.txeie().clear_bit()), - Event::Idle => self.usart.cr1.modify(|_, w| w.idleie().clear_bit()), - } - } - } - use crate::pac::USART2; - impl Serial - where - TXPIN: TxPin, - RXPIN: RxPin, - { - /// Creates a new serial instance - pub fn usart2(usart: USART2, pins: (TXPIN, RXPIN), baud_rate: Bps, rcc: &mut Rcc) -> Self { - let mut serial = Serial { usart, pins }; - serial.configure(baud_rate, rcc); - serial - .usart - .cr1 - .modify(|_, w| w.te().set_bit().re().set_bit().ue().set_bit()); - serial - } - } - impl Serial - where - TXPIN: TxPin, - { - /// Creates a new tx-only serial instance - pub fn usart2tx(usart: USART2, txpin: TXPIN, baud_rate: Bps, rcc: &mut Rcc) -> Self { - let rxpin = (); - let mut serial = Serial { - usart, - pins: (txpin, rxpin), - }; - serial.configure(baud_rate, rcc); - serial - .usart - .cr1 - .modify(|_, w| w.te().set_bit().ue().set_bit()); - serial - } - } - impl Serial - where - RXPIN: RxPin, - { - /// Creates a new rx-only serial instance - pub fn usart2rx(usart: USART2, rxpin: RXPIN, baud_rate: Bps, rcc: &mut Rcc) -> Self { - let txpin = (); - let mut serial = Serial { - usart, - pins: (txpin, rxpin), - }; - serial.configure(baud_rate, rcc); - serial - .usart - .cr1 - .modify(|_, w| w.re().set_bit().ue().set_bit()); - serial - } - } - impl Serial { - fn configure(&mut self, baud_rate: Bps, rcc: &mut Rcc) { - rcc.regs.apb1enr.modify(|_, w| w.usart2en().set_bit()); - let brr = rcc.clocks.pclk().0 / baud_rate.0; - self.usart.brr.write(|w| unsafe { w.bits(brr) }); - self.usart.cr2.reset(); - self.usart.cr3.reset(); - } - /// Starts listening for an interrupt event - pub fn listen(&mut self, event: Event) { - match event { - Event::Rxne => self.usart.cr1.modify(|_, w| w.rxneie().set_bit()), - Event::Txe => self.usart.cr1.modify(|_, w| w.txeie().set_bit()), - Event::Idle => self.usart.cr1.modify(|_, w| w.idleie().set_bit()), - } - } - /// Stop listening for an interrupt event - pub fn unlisten(&mut self, event: Event) { - match event { - Event::Rxne => self.usart.cr1.modify(|_, w| w.rxneie().clear_bit()), - Event::Txe => self.usart.cr1.modify(|_, w| w.txeie().clear_bit()), - Event::Idle => self.usart.cr1.modify(|_, w| w.idleie().clear_bit()), - } - } - } - impl embedded_hal::serial::Read for Rx - where - USART: Deref, - { - type Error = Error; - /// Tries to read a byte from the uart - fn read(&mut self) -> nb::Result { - read(self.usart) - } - } - impl embedded_hal::serial::Read for Serial - where - USART: Deref, - RXPIN: RxPin, - { - type Error = Error; - /// Tries to read a byte from the uart - fn read(&mut self) -> nb::Result { - read(&*self.usart) - } - } - impl embedded_hal::serial::Write for Tx - where - USART: Deref, - { - type Error = Infallible; - /// Ensures that none of the previously written words are still buffered - fn flush(&mut self) -> nb::Result<(), Self::Error> { - flush(self.usart) - } - /// Tries to write a byte to the uart - /// Fails if the transmit buffer is full - fn write(&mut self, byte: u8) -> nb::Result<(), Self::Error> { - write(self.usart, byte) - } - } - impl embedded_hal::serial::Write for Serial - where - USART: Deref, - TXPIN: TxPin, - { - type Error = Infallible; - /// Ensures that none of the previously written words are still buffered - fn flush(&mut self) -> nb::Result<(), Self::Error> { - flush(&*self.usart) - } - /// Tries to write a byte to the uart - /// Fails if the transmit buffer is full - fn write(&mut self, byte: u8) -> nb::Result<(), Self::Error> { - write(&*self.usart, byte) - } - } - impl Serial - where - USART: Deref, - { - /// Splits the UART Peripheral in a Tx and an Rx part - /// This is required for sending/receiving - pub fn split(self) -> (Tx, Rx) - where - TXPIN: TxPin, - RXPIN: RxPin, - { - ( - Tx { - usart: &*self.usart, - _instance: PhantomData, - }, - Rx { - usart: &*self.usart, - _instance: PhantomData, - }, - ) - } - pub fn release(self) -> (USART, (TXPIN, RXPIN)) { - (self.usart, self.pins) - } - } - impl Write for Tx - where - Tx: embedded_hal::serial::Write, - { - fn write_str(&mut self, s: &str) -> Result { - s.as_bytes() - .iter() - .try_for_each(|c| loop { - #[allow(unreachable_patterns)] - match self.write(*c) { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }) - .map_err(|_| core::fmt::Error) - } - } - impl Write for Serial - where - USART: Deref, - TXPIN: TxPin, - { - fn write_str(&mut self, s: &str) -> Result { - s.as_bytes() - .iter() - .try_for_each(|c| loop { - #[allow(unreachable_patterns)] - match self.write(*c) { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }) - .map_err(|_| core::fmt::Error) - } - } - /// Ensures that none of the previously written words are still buffered - fn flush(usart: *const SerialRegisterBlock) -> nb::Result<(), Infallible> { - let isr = unsafe { (*usart).isr.read() }; - if isr.tc().bit_is_set() { - Ok(()) - } else { - Err(nb::Error::WouldBlock) - } - } - /// Tries to write a byte to the UART - /// Returns `Err(WouldBlock)` if the transmit buffer is full - fn write(usart: *const SerialRegisterBlock, byte: u8) -> nb::Result<(), Infallible> { - let isr = unsafe { (*usart).isr.read() }; - if isr.txe().bit_is_set() { - unsafe { (*usart).tdr.write(|w| w.tdr().bits(byte as u16)) } - Ok(()) - } else { - Err(nb::Error::WouldBlock) - } - } - /// Tries to read a byte from the UART - fn read(usart: *const SerialRegisterBlock) -> nb::Result { - let isr = unsafe { (*usart).isr.read() }; - let icr = unsafe { &(*usart).icr }; - if isr.pe().bit_is_set() { - icr.write(|w| w.pecf().set_bit()); - Err(nb::Error::Other(Error::Parity)) - } else if isr.fe().bit_is_set() { - icr.write(|w| w.fecf().set_bit()); - Err(nb::Error::Other(Error::Framing)) - } else if isr.nf().bit_is_set() { - icr.write(|w| w.ncf().set_bit()); - Err(nb::Error::Other(Error::Noise)) - } else if isr.ore().bit_is_set() { - icr.write(|w| w.orecf().set_bit()); - Err(nb::Error::Other(Error::Overrun)) - } else if isr.rxne().bit_is_set() { - Ok(unsafe { (*usart).rdr.read().rdr().bits() as u8 }) - } else { - Err(nb::Error::WouldBlock) - } - } -} -#[cfg(feature = "device-selected")] -pub mod spi { - //! API for the integrate SPI peripherals - //! - //! The spi bus acts as the master (generating the clock) and you need to handle the CS separately. - //! - //! The most significant bit is transmitted first & only 8-bit transfers are supported - //! - //! # Example - //! Echo incoming data in the next transfer - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::pac; - //! use crate::hal::prelude::*; - //! use crate::hal::spi::{Spi, Mode, Phase, Polarity}; - //! - //! cortex_m::interrupt::free(|cs| { - //! let mut p = pac::Peripherals::take().unwrap(); - //! let mut rcc = p.RCC.constrain().freeze(&mut p.FLASH); - //! - //! let gpioa = p.GPIOA.split(&mut rcc); - //! - //! // Configure pins for SPI - //! let sck = gpioa.pa5.into_alternate_af0(cs); - //! let miso = gpioa.pa6.into_alternate_af0(cs); - //! let mosi = gpioa.pa7.into_alternate_af0(cs); - //! - //! // Configure SPI with 1MHz rate - //! let mut spi = Spi::spi1(p.SPI1, (sck, miso, mosi), Mode { - //! polarity: Polarity::IdleHigh, - //! phase: Phase::CaptureOnSecondTransition, - //! }, 1.mhz(), &mut rcc); - //! - //! let mut data = [0]; - //! loop { - //! spi.transfer(&mut data).unwrap(); - //! } - //! }); - //! ``` - use core::marker::PhantomData; - use core::{ops::Deref, ptr}; - pub use embedded_hal::spi::{Mode, Phase, Polarity}; - use crate::pac::SPI1; - use crate::gpio::*; - use crate::rcc::{Clocks, Rcc}; - use crate::time::Hertz; - /// Typestate for 8-bit transfer size - pub struct EightBit; - /// Typestate for 16-bit transfer size - pub struct SixteenBit; - /// SPI error - #[non_exhaustive] - pub enum Error { - /// Overrun occurred - Overrun, - /// Mode fault occurred - ModeFault, - /// CRC error - Crc, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match (&*self,) { - (&Error::Overrun,) => ::core::fmt::Formatter::write_str(f, "Overrun"), - (&Error::ModeFault,) => ::core::fmt::Formatter::write_str(f, "ModeFault"), - (&Error::Crc,) => ::core::fmt::Formatter::write_str(f, "Crc"), - } - } - } - /// SPI abstraction - pub struct Spi { - spi: SPI, - pins: (SCKPIN, MISOPIN, MOSIPIN), - _width: PhantomData, - } - pub trait SckPin {} - pub trait MisoPin {} - pub trait MosiPin {} - impl SckPin for gpioa::PA5> {} - impl SckPin for gpiob::PB3> {} - impl MisoPin for gpioa::PA6> {} - impl MisoPin for gpiob::PB4> {} - impl MosiPin for gpioa::PA7> {} - impl MosiPin for gpiob::PB5> {} - impl Spi { - /// Creates a new spi instance - pub fn spi1( - spi: SPI1, - pins: (SCKPIN, MISOPIN, MOSIPIN), - mode: Mode, - speed: F, - rcc: &mut Rcc, - ) -> Self - where - SCKPIN: SckPin, - MISOPIN: MisoPin, - MOSIPIN: MosiPin, - F: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.spi1en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.spi1rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.spi1rst().clear_bit()); - Spi:: { - spi, - pins, - _width: PhantomData, - } - .spi_init(mode, speed, rcc.clocks) - .into_8bit_width() - } - } - #[allow(dead_code)] - type SpiRegisterBlock = crate::pac::spi1::RegisterBlock; - impl Spi - where - SPI: Deref, - { - fn spi_init(self, mode: Mode, speed: F, clocks: Clocks) -> Self - where - F: Into, - { - self.spi.cr1.modify(|_, w| w.spe().clear_bit()); - let br = match clocks.pclk().0 / speed.into().0 { - 0 => ::core::panicking::panic("internal error: entered unreachable code"), - 1..=2 => 0b000, - 3..=5 => 0b001, - 6..=11 => 0b010, - 12..=23 => 0b011, - 24..=47 => 0b100, - 48..=95 => 0b101, - 96..=191 => 0b110, - _ => 0b111, - }; - self.spi.cr1.write(|w| { - w.cpha() - .bit(mode.phase == Phase::CaptureOnSecondTransition) - .cpol() - .bit(mode.polarity == Polarity::IdleHigh) - .mstr() - .set_bit() - .br() - .bits(br) - .lsbfirst() - .clear_bit() - .ssm() - .set_bit() - .ssi() - .set_bit() - .rxonly() - .clear_bit() - .bidimode() - .clear_bit() - .spe() - .set_bit() - }); - self - } - pub fn into_8bit_width(self) -> Spi { - self.spi - .cr2 - .write(|w| w.frxth().set_bit().ds().eight_bit().ssoe().clear_bit()); - Spi { - spi: self.spi, - pins: self.pins, - _width: PhantomData, - } - } - pub fn into_16bit_width(self) -> Spi { - self.spi - .cr2 - .write(|w| w.frxth().set_bit().ds().sixteen_bit().ssoe().clear_bit()); - Spi { - spi: self.spi, - pins: self.pins, - _width: PhantomData, - } - } - fn set_send_only(&mut self) { - self.spi - .cr1 - .modify(|_, w| w.bidimode().set_bit().bidioe().set_bit()); - } - fn set_bidi(&mut self) { - self.spi - .cr1 - .modify(|_, w| w.bidimode().clear_bit().bidioe().clear_bit()); - } - fn check_read(&mut self) -> nb::Result<(), Error> { - let sr = self.spi.sr.read(); - Err(if sr.ovr().bit_is_set() { - nb::Error::Other(Error::Overrun) - } else if sr.modf().bit_is_set() { - nb::Error::Other(Error::ModeFault) - } else if sr.crcerr().bit_is_set() { - nb::Error::Other(Error::Crc) - } else if sr.rxne().bit_is_set() { - return Ok(()); - } else { - nb::Error::WouldBlock - }) - } - fn send_buffer_size(&mut self) -> u8 { - match self.spi.sr.read().ftlvl().bits() { - 0 => 4, - 1 => 3, - 2 => 2, - _ => 0, - } - } - fn check_send(&mut self) -> nb::Result<(), Error> { - let sr = self.spi.sr.read(); - Err(if sr.ovr().bit_is_set() { - nb::Error::Other(Error::Overrun) - } else if sr.modf().bit_is_set() { - nb::Error::Other(Error::ModeFault) - } else if sr.crcerr().bit_is_set() { - nb::Error::Other(Error::Crc) - } else if sr.txe().bit_is_set() && sr.bsy().bit_is_clear() { - return Ok(()); - } else { - nb::Error::WouldBlock - }) - } - fn read_u8(&mut self) -> u8 { - unsafe { ptr::read_volatile(&self.spi.dr as *const _ as *const u8) } - } - fn send_u8(&mut self, byte: u8) { - unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u8, byte) } - } - fn read_u16(&mut self) -> u16 { - unsafe { ptr::read_volatile(&self.spi.dr as *const _ as *const u16) } - } - fn send_u16(&mut self, byte: u16) { - unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u16, byte) } - } - pub fn release(self) -> (SPI, (SCKPIN, MISOPIN, MOSIPIN)) { - (self.spi, self.pins) - } - } - impl ::embedded_hal::blocking::spi::Transfer - for Spi - where - SPI: Deref, - { - type Error = Error; - fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> { - self.set_bidi(); - for word in words.iter_mut() { - loop { - #[allow(unreachable_patterns)] - match self.check_send() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }?; - self.send_u8(*word); - loop { - #[allow(unreachable_patterns)] - match self.check_read() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }?; - *word = self.read_u8(); - } - Ok(words) - } - } - impl ::embedded_hal::blocking::spi::Write - for Spi - where - SPI: Deref, - { - type Error = Error; - fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - let mut bufcap: u8 = 0; - self.set_send_only(); - loop { - #[allow(unreachable_patterns)] - match self.check_send() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }?; - for word in words { - while bufcap == 0 { - bufcap = self.send_buffer_size(); - } - self.send_u8(*word); - bufcap -= 1; - } - loop { - #[allow(unreachable_patterns)] - match self.check_send() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - } - .ok(); - Ok(()) - } - } - impl ::embedded_hal::blocking::spi::Transfer - for Spi - where - SPI: Deref, - { - type Error = Error; - fn transfer<'w>(&mut self, words: &'w mut [u16]) -> Result<&'w [u16], Self::Error> { - self.set_bidi(); - for word in words.iter_mut() { - loop { - #[allow(unreachable_patterns)] - match self.check_send() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }?; - self.send_u16(*word); - loop { - #[allow(unreachable_patterns)] - match self.check_read() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }?; - *word = self.read_u16(); - } - Ok(words) - } - } - impl ::embedded_hal::blocking::spi::Write - for Spi - where - SPI: Deref, - { - type Error = Error; - fn write(&mut self, words: &[u16]) -> Result<(), Self::Error> { - self.set_send_only(); - for word in words { - loop { - #[allow(unreachable_patterns)] - match self.check_send() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - }?; - self.send_u16(*word); - } - loop { - #[allow(unreachable_patterns)] - match self.check_send() { - Err(::nb::Error::Other(e)) => - { - #[allow(unreachable_code)] - break Err(e) - } - Err(::nb::Error::WouldBlock) => {} - Ok(x) => break Ok(x), - } - } - .ok(); - Ok(()) - } - } -} -#[cfg(feature = "device-selected")] -pub mod time { - /// Bits per second - pub struct Bps(pub u32); - impl ::core::marker::StructuralPartialEq for Bps {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for Bps { - #[inline] - fn eq(&self, other: &Bps) -> bool { - match *other { - Bps(ref __self_1_0) => match *self { - Bps(ref __self_0_0) => (*__self_0_0) == (*__self_1_0), - }, - } - } - #[inline] - fn ne(&self, other: &Bps) -> bool { - match *other { - Bps(ref __self_1_0) => match *self { - Bps(ref __self_0_0) => (*__self_0_0) != (*__self_1_0), - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialOrd for Bps { - #[inline] - fn partial_cmp(&self, other: &Bps) -> ::core::option::Option<::core::cmp::Ordering> { - match *other { - Bps(ref __self_1_0) => match *self { - Bps(ref __self_0_0) => { - match ::core::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)) { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) => { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) - } - cmp => cmp, - } - } - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for Bps { - #[inline] - fn clone(&self) -> Bps { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for Bps {} - pub struct Hertz(pub u32); - impl ::core::marker::StructuralPartialEq for Hertz {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for Hertz { - #[inline] - fn eq(&self, other: &Hertz) -> bool { - match *other { - Hertz(ref __self_1_0) => match *self { - Hertz(ref __self_0_0) => (*__self_0_0) == (*__self_1_0), - }, - } - } - #[inline] - fn ne(&self, other: &Hertz) -> bool { - match *other { - Hertz(ref __self_1_0) => match *self { - Hertz(ref __self_0_0) => (*__self_0_0) != (*__self_1_0), - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialOrd for Hertz { - #[inline] - fn partial_cmp(&self, other: &Hertz) -> ::core::option::Option<::core::cmp::Ordering> { - match *other { - Hertz(ref __self_1_0) => match *self { - Hertz(ref __self_0_0) => { - match ::core::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)) { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) => { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) - } - cmp => cmp, - } - } - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for Hertz { - #[inline] - fn clone(&self) -> Hertz { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for Hertz {} - pub struct KiloHertz(pub u32); - impl ::core::marker::StructuralPartialEq for KiloHertz {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for KiloHertz { - #[inline] - fn eq(&self, other: &KiloHertz) -> bool { - match *other { - KiloHertz(ref __self_1_0) => match *self { - KiloHertz(ref __self_0_0) => (*__self_0_0) == (*__self_1_0), - }, - } - } - #[inline] - fn ne(&self, other: &KiloHertz) -> bool { - match *other { - KiloHertz(ref __self_1_0) => match *self { - KiloHertz(ref __self_0_0) => (*__self_0_0) != (*__self_1_0), - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialOrd for KiloHertz { - #[inline] - fn partial_cmp(&self, other: &KiloHertz) -> ::core::option::Option<::core::cmp::Ordering> { - match *other { - KiloHertz(ref __self_1_0) => match *self { - KiloHertz(ref __self_0_0) => { - match ::core::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)) { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) => { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) - } - cmp => cmp, - } - } - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for KiloHertz { - #[inline] - fn clone(&self) -> KiloHertz { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for KiloHertz {} - pub struct MegaHertz(pub u32); - impl ::core::marker::StructuralPartialEq for MegaHertz {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for MegaHertz { - #[inline] - fn eq(&self, other: &MegaHertz) -> bool { - match *other { - MegaHertz(ref __self_1_0) => match *self { - MegaHertz(ref __self_0_0) => (*__self_0_0) == (*__self_1_0), - }, - } - } - #[inline] - fn ne(&self, other: &MegaHertz) -> bool { - match *other { - MegaHertz(ref __self_1_0) => match *self { - MegaHertz(ref __self_0_0) => (*__self_0_0) != (*__self_1_0), - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialOrd for MegaHertz { - #[inline] - fn partial_cmp(&self, other: &MegaHertz) -> ::core::option::Option<::core::cmp::Ordering> { - match *other { - MegaHertz(ref __self_1_0) => match *self { - MegaHertz(ref __self_0_0) => { - match ::core::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)) { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) => { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) - } - cmp => cmp, - } - } - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for MegaHertz { - #[inline] - fn clone(&self) -> MegaHertz { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for MegaHertz {} - /// Extension trait that adds convenience methods to the `u32` type - pub trait U32Ext { - /// Wrap in `Bps` - fn bps(self) -> Bps; - /// Wrap in `Hertz` - fn hz(self) -> Hertz; - /// Wrap in `KiloHertz` - fn khz(self) -> KiloHertz; - /// Wrap in `MegaHertz` - fn mhz(self) -> MegaHertz; - } - impl U32Ext for u32 { - fn bps(self) -> Bps { - Bps(self) - } - fn hz(self) -> Hertz { - Hertz(self) - } - fn khz(self) -> KiloHertz { - KiloHertz(self) - } - fn mhz(self) -> MegaHertz { - MegaHertz(self) - } - } - impl Into for KiloHertz { - fn into(self) -> Hertz { - Hertz(self.0 * 1_000) - } - } - impl Into for MegaHertz { - fn into(self) -> Hertz { - Hertz(self.0 * 1_000_000) - } - } - impl Into for MegaHertz { - fn into(self) -> KiloHertz { - KiloHertz(self.0 * 1_000) - } - } -} -#[cfg(feature = "device-selected")] -pub mod timers { - //! API for the integrated timers - //! - //! This only implements basic functions, a lot of things are missing - //! - //! # Example - //! Blink the led with 1Hz - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::pac; - //! use crate::hal::prelude::*; - //! use crate::hal::time::*; - //! use crate::hal::timers::*; - //! use nb::block; - //! - //! cortex_m::interrupt::free(|cs| { - //! let mut p = pac::Peripherals::take().unwrap(); - //! let mut rcc = p.RCC.configure().freeze(&mut p.FLASH); - //! - //! let gpioa = p.GPIOA.split(&mut rcc); - //! - //! let mut led = gpioa.pa1.into_push_pull_pull_output(cs); - //! - //! let mut timer = Timer::tim1(p.TIM1, Hertz(1), &mut rcc); - //! loop { - //! led.toggle(); - //! block!(timer.wait()).ok(); - //! } - //! }); - //! ``` - use cortex_m::peripheral::syst::SystClkSource; - use cortex_m::peripheral::SYST; - use crate::rcc::{Clocks, Rcc}; - use crate::time::Hertz; - use embedded_hal::timer::{CountDown, Periodic}; - use void::Void; - /// Hardware timers - pub struct Timer { - clocks: Clocks, - tim: TIM, - } - /// Interrupt events - pub enum Event { - /// Timer timed out / count down ended - TimeOut, - } - impl Timer { - /// Configures the SYST clock as a periodic count down timer - pub fn syst(mut syst: SYST, timeout: T, rcc: &Rcc) -> Self - where - T: Into, - { - syst.set_clock_source(SystClkSource::Core); - let mut timer = Timer { - tim: syst, - clocks: rcc.clocks, - }; - timer.start(timeout); - timer - } - /// Starts listening for an `event` - pub fn listen(&mut self, event: &Event) { - match event { - Event::TimeOut => self.tim.enable_interrupt(), - } - } - /// Stops listening for an `event` - pub fn unlisten(&mut self, event: &Event) { - match event { - Event::TimeOut => self.tim.disable_interrupt(), - } - } - } - /// Use the systick as a timer - /// - /// Be aware that intervals less than 4 Hertz may not function properly - impl CountDown for Timer { - type Time = Hertz; - /// Start the timer with a `timeout` - fn start(&mut self, timeout: T) - where - T: Into, - { - let rvr = self.clocks.sysclk().0 / timeout.into().0 - 1; - if !(rvr < (1 << 24)) { - ::core::panicking::panic("assertion failed: rvr < (1 << 24)") - }; - self.tim.set_reload(rvr); - self.tim.clear_current(); - self.tim.enable_counter(); - } - /// Return `Ok` if the timer has wrapped - /// Automatically clears the flag and restarts the time - fn wait(&mut self) -> nb::Result<(), Void> { - if self.tim.has_wrapped() { - Ok(()) - } else { - Err(nb::Error::WouldBlock) - } - } - } - impl Periodic for Timer {} - use crate::pac::TIM1; - impl Timer { - /// Configures a TIM peripheral as a periodic count down timer - pub fn tim1(tim: TIM1, timeout: T, rcc: &mut Rcc) -> Self - where - T: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.tim1en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim1rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim1rst().clear_bit()); - let mut timer = Timer { - clocks: rcc.clocks, - tim, - }; - timer.start(timeout); - timer - } - /// Starts listening for an `event` - pub fn listen(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().set_bit()); - } - } - } - /// Stops listening for an `event` - pub fn unlisten(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().clear_bit()); - } - } - } - /// Releases the TIM peripheral - pub fn release(self) -> TIM1 { - let rcc = unsafe { &(*crate::pac::RCC::ptr()) }; - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - rcc.apb2enr.modify(|_, w| w.tim1en().clear_bit()); - self.tim - } - } - impl CountDown for Timer { - type Time = Hertz; - /// Start the timer with a `timeout` - fn start(&mut self, timeout: T) - where - T: Into, - { - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - self.tim.cnt.reset(); - let frequency = timeout.into().0; - let tclk = if self.clocks.hclk().0 == self.clocks.pclk().0 { - self.clocks.pclk().0 - } else { - self.clocks.pclk().0 * 2 - }; - let ticks = tclk / frequency; - let psc = cast::u16((ticks - 1) / (1 << 16)).unwrap(); - self.tim.psc.write(|w| w.psc().bits(psc)); - let arr = cast::u16(ticks / cast::u32(psc + 1)).unwrap(); - self.tim.arr.write(|w| unsafe { w.bits(cast::u32(arr)) }); - self.tim.cr1.modify(|_, w| w.cen().set_bit()); - } - /// Return `Ok` if the timer has wrapped - /// Automatically clears the flag and restarts the time - fn wait(&mut self) -> nb::Result<(), Void> { - if self.tim.sr.read().uif().bit_is_clear() { - Err(nb::Error::WouldBlock) - } else { - self.tim.sr.modify(|_, w| w.uif().clear_bit()); - Ok(()) - } - } - } - impl Periodic for Timer {} - use crate::pac::TIM3; - impl Timer { - /// Configures a TIM peripheral as a periodic count down timer - pub fn tim3(tim: TIM3, timeout: T, rcc: &mut Rcc) -> Self - where - T: Into, - { - rcc.regs.apb1enr.modify(|_, w| w.tim3en().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim3rst().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim3rst().clear_bit()); - let mut timer = Timer { - clocks: rcc.clocks, - tim, - }; - timer.start(timeout); - timer - } - /// Starts listening for an `event` - pub fn listen(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().set_bit()); - } - } - } - /// Stops listening for an `event` - pub fn unlisten(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().clear_bit()); - } - } - } - /// Releases the TIM peripheral - pub fn release(self) -> TIM3 { - let rcc = unsafe { &(*crate::pac::RCC::ptr()) }; - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - rcc.apb1enr.modify(|_, w| w.tim3en().clear_bit()); - self.tim - } - } - impl CountDown for Timer { - type Time = Hertz; - /// Start the timer with a `timeout` - fn start(&mut self, timeout: T) - where - T: Into, - { - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - self.tim.cnt.reset(); - let frequency = timeout.into().0; - let tclk = if self.clocks.hclk().0 == self.clocks.pclk().0 { - self.clocks.pclk().0 - } else { - self.clocks.pclk().0 * 2 - }; - let ticks = tclk / frequency; - let psc = cast::u16((ticks - 1) / (1 << 16)).unwrap(); - self.tim.psc.write(|w| w.psc().bits(psc)); - let arr = cast::u16(ticks / cast::u32(psc + 1)).unwrap(); - self.tim.arr.write(|w| unsafe { w.bits(cast::u32(arr)) }); - self.tim.cr1.modify(|_, w| w.cen().set_bit()); - } - /// Return `Ok` if the timer has wrapped - /// Automatically clears the flag and restarts the time - fn wait(&mut self) -> nb::Result<(), Void> { - if self.tim.sr.read().uif().bit_is_clear() { - Err(nb::Error::WouldBlock) - } else { - self.tim.sr.modify(|_, w| w.uif().clear_bit()); - Ok(()) - } - } - } - impl Periodic for Timer {} - use crate::pac::TIM14; - impl Timer { - /// Configures a TIM peripheral as a periodic count down timer - pub fn tim14(tim: TIM14, timeout: T, rcc: &mut Rcc) -> Self - where - T: Into, - { - rcc.regs.apb1enr.modify(|_, w| w.tim14en().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim14rst().set_bit()); - rcc.regs.apb1rstr.modify(|_, w| w.tim14rst().clear_bit()); - let mut timer = Timer { - clocks: rcc.clocks, - tim, - }; - timer.start(timeout); - timer - } - /// Starts listening for an `event` - pub fn listen(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().set_bit()); - } - } - } - /// Stops listening for an `event` - pub fn unlisten(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().clear_bit()); - } - } - } - /// Releases the TIM peripheral - pub fn release(self) -> TIM14 { - let rcc = unsafe { &(*crate::pac::RCC::ptr()) }; - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - rcc.apb1enr.modify(|_, w| w.tim14en().clear_bit()); - self.tim - } - } - impl CountDown for Timer { - type Time = Hertz; - /// Start the timer with a `timeout` - fn start(&mut self, timeout: T) - where - T: Into, - { - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - self.tim.cnt.reset(); - let frequency = timeout.into().0; - let tclk = if self.clocks.hclk().0 == self.clocks.pclk().0 { - self.clocks.pclk().0 - } else { - self.clocks.pclk().0 * 2 - }; - let ticks = tclk / frequency; - let psc = cast::u16((ticks - 1) / (1 << 16)).unwrap(); - self.tim.psc.write(|w| w.psc().bits(psc)); - let arr = cast::u16(ticks / cast::u32(psc + 1)).unwrap(); - self.tim.arr.write(|w| unsafe { w.bits(cast::u32(arr)) }); - self.tim.cr1.modify(|_, w| w.cen().set_bit()); - } - /// Return `Ok` if the timer has wrapped - /// Automatically clears the flag and restarts the time - fn wait(&mut self) -> nb::Result<(), Void> { - if self.tim.sr.read().uif().bit_is_clear() { - Err(nb::Error::WouldBlock) - } else { - self.tim.sr.modify(|_, w| w.uif().clear_bit()); - Ok(()) - } - } - } - impl Periodic for Timer {} - use crate::pac::TIM16; - impl Timer { - /// Configures a TIM peripheral as a periodic count down timer - pub fn tim16(tim: TIM16, timeout: T, rcc: &mut Rcc) -> Self - where - T: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.tim16en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim16rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim16rst().clear_bit()); - let mut timer = Timer { - clocks: rcc.clocks, - tim, - }; - timer.start(timeout); - timer - } - /// Starts listening for an `event` - pub fn listen(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().set_bit()); - } - } - } - /// Stops listening for an `event` - pub fn unlisten(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().clear_bit()); - } - } - } - /// Releases the TIM peripheral - pub fn release(self) -> TIM16 { - let rcc = unsafe { &(*crate::pac::RCC::ptr()) }; - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - rcc.apb2enr.modify(|_, w| w.tim16en().clear_bit()); - self.tim - } - } - impl CountDown for Timer { - type Time = Hertz; - /// Start the timer with a `timeout` - fn start(&mut self, timeout: T) - where - T: Into, - { - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - self.tim.cnt.reset(); - let frequency = timeout.into().0; - let tclk = if self.clocks.hclk().0 == self.clocks.pclk().0 { - self.clocks.pclk().0 - } else { - self.clocks.pclk().0 * 2 - }; - let ticks = tclk / frequency; - let psc = cast::u16((ticks - 1) / (1 << 16)).unwrap(); - self.tim.psc.write(|w| w.psc().bits(psc)); - let arr = cast::u16(ticks / cast::u32(psc + 1)).unwrap(); - self.tim.arr.write(|w| unsafe { w.bits(cast::u32(arr)) }); - self.tim.cr1.modify(|_, w| w.cen().set_bit()); - } - /// Return `Ok` if the timer has wrapped - /// Automatically clears the flag and restarts the time - fn wait(&mut self) -> nb::Result<(), Void> { - if self.tim.sr.read().uif().bit_is_clear() { - Err(nb::Error::WouldBlock) - } else { - self.tim.sr.modify(|_, w| w.uif().clear_bit()); - Ok(()) - } - } - } - impl Periodic for Timer {} - use crate::pac::TIM17; - impl Timer { - /// Configures a TIM peripheral as a periodic count down timer - pub fn tim17(tim: TIM17, timeout: T, rcc: &mut Rcc) -> Self - where - T: Into, - { - rcc.regs.apb2enr.modify(|_, w| w.tim17en().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim17rst().set_bit()); - rcc.regs.apb2rstr.modify(|_, w| w.tim17rst().clear_bit()); - let mut timer = Timer { - clocks: rcc.clocks, - tim, - }; - timer.start(timeout); - timer - } - /// Starts listening for an `event` - pub fn listen(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().set_bit()); - } - } - } - /// Stops listening for an `event` - pub fn unlisten(&mut self, event: Event) { - match event { - Event::TimeOut => { - self.tim.dier.write(|w| w.uie().clear_bit()); - } - } - } - /// Releases the TIM peripheral - pub fn release(self) -> TIM17 { - let rcc = unsafe { &(*crate::pac::RCC::ptr()) }; - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - rcc.apb2enr.modify(|_, w| w.tim17en().clear_bit()); - self.tim - } - } - impl CountDown for Timer { - type Time = Hertz; - /// Start the timer with a `timeout` - fn start(&mut self, timeout: T) - where - T: Into, - { - self.tim.cr1.modify(|_, w| w.cen().clear_bit()); - self.tim.cnt.reset(); - let frequency = timeout.into().0; - let tclk = if self.clocks.hclk().0 == self.clocks.pclk().0 { - self.clocks.pclk().0 - } else { - self.clocks.pclk().0 * 2 - }; - let ticks = tclk / frequency; - let psc = cast::u16((ticks - 1) / (1 << 16)).unwrap(); - self.tim.psc.write(|w| w.psc().bits(psc)); - let arr = cast::u16(ticks / cast::u32(psc + 1)).unwrap(); - self.tim.arr.write(|w| unsafe { w.bits(cast::u32(arr)) }); - self.tim.cr1.modify(|_, w| w.cen().set_bit()); - } - /// Return `Ok` if the timer has wrapped - /// Automatically clears the flag and restarts the time - fn wait(&mut self) -> nb::Result<(), Void> { - if self.tim.sr.read().uif().bit_is_clear() { - Err(nb::Error::WouldBlock) - } else { - self.tim.sr.modify(|_, w| w.uif().clear_bit()); - Ok(()) - } - } - } - impl Periodic for Timer {} - use crate::gpio::{AF0, AF1, AF2, AF4, AF5}; - use crate::gpio::{gpioa::*, gpiob::*, Alternate}; - pub trait PinC1 {} - pub trait PinC2 {} - pub trait PinC3 {} - pub trait PinC4 {} - impl PinC1 for PA8> {} - impl PinC2 for PA9> {} - impl PinC3 for PA10> {} - impl PinC4 for PA11> {} - impl PinC1 for PA6> {} - impl PinC2 for PA7> {} - impl PinC1 for PB4> {} - impl PinC2 for PB5> {} - impl PinC3 for PB0> {} - impl PinC4 for PB1> {} - impl PinC1 for PA4> {} - impl PinC1 for PA7> {} - impl PinC1 for PB1> {} - impl PinC1 for PA6> {} - impl PinC1 for PB8> {} - impl PinC1 for PA7> {} - impl PinC1 for PB9> {} - #[cfg(any( - feature = "stm32f030", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098" - ))] - use crate::gpio::gpioc::*; - impl PinC1 for PC6> {} - impl PinC2 for PC7> {} - impl PinC3 for PC8> {} - impl PinC4 for PC9> {} -} -#[cfg(feature = "device-selected")] -pub mod watchdog { - //! API for the IWDG - //! - //! You can activate the watchdog by calling `start` or the setting appropriate - //! device option bit when programming. - //! - //! After activating the watchdog, you'll have to regularly `feed` the watchdog. - //! If more time than `timeout` has gone by since the last `feed`, your - //! microcontroller will be reset. - //! - //! This is useful if you fear that your program may get stuck. In that case it - //! won't feed the watchdog anymore, the watchdog will reset the microcontroller - //! and thus your program will function again. - //! - //! **Attention**: - //! - //! The IWDG runs on a separate 40kHz low-accuracy clock (30kHz-60kHz). You may - //! want to some buffer in your interval. - //! - //! Per default the iwdg continues to run even when you stopped execution of code via a debugger. - //! You may want to disable the watchdog when the cpu is stopped - //! - //! ``` ignore - //! let dbgmcu = p.DBGMCU; - //! dbgmcu.apb1_fz.modify(|_, w| w.dbg_iwdg_stop().set_bit()); - //! ``` - //! - //! # Example - //! ``` no_run - //! use stm32f0xx_hal as hal; - //! - //! use crate::hal::pac; - //! use crate::hal::prelude::*; - //! use crate::hal:watchdog::Watchdog; - //! use crate::hal:time::Hertz; - //! - //! let mut p = pac::Peripherals::take().unwrap(); - //! - //! let mut iwdg = Watchdog::new(p.iwdg); - //! iwdg.start(Hertz(100)); - //! loop {} - //! // Whoops, got stuck, the watchdog issues a reset after 10 ms - //! iwdg.feed(); - //! ``` - use embedded_hal::watchdog; - use crate::pac::IWDG; - use crate::time::Hertz; - /// Watchdog instance - pub struct Watchdog { - iwdg: IWDG, - } - impl watchdog::Watchdog for Watchdog { - /// Feed the watchdog, so that at least one `period` goes by before the next - /// reset - fn feed(&mut self) { - self.iwdg.kr.write(|w| w.key().reset()); - } - } - /// Timeout configuration for the IWDG - pub struct IwdgTimeout { - psc: u8, - reload: u16, - } - impl ::core::marker::StructuralPartialEq for IwdgTimeout {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for IwdgTimeout { - #[inline] - fn eq(&self, other: &IwdgTimeout) -> bool { - match *other { - IwdgTimeout { - psc: ref __self_1_0, - reload: ref __self_1_1, - } => match *self { - IwdgTimeout { - psc: ref __self_0_0, - reload: ref __self_0_1, - } => (*__self_0_0) == (*__self_1_0) && (*__self_0_1) == (*__self_1_1), - }, - } - } - #[inline] - fn ne(&self, other: &IwdgTimeout) -> bool { - match *other { - IwdgTimeout { - psc: ref __self_1_0, - reload: ref __self_1_1, - } => match *self { - IwdgTimeout { - psc: ref __self_0_0, - reload: ref __self_0_1, - } => (*__self_0_0) != (*__self_1_0) || (*__self_0_1) != (*__self_1_1), - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialOrd for IwdgTimeout { - #[inline] - fn partial_cmp( - &self, - other: &IwdgTimeout, - ) -> ::core::option::Option<::core::cmp::Ordering> { - match *other { - IwdgTimeout { - psc: ref __self_1_0, - reload: ref __self_1_1, - } => match *self { - IwdgTimeout { - psc: ref __self_0_0, - reload: ref __self_0_1, - } => match ::core::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)) - { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) => { - match ::core::cmp::PartialOrd::partial_cmp( - &(*__self_0_1), - &(*__self_1_1), - ) { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) => { - ::core::option::Option::Some(::core::cmp::Ordering::Equal) - } - cmp => cmp, - } - } - cmp => cmp, - }, - }, - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for IwdgTimeout { - #[inline] - fn clone(&self) -> IwdgTimeout { - { - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for IwdgTimeout {} - impl Into for Hertz { - /// This converts the value so it's usable by the IWDG - /// Due to conversion losses, the specified frequency is a maximum - /// - /// It can also only represent values < 10000 Hertz - fn into(self) -> IwdgTimeout { - let mut time = 40_000 / 4 / self.0; - let mut psc = 0; - let mut reload = 0; - while psc < 7 { - reload = time; - if reload < 0x1000 { - break; - } - psc += 1; - time /= 2; - } - let reload = reload as u16; - IwdgTimeout { psc, reload } - } - } - impl Watchdog { - pub fn new(iwdg: IWDG) -> Self { - Self { iwdg } - } - } - impl watchdog::WatchdogEnable for Watchdog { - type Time = IwdgTimeout; - fn start(&mut self, period: T) - where - T: Into, - { - let time: IwdgTimeout = period.into(); - self.iwdg.kr.write(|w| w.key().reset()); - self.iwdg.kr.write(|w| w.key().start()); - self.iwdg.kr.write(|w| w.key().enable()); - while self.iwdg.sr.read().pvu().bit() {} - self.iwdg.pr.write(|w| w.pr().bits(time.psc)); - while self.iwdg.sr.read().rvu().bit() {} - self.iwdg.rlr.write(|w| w.rl().bits(time.reload)); - while self.iwdg.sr.read().bits() != 0 {} - self.iwdg.kr.write(|w| w.key().reset()); - } - } -} -#[cfg(feature = "device-selected")] -#[deprecated(since = "0.17.0", note = "please use `pac` instead")] -pub use pac as stm32; diff --git a/docs/gpio_orig_stm32f0xx.rs b/docs/gpio_orig_stm32f0xx.rs deleted file mode 100644 index 6bcd0d7..0000000 --- a/docs/gpio_orig_stm32f0xx.rs +++ /dev/null @@ -1,761 +0,0 @@ -//! General Purpose Input / Output - -use core::convert::Infallible; -use core::marker::PhantomData; - -use crate::rcc::Rcc; - -/// Extension trait to split a GPIO peripheral in independent pins and registers -pub trait GpioExt { - /// The parts to split the GPIO into - type Parts; - - /// Splits the GPIO block into independent pins and registers - fn split(self, rcc: &mut Rcc) -> Self::Parts; -} - -trait GpioRegExt { - fn is_low(&self, pos: u8) -> bool; - fn is_set_low(&self, pos: u8) -> bool; - fn set_high(&self, pos: u8); - fn set_low(&self, pos: u8); -} - -/// Alternate function 0 -pub struct AF0; -/// Alternate function 1 -pub struct AF1; -/// Alternate function 2 -pub struct AF2; -/// Alternate function 3 -pub struct AF3; -/// Alternate function 4 -pub struct AF4; -/// Alternate function 5 -pub struct AF5; -/// Alternate function 6 -pub struct AF6; -/// Alternate function 7 -pub struct AF7; - -/// Alternate function mode (type state) -pub struct Alternate { - _mode: PhantomData, -} - -/// Input mode (type state) -pub struct Input { - _mode: PhantomData, -} - -/// Floating input (type state) -pub struct Floating; - -/// Pulled down input (type state) -pub struct PullDown; - -/// Pulled up input (type state) -pub struct PullUp; - -/// Open drain input or output (type state) -pub struct OpenDrain; - -/// Analog mode (type state) -pub struct Analog; - -/// Output mode (type state) -pub struct Output { - _mode: PhantomData, -} - -/// Push pull output (type state) -pub struct PushPull; - -use embedded_hal::digital::v2::{toggleable, InputPin, OutputPin, StatefulOutputPin}; - -/// Fully erased pin -pub struct Pin { - i: u8, - port: *const dyn GpioRegExt, - _mode: PhantomData, -} - -// NOTE(unsafe) The only write acess is to BSRR, which is thread safe -unsafe impl Sync for Pin {} -// NOTE(unsafe) this only enables read access to the same pin from multiple -// threads -unsafe impl Send for Pin {} - -impl StatefulOutputPin for Pin> { - #[inline(always)] - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - - #[inline(always)] - fn is_set_low(&self) -> Result { - Ok(unsafe { (*self.port).is_set_low(self.i) }) - } -} - -impl OutputPin for Pin> { - type Error = Infallible; - - #[inline(always)] - fn set_high(&mut self) -> Result<(), Self::Error> { - unsafe { (*self.port).set_high(self.i) }; - Ok(()) - } - - #[inline(always)] - fn set_low(&mut self) -> Result<(), Self::Error> { - unsafe { (*self.port).set_low(self.i) } - Ok(()) - } -} - -impl toggleable::Default for Pin> {} - -impl InputPin for Pin> { - type Error = Infallible; - - #[inline(always)] - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - - #[inline(always)] - fn is_low(&self) -> Result { - Ok(unsafe { (*self.port).is_low(self.i) }) - } -} - -impl InputPin for Pin> { - type Error = Infallible; - - #[inline(always)] - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - - #[inline(always)] - fn is_low(&self) -> Result { - Ok(unsafe { (*self.port).is_low(self.i) }) - } -} - -macro_rules! gpio_trait { - ($gpiox:ident) => { - impl GpioRegExt for crate::pac::$gpiox::RegisterBlock { - fn is_low(&self, pos: u8) -> bool { - // NOTE(unsafe) atomic read with no side effects - self.idr.read().bits() & (1 << pos) == 0 - } - - fn is_set_low(&self, pos: u8) -> bool { - // NOTE(unsafe) atomic read with no side effects - self.odr.read().bits() & (1 << pos) == 0 - } - - fn set_high(&self, pos: u8) { - // NOTE(unsafe) atomic write to a stateless register - unsafe { self.bsrr.write(|w| w.bits(1 << pos)) } - } - - fn set_low(&self, pos: u8) { - // NOTE(unsafe) atomic write to a stateless register - unsafe { self.bsrr.write(|w| w.bits(1 << (pos + 16))) } - } - } - }; -} - -gpio_trait!(gpioa); -gpio_trait!(gpiof); - -macro_rules! gpio { - ([$($GPIOX:ident, $gpiox:ident, $iopxenr:ident, $PXx:ident, $gate:meta => [ - $($PXi:ident: ($pxi:ident, $i:expr, $MODE:ty),)+ - ]),+]) => { - $( - /// GPIO - #[cfg($gate)] - pub mod $gpiox { - use core::marker::PhantomData; - use core::convert::Infallible; - - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{ - rcc::Rcc, - pac::$GPIOX - }; - - use cortex_m::interrupt::CriticalSection; - - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, - PullDown, PullUp, PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, - Pin, GpioRegExt, - }; - - /// GPIO parts - pub struct Parts { - $( - /// Pin - pub $pxi: $PXi<$MODE>, - )+ - } - - impl GpioExt for $GPIOX { - type Parts = Parts; - - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.$iopxenr().set_bit()); - - Parts { - $( - $pxi: $PXi { _mode: PhantomData }, - )+ - } - } - } - - fn _set_alternate_mode (index:usize, mode: u32) - { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*$GPIOX::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset)) - }); - } - } - - $( - /// Pin - pub struct $PXi { - _mode: PhantomData, - } - - impl $PXi { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 0); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 1); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 2); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 3); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 4); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 5); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 6); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7( - self, _cs: &CriticalSection - ) -> $PXi> { - _set_alternate_mode($i, 7); - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input( - self, _cs: &CriticalSection - ) -> $PXi> { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input( - self, _cs: &CriticalSection - ) -> $PXi> { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input( - self, _cs: &CriticalSection - ) -> $PXi> { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as an analog pin - pub fn into_analog( - self, _cs: &CriticalSection - ) -> $PXi { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output( - self, _cs: &CriticalSection - ) -> $PXi> { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - reg.otyper.modify(|r, w| { - w.bits(r.bits() | (0b1 << $i)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output( - self, _cs: &CriticalSection - ) -> $PXi> { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - reg.otyper.modify(|r, w| { - w.bits(r.bits() & !(0b1 << $i)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs( - self, _cs: &CriticalSection - ) -> $PXi> { - let offset = 2 * $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset)) - }); - reg.otyper.modify(|r, w| { - w.bits(r.bits() & !(0b1 << $i)) - }); - reg.ospeedr.modify(|r, w| { - w.bits(r.bits() & !(0b1 << $i)) - }); - reg.moder.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset)) - }); - } - $PXi { _mode: PhantomData } - } - } - - impl $PXi> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * $i; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (value << offset)) - }); - } - } - } - - impl $PXi> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * $i; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.pupdr.modify(|r, w| { - w.bits((r.bits() & !(0b11 << offset)) | (value << offset)) - }); - } - self - } - } - - impl $PXi> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = $i; - unsafe { - let reg = &(*$GPIOX::ptr()); - reg.otyper.modify(|r, w| { - w.bits(r.bits() | (1 << offset)) - }); - } - self - } - } - - impl $PXi> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: $i, - port: $GPIOX::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - - impl StatefulOutputPin for $PXi> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - - fn is_set_low(&self) -> Result { - Ok(unsafe { (*$GPIOX::ptr()).is_set_low($i) }) - } - } - - impl OutputPin for $PXi> { - type Error = Infallible; - - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*$GPIOX::ptr()).set_high($i) }) - } - - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*$GPIOX::ptr()).set_low($i) }) - } - } - - impl toggleable::Default for $PXi> {} - - impl InputPin for $PXi> { - type Error = Infallible; - - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - - fn is_low(&self) -> Result { - Ok(unsafe { (*$GPIOX::ptr()).is_low($i) }) - } - } - - impl $PXi> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: $i, - port: $GPIOX::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - - impl InputPin for $PXi> { - type Error = Infallible; - - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - - fn is_low(&self) -> Result { - Ok(unsafe { (*$GPIOX::ptr()).is_low($i) }) - } - } - )+ - } - )+ - } -} - -gpio!([ - GPIOA, gpioa, iopaen, PA, any( - feature = "device-selected" - ) => [ - PA0: (pa0, 0, Input), - PA1: (pa1, 1, Input), - PA2: (pa2, 2, Input), - PA3: (pa3, 3, Input), - PA4: (pa4, 4, Input), - PA5: (pa5, 5, Input), - PA6: (pa6, 6, Input), - PA7: (pa7, 7, Input), - PA8: (pa8, 8, Input), - PA9: (pa9, 9, Input), - PA10: (pa10, 10, Input), - PA11: (pa11, 11, Input), - PA12: (pa12, 12, Input), - PA13: (pa13, 13, Input), - PA14: (pa14, 14, Input), - PA15: (pa15, 15, Input), - ], - GPIOB, gpiob, iopben, PB, any( - feature = "device-selected" - ) => [ - PB0: (pb0, 0, Input), - PB1: (pb1, 1, Input), - PB2: (pb2, 2, Input), - PB3: (pb3, 3, Input), - PB4: (pb4, 4, Input), - PB5: (pb5, 5, Input), - PB6: (pb6, 6, Input), - PB7: (pb7, 7, Input), - PB8: (pb8, 8, Input), - PB9: (pb9, 9, Input), - PB10: (pb10, 10, Input), - PB11: (pb11, 11, Input), - PB12: (pb12, 12, Input), - PB13: (pb13, 13, Input), - PB14: (pb14, 14, Input), - PB15: (pb15, 15, Input), - ], - GPIOC, gpioc, iopcen, PC, any( - feature = "stm32f031", - feature = "stm32f038", - feature = "stm32f042", - feature = "stm32f048" - ) => [ - PC13: (pc13, 13, Input), - PC14: (pc14, 14, Input), - PC15: (pc15, 15, Input), - ], - GPIOC, gpioc, iopcen, PC, any( - feature = "stm32f030", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098" - ) => [ - PC0: (pc0, 0, Input), - PC1: (pc1, 1, Input), - PC2: (pc2, 2, Input), - PC3: (pc3, 3, Input), - PC4: (pc4, 4, Input), - PC5: (pc5, 5, Input), - PC6: (pc6, 6, Input), - PC7: (pc7, 7, Input), - PC8: (pc8, 8, Input), - PC9: (pc9, 9, Input), - PC10: (pc10, 10, Input), - PC11: (pc11, 11, Input), - PC12: (pc12, 12, Input), - PC13: (pc13, 13, Input), - PC14: (pc14, 14, Input), - PC15: (pc15, 15, Input), - ], - GPIOD, gpiod, iopden, PD, any( - feature = "stm32f030", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070" - ) => [ - PD2: (pd2, 2, Input), - ], - GPIOD, gpiod, iopden, PD, any( - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098" - ) => [ - PD0: (pd0, 0, Input), - PD1: (pd1, 1, Input), - PD2: (pd2, 2, Input), - PD3: (pd3, 3, Input), - PD4: (pd4, 4, Input), - PD5: (pd5, 5, Input), - PD6: (pd6, 6, Input), - PD7: (pd7, 7, Input), - PD8: (pd8, 8, Input), - PD9: (pd9, 9, Input), - PD10: (pd10, 10, Input), - PD11: (pd11, 11, Input), - PD12: (pd12, 12, Input), - PD13: (pd13, 13, Input), - PD14: (pd14, 14, Input), - PD15: (pd15, 15, Input), - ], - GPIOE, gpioe, iopeen, PE, any( - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098" - ) => [ - PE0: (pe0, 0, Input), - PE1: (pe1, 1, Input), - PE2: (pe2, 2, Input), - PE3: (pe3, 3, Input), - PE4: (pe4, 4, Input), - PE5: (pe5, 5, Input), - PE6: (pe6, 6, Input), - PE7: (pe7, 7, Input), - PE8: (pe8, 8, Input), - PE9: (pe9, 9, Input), - PE10: (pe10, 10, Input), - PE11: (pe11, 11, Input), - PE12: (pe12, 12, Input), - PE13: (pe13, 13, Input), - PE14: (pe14, 14, Input), - PE15: (pe15, 15, Input), - ], - GPIOF, gpiof, iopfen, PF, any( - feature = "stm32f030x4", - feature = "stm32f030x6", - feature = "stm32f030x8", - feature = "stm32f051", - feature = "stm32f058", - ) => [ - PF0: (pf0, 0, Input), - PF1: (pf1, 1, Input), - PF4: (pf4, 4, Input), - PF5: (pf5, 5, Input), - PF6: (pf6, 6, Input), - PF7: (pf7, 7, Input), - ], - GPIOF, gpiof, iopfen, PF, any( - feature = "stm32f030xc", - feature = "stm32f070" - ) => [ - PF0: (pf0, 0, Input), - PF1: (pf1, 1, Input), - ], - GPIOF, gpiof, iopfen, PF, any( - feature = "stm32f031", - feature = "stm32f038" - ) => [ - PF0: (pf0, 0, Input), - PF1: (pf1, 1, Input), - PF6: (pf6, 6, Input), - PF7: (pf7, 7, Input), - ], - GPIOF, gpiof, iopfen, PF, any( - feature = "stm32f042", - feature = "stm32f048" - ) => [ - PF0: (pf0, 0, Input), - PF1: (pf1, 1, Input), - PF11: (pf11, 11, Input), - ], - GPIOF, gpiof, iopfen, PF, any( - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", - ) => [ - PF0: (pf0, 0, Input), - PF1: (pf1, 1, Input), - PF2: (pf2, 2, Input), - PF3: (pf3, 3, Input), - PF6: (pf6, 6, Input), - PF9: (pf9, 9, Input), - PF10: (pf10, 10, Input), - ] - ]); diff --git a/docs/gpio_stm32f0xx.rs b/docs/gpio_stm32f0xx.rs deleted file mode 100644 index ae81842..0000000 --- a/docs/gpio_stm32f0xx.rs +++ /dev/null @@ -1,12410 +0,0 @@ -#[cfg(feature = "device-selected")] -pub mod gpio { - //! General Purpose Input / Output - use core::convert::Infallible; - use core::marker::PhantomData; - use crate::rcc::Rcc; - /// Extension trait to split a GPIO peripheral in independent pins and registers - pub trait GpioExt { - /// The parts to split the GPIO into - type Parts; - /// Splits the GPIO block into independent pins and registers - fn split(self, rcc: &mut Rcc) -> Self::Parts; - } - trait GpioRegExt { - fn is_low(&self, pos: u8) -> bool; - fn is_set_low(&self, pos: u8) -> bool; - fn set_high(&self, pos: u8); - fn set_low(&self, pos: u8); - } - /// Alternate function 0 - pub struct AF0; - /// Alternate function 1 - pub struct AF1; - /// Alternate function 2 - pub struct AF2; - /// Alternate function 3 - pub struct AF3; - /// Alternate function 4 - pub struct AF4; - /// Alternate function 5 - pub struct AF5; - /// Alternate function 6 - pub struct AF6; - /// Alternate function 7 - pub struct AF7; - /// Alternate function mode (type state) - pub struct Alternate { - _mode: PhantomData, - } - /// Input mode (type state) - pub struct Input { - _mode: PhantomData, - } - /// Floating input (type state) - pub struct Floating; - /// Pulled down input (type state) - pub struct PullDown; - /// Pulled up input (type state) - pub struct PullUp; - /// Open drain input or output (type state) - pub struct OpenDrain; - /// Analog mode (type state) - pub struct Analog; - /// Output mode (type state) - pub struct Output { - _mode: PhantomData, - } - /// Push pull output (type state) - pub struct PushPull; - use embedded_hal::digital::v2::{toggleable, InputPin, OutputPin, StatefulOutputPin}; - /// Fully erased pin - pub struct Pin { - i: u8, - port: *const dyn GpioRegExt, - _mode: PhantomData, - } - unsafe impl Sync for Pin {} - unsafe impl Send for Pin {} - impl StatefulOutputPin for Pin> { - #[inline(always)] - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - #[inline(always)] - fn is_set_low(&self) -> Result { - Ok(unsafe { (*self.port).is_set_low(self.i) }) - } - } - impl OutputPin for Pin> { - type Error = Infallible; - #[inline(always)] - fn set_high(&mut self) -> Result<(), Self::Error> { - unsafe { (*self.port).set_high(self.i) }; - Ok(()) - } - #[inline(always)] - fn set_low(&mut self) -> Result<(), Self::Error> { - unsafe { (*self.port).set_low(self.i) } - Ok(()) - } - } - impl toggleable::Default for Pin> {} - impl InputPin for Pin> { - type Error = Infallible; - #[inline(always)] - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - #[inline(always)] - fn is_low(&self) -> Result { - Ok(unsafe { (*self.port).is_low(self.i) }) - } - } - impl InputPin for Pin> { - type Error = Infallible; - #[inline(always)] - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - #[inline(always)] - fn is_low(&self) -> Result { - Ok(unsafe { (*self.port).is_low(self.i) }) - } - } - impl GpioRegExt for crate::pac::gpioa::RegisterBlock { - fn is_low(&self, pos: u8) -> bool { - self.idr.read().bits() & (1 << pos) == 0 - } - fn is_set_low(&self, pos: u8) -> bool { - self.odr.read().bits() & (1 << pos) == 0 - } - fn set_high(&self, pos: u8) { - unsafe { self.bsrr.write(|w| w.bits(1 << pos)) } - } - fn set_low(&self, pos: u8) { - unsafe { self.bsrr.write(|w| w.bits(1 << (pos + 16))) } - } - } - impl GpioRegExt for crate::pac::gpiof::RegisterBlock { - fn is_low(&self, pos: u8) -> bool { - self.idr.read().bits() & (1 << pos) == 0 - } - fn is_set_low(&self, pos: u8) -> bool { - self.odr.read().bits() & (1 << pos) == 0 - } - fn set_high(&self, pos: u8) { - unsafe { self.bsrr.write(|w| w.bits(1 << pos)) } - } - fn set_low(&self, pos: u8) { - unsafe { self.bsrr.write(|w| w.bits(1 << (pos + 16))) } - } - } - /// GPIO - #[cfg(any(feature = "device-selected"))] - pub mod gpioa { - use core::marker::PhantomData; - use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{rcc::Rcc, pac::GPIOA}; - use cortex_m::interrupt::CriticalSection; - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, PullDown, PullUp, - PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, Pin, GpioRegExt, - }; - /// GPIO parts - pub struct Parts { - /// Pin - pub pa0: PA0>, - /// Pin - pub pa1: PA1>, - /// Pin - pub pa2: PA2>, - /// Pin - pub pa3: PA3>, - /// Pin - pub pa4: PA4>, - /// Pin - pub pa5: PA5>, - /// Pin - pub pa6: PA6>, - /// Pin - pub pa7: PA7>, - /// Pin - pub pa8: PA8>, - /// Pin - pub pa9: PA9>, - /// Pin - pub pa10: PA10>, - /// Pin - pub pa11: PA11>, - /// Pin - pub pa12: PA12>, - /// Pin - pub pa13: PA13>, - /// Pin - pub pa14: PA14>, - /// Pin - pub pa15: PA15>, - } - impl GpioExt for GPIOA { - type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.iopaen().set_bit()); - Parts { - pa0: PA0 { _mode: PhantomData }, - pa1: PA1 { _mode: PhantomData }, - pa2: PA2 { _mode: PhantomData }, - pa3: PA3 { _mode: PhantomData }, - pa4: PA4 { _mode: PhantomData }, - pa5: PA5 { _mode: PhantomData }, - pa6: PA6 { _mode: PhantomData }, - pa7: PA7 { _mode: PhantomData }, - pa8: PA8 { _mode: PhantomData }, - pa9: PA9 { _mode: PhantomData }, - pa10: PA10 { _mode: PhantomData }, - pa11: PA11 { _mode: PhantomData }, - pa12: PA12 { _mode: PhantomData }, - pa13: PA13 { _mode: PhantomData }, - pa14: PA14 { _mode: PhantomData }, - pa15: PA15 { _mode: PhantomData }, - } - } - } - fn _set_alternate_mode(index: usize, mode: u32) { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*GPIOA::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - } - } - /// Pin - pub struct PA0 { - _mode: PhantomData, - } - impl PA0 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 0); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 1); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 2); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 3); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 4); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 5); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 6); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 7); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA0 { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA0 { _mode: PhantomData } - } - } - impl PA0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA0> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA0> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(0) }) - } - } - impl OutputPin for PA0> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(0) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(0) }) - } - } - impl toggleable::Default for PA0> {} - impl InputPin for PA0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(0) }) - } - } - impl PA0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(0) }) - } - } - /// Pin - pub struct PA1 { - _mode: PhantomData, - } - impl PA1 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 0); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 1); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 2); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 3); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 4); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 5); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 6); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA1> { - _set_alternate_mode(1, 7); - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA1 { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA1 { _mode: PhantomData } - } - } - impl PA1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA1> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 1; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA1> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(1) }) - } - } - impl OutputPin for PA1> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(1) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(1) }) - } - } - impl toggleable::Default for PA1> {} - impl InputPin for PA1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(1) }) - } - } - impl PA1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(1) }) - } - } - /// Pin - pub struct PA2 { - _mode: PhantomData, - } - impl PA2 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 0); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 1); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 2); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 3); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 4); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 5); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 6); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA2> { - _set_alternate_mode(2, 7); - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA2 { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA2 { _mode: PhantomData } - } - } - impl PA2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA2> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 2; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA2> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(2) }) - } - } - impl OutputPin for PA2> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(2) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(2) }) - } - } - impl toggleable::Default for PA2> {} - impl InputPin for PA2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(2) }) - } - } - impl PA2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(2) }) - } - } - /// Pin - pub struct PA3 { - _mode: PhantomData, - } - impl PA3 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 0); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 1); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 2); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 3); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 4); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 5); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 6); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA3> { - _set_alternate_mode(3, 7); - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA3 { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA3 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA3 { _mode: PhantomData } - } - } - impl PA3> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 3; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA3> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 3; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA3> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 3; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA3> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 3, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA3> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(3) }) - } - } - impl OutputPin for PA3> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(3) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(3) }) - } - } - impl toggleable::Default for PA3> {} - impl InputPin for PA3> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(3) }) - } - } - impl PA3> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 3, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA3> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(3) }) - } - } - /// Pin - pub struct PA4 { - _mode: PhantomData, - } - impl PA4 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 0); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 1); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 2); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 3); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 4); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 5); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 6); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA4> { - _set_alternate_mode(4, 7); - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA4 { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA4 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA4 { _mode: PhantomData } - } - } - impl PA4> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 4; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA4> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 4; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA4> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 4; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA4> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 4, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA4> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(4) }) - } - } - impl OutputPin for PA4> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(4) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(4) }) - } - } - impl toggleable::Default for PA4> {} - impl InputPin for PA4> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(4) }) - } - } - impl PA4> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 4, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA4> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(4) }) - } - } - /// Pin - pub struct PA5 { - _mode: PhantomData, - } - impl PA5 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 0); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 1); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 2); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 3); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 4); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 5); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 6); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA5> { - _set_alternate_mode(5, 7); - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA5 { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA5 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA5 { _mode: PhantomData } - } - } - impl PA5> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 5; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA5> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 5; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA5> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 5; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA5> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 5, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA5> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(5) }) - } - } - impl OutputPin for PA5> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(5) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(5) }) - } - } - impl toggleable::Default for PA5> {} - impl InputPin for PA5> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(5) }) - } - } - impl PA5> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 5, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA5> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(5) }) - } - } - /// Pin - pub struct PA6 { - _mode: PhantomData, - } - impl PA6 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 0); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 1); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 2); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 3); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 4); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 5); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 6); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA6> { - _set_alternate_mode(6, 7); - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA6 { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA6 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA6 { _mode: PhantomData } - } - } - impl PA6> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 6; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA6> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 6; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA6> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 6; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA6> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 6, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA6> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(6) }) - } - } - impl OutputPin for PA6> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(6) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(6) }) - } - } - impl toggleable::Default for PA6> {} - impl InputPin for PA6> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(6) }) - } - } - impl PA6> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 6, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA6> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(6) }) - } - } - /// Pin - pub struct PA7 { - _mode: PhantomData, - } - impl PA7 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 0); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 1); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 2); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 3); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 4); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 5); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 6); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA7> { - _set_alternate_mode(7, 7); - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA7 { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA7 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA7 { _mode: PhantomData } - } - } - impl PA7> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 7; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA7> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 7; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA7> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 7; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA7> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 7, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA7> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(7) }) - } - } - impl OutputPin for PA7> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(7) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(7) }) - } - } - impl toggleable::Default for PA7> {} - impl InputPin for PA7> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(7) }) - } - } - impl PA7> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 7, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA7> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(7) }) - } - } - /// Pin - pub struct PA8 { - _mode: PhantomData, - } - impl PA8 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 0); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 1); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 2); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 3); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 4); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 5); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 6); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA8> { - _set_alternate_mode(8, 7); - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA8 { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA8 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA8 { _mode: PhantomData } - } - } - impl PA8> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 8; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA8> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 8; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA8> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 8; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA8> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 8, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA8> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(8) }) - } - } - impl OutputPin for PA8> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(8) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(8) }) - } - } - impl toggleable::Default for PA8> {} - impl InputPin for PA8> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(8) }) - } - } - impl PA8> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 8, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA8> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(8) }) - } - } - /// Pin - pub struct PA9 { - _mode: PhantomData, - } - impl PA9 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 0); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 1); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 2); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 3); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 4); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 5); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 6); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA9> { - _set_alternate_mode(9, 7); - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA9 { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA9 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA9 { _mode: PhantomData } - } - } - impl PA9> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 9; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA9> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 9; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA9> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 9; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA9> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 9, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA9> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(9) }) - } - } - impl OutputPin for PA9> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(9) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(9) }) - } - } - impl toggleable::Default for PA9> {} - impl InputPin for PA9> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(9) }) - } - } - impl PA9> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 9, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA9> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(9) }) - } - } - /// Pin - pub struct PA10 { - _mode: PhantomData, - } - impl PA10 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 0); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 1); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 2); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 3); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 4); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 5); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 6); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA10> { - _set_alternate_mode(10, 7); - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA10 { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA10 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA10 { _mode: PhantomData } - } - } - impl PA10> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 10; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA10> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 10; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA10> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 10; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA10> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 10, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA10> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(10) }) - } - } - impl OutputPin for PA10> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(10) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(10) }) - } - } - impl toggleable::Default for PA10> {} - impl InputPin for PA10> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(10) }) - } - } - impl PA10> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 10, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA10> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(10) }) - } - } - /// Pin - pub struct PA11 { - _mode: PhantomData, - } - impl PA11 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 0); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 1); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 2); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 3); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 4); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 5); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 6); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA11> { - _set_alternate_mode(11, 7); - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA11 { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA11 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA11 { _mode: PhantomData } - } - } - impl PA11> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 11; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA11> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 11; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA11> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 11; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA11> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 11, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA11> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(11) }) - } - } - impl OutputPin for PA11> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(11) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(11) }) - } - } - impl toggleable::Default for PA11> {} - impl InputPin for PA11> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(11) }) - } - } - impl PA11> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 11, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA11> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(11) }) - } - } - /// Pin - pub struct PA12 { - _mode: PhantomData, - } - impl PA12 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 0); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 1); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 2); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 3); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 4); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 5); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 6); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA12> { - _set_alternate_mode(12, 7); - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA12 { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA12 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA12 { _mode: PhantomData } - } - } - impl PA12> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 12; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA12> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 12; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA12> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 12; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA12> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 12, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA12> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(12) }) - } - } - impl OutputPin for PA12> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(12) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(12) }) - } - } - impl toggleable::Default for PA12> {} - impl InputPin for PA12> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(12) }) - } - } - impl PA12> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 12, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA12> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(12) }) - } - } - /// Pin - pub struct PA13 { - _mode: PhantomData, - } - impl PA13 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 0); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 1); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 2); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 3); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 4); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 5); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 6); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA13> { - _set_alternate_mode(13, 7); - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA13 { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA13 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA13 { _mode: PhantomData } - } - } - impl PA13> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 13; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA13> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 13; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA13> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 13; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA13> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 13, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA13> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(13) }) - } - } - impl OutputPin for PA13> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(13) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(13) }) - } - } - impl toggleable::Default for PA13> {} - impl InputPin for PA13> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(13) }) - } - } - impl PA13> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 13, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA13> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(13) }) - } - } - /// Pin - pub struct PA14 { - _mode: PhantomData, - } - impl PA14 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 0); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 1); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 2); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 3); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 4); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 5); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 6); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA14> { - _set_alternate_mode(14, 7); - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA14 { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA14 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA14 { _mode: PhantomData } - } - } - impl PA14> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 14; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA14> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 14; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA14> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 14; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA14> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 14, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA14> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(14) }) - } - } - impl OutputPin for PA14> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(14) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(14) }) - } - } - impl toggleable::Default for PA14> {} - impl InputPin for PA14> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(14) }) - } - } - impl PA14> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 14, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA14> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(14) }) - } - } - /// Pin - pub struct PA15 { - _mode: PhantomData, - } - impl PA15 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 0); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 1); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 2); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 3); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 4); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 5); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 6); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA15> { - _set_alternate_mode(15, 7); - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA15 { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA15 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA15 { _mode: PhantomData } - } - } - impl PA15> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 15; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA15> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 15; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA15> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 15; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA15> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 15, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA15> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(15) }) - } - } - impl OutputPin for PA15> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(15) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(15) }) - } - } - impl toggleable::Default for PA15> {} - impl InputPin for PA15> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(15) }) - } - } - impl PA15> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 15, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA15> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(15) }) - } - } - } - /// GPIO - #[cfg(any(feature = "device-selected"))] - pub mod gpiob { - use core::marker::PhantomData; - use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{rcc::Rcc, pac::GPIOB}; - use cortex_m::interrupt::CriticalSection; - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, PullDown, PullUp, - PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, Pin, GpioRegExt, - }; - /// GPIO parts - pub struct Parts { - /// Pin - pub pb0: PB0>, - /// Pin - pub pb1: PB1>, - /// Pin - pub pb2: PB2>, - /// Pin - pub pb3: PB3>, - /// Pin - pub pb4: PB4>, - /// Pin - pub pb5: PB5>, - /// Pin - pub pb6: PB6>, - /// Pin - pub pb7: PB7>, - /// Pin - pub pb8: PB8>, - /// Pin - pub pb9: PB9>, - /// Pin - pub pb10: PB10>, - /// Pin - pub pb11: PB11>, - /// Pin - pub pb12: PB12>, - /// Pin - pub pb13: PB13>, - /// Pin - pub pb14: PB14>, - /// Pin - pub pb15: PB15>, - } - impl GpioExt for GPIOB { - type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.iopben().set_bit()); - Parts { - pb0: PB0 { _mode: PhantomData }, - pb1: PB1 { _mode: PhantomData }, - pb2: PB2 { _mode: PhantomData }, - pb3: PB3 { _mode: PhantomData }, - pb4: PB4 { _mode: PhantomData }, - pb5: PB5 { _mode: PhantomData }, - pb6: PB6 { _mode: PhantomData }, - pb7: PB7 { _mode: PhantomData }, - pb8: PB8 { _mode: PhantomData }, - pb9: PB9 { _mode: PhantomData }, - pb10: PB10 { _mode: PhantomData }, - pb11: PB11 { _mode: PhantomData }, - pb12: PB12 { _mode: PhantomData }, - pb13: PB13 { _mode: PhantomData }, - pb14: PB14 { _mode: PhantomData }, - pb15: PB15 { _mode: PhantomData }, - } - } - } - fn _set_alternate_mode(index: usize, mode: u32) { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*GPIOB::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - } - } - /// Pin - pub struct PB0 { - _mode: PhantomData, - } - impl PB0 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 0); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 1); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 2); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 3); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 4); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 5); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 6); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB0> { - _set_alternate_mode(0, 7); - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB0 { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB0 { _mode: PhantomData } - } - } - impl PB0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB0> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 0; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB0> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(0) }) - } - } - impl OutputPin for PB0> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(0) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(0) }) - } - } - impl toggleable::Default for PB0> {} - impl InputPin for PB0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(0) }) - } - } - impl PB0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(0) }) - } - } - /// Pin - pub struct PB1 { - _mode: PhantomData, - } - impl PB1 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 0); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 1); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 2); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 3); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 4); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 5); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 6); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB1> { - _set_alternate_mode(1, 7); - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB1 { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB1 { _mode: PhantomData } - } - } - impl PB1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB1> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 1; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB1> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(1) }) - } - } - impl OutputPin for PB1> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(1) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(1) }) - } - } - impl toggleable::Default for PB1> {} - impl InputPin for PB1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(1) }) - } - } - impl PB1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(1) }) - } - } - /// Pin - pub struct PB2 { - _mode: PhantomData, - } - impl PB2 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 0); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 1); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 2); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 3); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 4); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 5); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 6); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB2> { - _set_alternate_mode(2, 7); - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB2 { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB2 { _mode: PhantomData } - } - } - impl PB2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB2> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 2; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB2> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(2) }) - } - } - impl OutputPin for PB2> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(2) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(2) }) - } - } - impl toggleable::Default for PB2> {} - impl InputPin for PB2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(2) }) - } - } - impl PB2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(2) }) - } - } - /// Pin - pub struct PB3 { - _mode: PhantomData, - } - impl PB3 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 0); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 1); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 2); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 3); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 4); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 5); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 6); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB3> { - _set_alternate_mode(3, 7); - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB3 { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB3 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB3 { _mode: PhantomData } - } - } - impl PB3> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 3; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB3> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 3; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB3> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 3; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB3> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 3, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB3> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(3) }) - } - } - impl OutputPin for PB3> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(3) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(3) }) - } - } - impl toggleable::Default for PB3> {} - impl InputPin for PB3> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(3) }) - } - } - impl PB3> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 3, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB3> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(3) }) - } - } - /// Pin - pub struct PB4 { - _mode: PhantomData, - } - impl PB4 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 0); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 1); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 2); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 3); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 4); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 5); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 6); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB4> { - _set_alternate_mode(4, 7); - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB4 { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB4 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB4 { _mode: PhantomData } - } - } - impl PB4> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 4; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB4> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 4; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB4> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 4; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB4> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 4, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB4> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(4) }) - } - } - impl OutputPin for PB4> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(4) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(4) }) - } - } - impl toggleable::Default for PB4> {} - impl InputPin for PB4> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(4) }) - } - } - impl PB4> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 4, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB4> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(4) }) - } - } - /// Pin - pub struct PB5 { - _mode: PhantomData, - } - impl PB5 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 0); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 1); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 2); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 3); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 4); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 5); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 6); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB5> { - _set_alternate_mode(5, 7); - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB5 { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB5 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB5 { _mode: PhantomData } - } - } - impl PB5> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 5; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB5> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 5; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB5> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 5; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB5> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 5, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB5> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(5) }) - } - } - impl OutputPin for PB5> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(5) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(5) }) - } - } - impl toggleable::Default for PB5> {} - impl InputPin for PB5> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(5) }) - } - } - impl PB5> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 5, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB5> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(5) }) - } - } - /// Pin - pub struct PB6 { - _mode: PhantomData, - } - impl PB6 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 0); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 1); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 2); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 3); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 4); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 5); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 6); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB6> { - _set_alternate_mode(6, 7); - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB6 { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB6 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB6 { _mode: PhantomData } - } - } - impl PB6> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 6; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB6> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 6; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB6> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 6; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB6> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 6, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB6> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(6) }) - } - } - impl OutputPin for PB6> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(6) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(6) }) - } - } - impl toggleable::Default for PB6> {} - impl InputPin for PB6> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(6) }) - } - } - impl PB6> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 6, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB6> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(6) }) - } - } - /// Pin - pub struct PB7 { - _mode: PhantomData, - } - impl PB7 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 0); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 1); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 2); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 3); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 4); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 5); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 6); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB7> { - _set_alternate_mode(7, 7); - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB7 { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB7 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB7 { _mode: PhantomData } - } - } - impl PB7> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 7; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB7> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 7; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB7> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 7; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB7> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 7, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB7> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(7) }) - } - } - impl OutputPin for PB7> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(7) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(7) }) - } - } - impl toggleable::Default for PB7> {} - impl InputPin for PB7> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(7) }) - } - } - impl PB7> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 7, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB7> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(7) }) - } - } - /// Pin - pub struct PB8 { - _mode: PhantomData, - } - impl PB8 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 0); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 1); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 2); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 3); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 4); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 5); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 6); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB8> { - _set_alternate_mode(8, 7); - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB8 { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB8 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB8 { _mode: PhantomData } - } - } - impl PB8> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 8; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB8> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 8; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB8> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 8; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB8> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 8, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB8> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(8) }) - } - } - impl OutputPin for PB8> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(8) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(8) }) - } - } - impl toggleable::Default for PB8> {} - impl InputPin for PB8> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(8) }) - } - } - impl PB8> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 8, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB8> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(8) }) - } - } - /// Pin - pub struct PB9 { - _mode: PhantomData, - } - impl PB9 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 0); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 1); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 2); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 3); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 4); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 5); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 6); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB9> { - _set_alternate_mode(9, 7); - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB9 { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB9 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB9 { _mode: PhantomData } - } - } - impl PB9> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 9; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB9> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 9; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB9> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 9; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB9> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 9, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB9> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(9) }) - } - } - impl OutputPin for PB9> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(9) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(9) }) - } - } - impl toggleable::Default for PB9> {} - impl InputPin for PB9> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(9) }) - } - } - impl PB9> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 9, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB9> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(9) }) - } - } - /// Pin - pub struct PB10 { - _mode: PhantomData, - } - impl PB10 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 0); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 1); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 2); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 3); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 4); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 5); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 6); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB10> { - _set_alternate_mode(10, 7); - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB10 { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB10 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB10 { _mode: PhantomData } - } - } - impl PB10> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 10; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB10> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 10; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB10> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 10; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB10> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 10, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB10> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(10) }) - } - } - impl OutputPin for PB10> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(10) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(10) }) - } - } - impl toggleable::Default for PB10> {} - impl InputPin for PB10> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(10) }) - } - } - impl PB10> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 10, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB10> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(10) }) - } - } - /// Pin - pub struct PB11 { - _mode: PhantomData, - } - impl PB11 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 0); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 1); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 2); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 3); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 4); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 5); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 6); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB11> { - _set_alternate_mode(11, 7); - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB11 { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB11 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB11 { _mode: PhantomData } - } - } - impl PB11> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 11; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB11> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 11; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB11> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 11; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB11> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 11, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB11> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(11) }) - } - } - impl OutputPin for PB11> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(11) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(11) }) - } - } - impl toggleable::Default for PB11> {} - impl InputPin for PB11> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(11) }) - } - } - impl PB11> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 11, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB11> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(11) }) - } - } - /// Pin - pub struct PB12 { - _mode: PhantomData, - } - impl PB12 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 0); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 1); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 2); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 3); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 4); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 5); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 6); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB12> { - _set_alternate_mode(12, 7); - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB12 { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB12 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB12 { _mode: PhantomData } - } - } - impl PB12> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 12; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB12> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 12; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB12> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 12; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB12> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 12, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB12> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(12) }) - } - } - impl OutputPin for PB12> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(12) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(12) }) - } - } - impl toggleable::Default for PB12> {} - impl InputPin for PB12> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(12) }) - } - } - impl PB12> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 12, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB12> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(12) }) - } - } - /// Pin - pub struct PB13 { - _mode: PhantomData, - } - impl PB13 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 0); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 1); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 2); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 3); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 4); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 5); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 6); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB13> { - _set_alternate_mode(13, 7); - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB13 { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB13 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB13 { _mode: PhantomData } - } - } - impl PB13> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 13; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB13> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 13; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB13> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 13; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB13> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 13, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB13> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(13) }) - } - } - impl OutputPin for PB13> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(13) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(13) }) - } - } - impl toggleable::Default for PB13> {} - impl InputPin for PB13> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(13) }) - } - } - impl PB13> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 13, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB13> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(13) }) - } - } - /// Pin - pub struct PB14 { - _mode: PhantomData, - } - impl PB14 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 0); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 1); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 2); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 3); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 4); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 5); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 6); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB14> { - _set_alternate_mode(14, 7); - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB14 { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB14 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB14 { _mode: PhantomData } - } - } - impl PB14> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 14; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB14> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 14; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB14> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 14; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB14> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 14, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB14> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(14) }) - } - } - impl OutputPin for PB14> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(14) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(14) }) - } - } - impl toggleable::Default for PB14> {} - impl InputPin for PB14> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(14) }) - } - } - impl PB14> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 14, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB14> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(14) }) - } - } - /// Pin - pub struct PB15 { - _mode: PhantomData, - } - impl PB15 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 0); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 1); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 2); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 3); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 4); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 5); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 6); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PB15> { - _set_alternate_mode(15, 7); - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PB15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PB15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PB15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PB15 { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PB15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PB15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB15 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PB15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PB15 { _mode: PhantomData } - } - } - impl PB15> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 15; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PB15> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 15; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PB15> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 15; - unsafe { - let reg = &(*GPIOB::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PB15> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 15, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PB15> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_set_low(15) }) - } - } - impl OutputPin for PB15> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_high(15) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOB::ptr()).set_low(15) }) - } - } - impl toggleable::Default for PB15> {} - impl InputPin for PB15> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(15) }) - } - } - impl PB15> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 15, - port: GPIOB::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PB15> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOB::ptr()).is_low(15) }) - } - } - } - /// GPIO - #[cfg(any( - feature = "stm32f030", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098" - ))] - pub mod gpioc { - use core::marker::PhantomData; - use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{rcc::Rcc, pac::GPIOC}; - use cortex_m::interrupt::CriticalSection; - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, PullDown, PullUp, - PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, Pin, GpioRegExt, - }; - /// GPIO parts - pub struct Parts { - /// Pin - pub pc0: PC0>, - /// Pin - pub pc1: PC1>, - /// Pin - pub pc2: PC2>, - /// Pin - pub pc3: PC3>, - /// Pin - pub pc4: PC4>, - /// Pin - pub pc5: PC5>, - /// Pin - pub pc6: PC6>, - /// Pin - pub pc7: PC7>, - /// Pin - pub pc8: PC8>, - /// Pin - pub pc9: PC9>, - /// Pin - pub pc10: PC10>, - /// Pin - pub pc11: PC11>, - /// Pin - pub pc12: PC12>, - /// Pin - pub pc13: PC13>, - /// Pin - pub pc14: PC14>, - /// Pin - pub pc15: PC15>, - } - impl GpioExt for GPIOC { - type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.iopcen().set_bit()); - Parts { - pc0: PC0 { _mode: PhantomData }, - pc1: PC1 { _mode: PhantomData }, - pc2: PC2 { _mode: PhantomData }, - pc3: PC3 { _mode: PhantomData }, - pc4: PC4 { _mode: PhantomData }, - pc5: PC5 { _mode: PhantomData }, - pc6: PC6 { _mode: PhantomData }, - pc7: PC7 { _mode: PhantomData }, - pc8: PC8 { _mode: PhantomData }, - pc9: PC9 { _mode: PhantomData }, - pc10: PC10 { _mode: PhantomData }, - pc11: PC11 { _mode: PhantomData }, - pc12: PC12 { _mode: PhantomData }, - pc13: PC13 { _mode: PhantomData }, - pc14: PC14 { _mode: PhantomData }, - pc15: PC15 { _mode: PhantomData }, - } - } - } - fn _set_alternate_mode(index: usize, mode: u32) { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*GPIOC::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - } - } - /// Pin - pub struct PC0 { - _mode: PhantomData, - } - impl PC0 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 0); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 1); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 2); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 3); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 4); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 5); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 6); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC0> { - _set_alternate_mode(0, 7); - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC0 { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC0 { _mode: PhantomData } - } - } - impl PC0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC0> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 0; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC0> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(0) }) - } - } - impl OutputPin for PC0> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(0) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(0) }) - } - } - impl toggleable::Default for PC0> {} - impl InputPin for PC0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(0) }) - } - } - impl PC0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(0) }) - } - } - /// Pin - pub struct PC1 { - _mode: PhantomData, - } - impl PC1 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 0); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 1); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 2); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 3); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 4); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 5); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 6); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC1> { - _set_alternate_mode(1, 7); - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC1 { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC1 { _mode: PhantomData } - } - } - impl PC1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC1> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 1; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC1> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(1) }) - } - } - impl OutputPin for PC1> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(1) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(1) }) - } - } - impl toggleable::Default for PC1> {} - impl InputPin for PC1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(1) }) - } - } - impl PC1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(1) }) - } - } - /// Pin - pub struct PC2 { - _mode: PhantomData, - } - impl PC2 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 0); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 1); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 2); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 3); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 4); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 5); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 6); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC2> { - _set_alternate_mode(2, 7); - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC2 { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC2 { _mode: PhantomData } - } - } - impl PC2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC2> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 2; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC2> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(2) }) - } - } - impl OutputPin for PC2> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(2) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(2) }) - } - } - impl toggleable::Default for PC2> {} - impl InputPin for PC2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(2) }) - } - } - impl PC2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(2) }) - } - } - /// Pin - pub struct PC3 { - _mode: PhantomData, - } - impl PC3 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 0); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 1); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 2); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 3); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 4); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 5); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 6); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC3> { - _set_alternate_mode(3, 7); - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC3 { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC3 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC3> { - let offset = 2 * 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 3))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC3 { _mode: PhantomData } - } - } - impl PC3> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 3; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC3> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 3; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC3> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 3; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC3> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 3, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC3> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(3) }) - } - } - impl OutputPin for PC3> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(3) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(3) }) - } - } - impl toggleable::Default for PC3> {} - impl InputPin for PC3> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(3) }) - } - } - impl PC3> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 3, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC3> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(3) }) - } - } - /// Pin - pub struct PC4 { - _mode: PhantomData, - } - impl PC4 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 0); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 1); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 2); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 3); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 4); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 5); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 6); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC4> { - _set_alternate_mode(4, 7); - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC4 { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC4 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC4> { - let offset = 2 * 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 4))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC4 { _mode: PhantomData } - } - } - impl PC4> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 4; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC4> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 4; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC4> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 4; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC4> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 4, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC4> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(4) }) - } - } - impl OutputPin for PC4> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(4) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(4) }) - } - } - impl toggleable::Default for PC4> {} - impl InputPin for PC4> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(4) }) - } - } - impl PC4> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 4, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC4> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(4) }) - } - } - /// Pin - pub struct PC5 { - _mode: PhantomData, - } - impl PC5 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 0); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 1); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 2); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 3); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 4); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 5); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 6); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC5> { - _set_alternate_mode(5, 7); - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC5 { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC5 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC5> { - let offset = 2 * 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 5))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC5 { _mode: PhantomData } - } - } - impl PC5> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 5; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC5> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 5; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC5> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 5; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC5> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 5, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC5> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(5) }) - } - } - impl OutputPin for PC5> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(5) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(5) }) - } - } - impl toggleable::Default for PC5> {} - impl InputPin for PC5> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(5) }) - } - } - impl PC5> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 5, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC5> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(5) }) - } - } - /// Pin - pub struct PC6 { - _mode: PhantomData, - } - impl PC6 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 0); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 1); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 2); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 3); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 4); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 5); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 6); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC6> { - _set_alternate_mode(6, 7); - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC6 { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC6 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC6> { - let offset = 2 * 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 6))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC6 { _mode: PhantomData } - } - } - impl PC6> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 6; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC6> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 6; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC6> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 6; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC6> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 6, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC6> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(6) }) - } - } - impl OutputPin for PC6> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(6) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(6) }) - } - } - impl toggleable::Default for PC6> {} - impl InputPin for PC6> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(6) }) - } - } - impl PC6> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 6, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC6> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(6) }) - } - } - /// Pin - pub struct PC7 { - _mode: PhantomData, - } - impl PC7 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 0); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 1); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 2); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 3); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 4); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 5); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 6); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC7> { - _set_alternate_mode(7, 7); - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC7 { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC7 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC7> { - let offset = 2 * 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 7))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC7 { _mode: PhantomData } - } - } - impl PC7> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 7; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC7> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 7; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC7> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 7; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC7> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 7, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC7> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(7) }) - } - } - impl OutputPin for PC7> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(7) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(7) }) - } - } - impl toggleable::Default for PC7> {} - impl InputPin for PC7> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(7) }) - } - } - impl PC7> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 7, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC7> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(7) }) - } - } - /// Pin - pub struct PC8 { - _mode: PhantomData, - } - impl PC8 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 0); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 1); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 2); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 3); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 4); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 5); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 6); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC8> { - _set_alternate_mode(8, 7); - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC8 { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC8 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC8> { - let offset = 2 * 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 8))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC8 { _mode: PhantomData } - } - } - impl PC8> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 8; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC8> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 8; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC8> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 8; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC8> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 8, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC8> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(8) }) - } - } - impl OutputPin for PC8> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(8) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(8) }) - } - } - impl toggleable::Default for PC8> {} - impl InputPin for PC8> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(8) }) - } - } - impl PC8> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 8, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC8> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(8) }) - } - } - /// Pin - pub struct PC9 { - _mode: PhantomData, - } - impl PC9 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 0); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 1); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 2); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 3); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 4); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 5); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 6); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC9> { - _set_alternate_mode(9, 7); - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC9 { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC9 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC9> { - let offset = 2 * 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 9))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC9 { _mode: PhantomData } - } - } - impl PC9> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 9; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC9> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 9; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC9> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 9; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC9> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 9, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC9> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(9) }) - } - } - impl OutputPin for PC9> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(9) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(9) }) - } - } - impl toggleable::Default for PC9> {} - impl InputPin for PC9> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(9) }) - } - } - impl PC9> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 9, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC9> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(9) }) - } - } - /// Pin - pub struct PC10 { - _mode: PhantomData, - } - impl PC10 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 0); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 1); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 2); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 3); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 4); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 5); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 6); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC10> { - _set_alternate_mode(10, 7); - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC10 { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC10 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC10> { - let offset = 2 * 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 10))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC10 { _mode: PhantomData } - } - } - impl PC10> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 10; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC10> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 10; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC10> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 10; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC10> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 10, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC10> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(10) }) - } - } - impl OutputPin for PC10> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(10) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(10) }) - } - } - impl toggleable::Default for PC10> {} - impl InputPin for PC10> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(10) }) - } - } - impl PC10> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 10, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC10> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(10) }) - } - } - /// Pin - pub struct PC11 { - _mode: PhantomData, - } - impl PC11 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 0); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 1); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 2); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 3); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 4); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 5); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 6); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC11> { - _set_alternate_mode(11, 7); - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC11 { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC11 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC11> { - let offset = 2 * 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 11))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC11 { _mode: PhantomData } - } - } - impl PC11> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 11; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC11> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 11; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC11> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 11; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC11> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 11, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC11> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(11) }) - } - } - impl OutputPin for PC11> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(11) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(11) }) - } - } - impl toggleable::Default for PC11> {} - impl InputPin for PC11> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(11) }) - } - } - impl PC11> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 11, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC11> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(11) }) - } - } - /// Pin - pub struct PC12 { - _mode: PhantomData, - } - impl PC12 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 0); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 1); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 2); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 3); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 4); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 5); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 6); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC12> { - _set_alternate_mode(12, 7); - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC12 { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC12 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC12> { - let offset = 2 * 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 12))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC12 { _mode: PhantomData } - } - } - impl PC12> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 12; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC12> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 12; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC12> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 12; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC12> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 12, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC12> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(12) }) - } - } - impl OutputPin for PC12> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(12) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(12) }) - } - } - impl toggleable::Default for PC12> {} - impl InputPin for PC12> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(12) }) - } - } - impl PC12> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 12, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC12> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(12) }) - } - } - /// Pin - pub struct PC13 { - _mode: PhantomData, - } - impl PC13 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 0); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 1); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 2); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 3); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 4); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 5); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 6); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC13> { - _set_alternate_mode(13, 7); - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC13 { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC13 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC13> { - let offset = 2 * 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 13))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC13 { _mode: PhantomData } - } - } - impl PC13> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 13; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC13> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 13; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC13> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 13; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC13> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 13, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC13> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(13) }) - } - } - impl OutputPin for PC13> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(13) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(13) }) - } - } - impl toggleable::Default for PC13> {} - impl InputPin for PC13> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(13) }) - } - } - impl PC13> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 13, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC13> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(13) }) - } - } - /// Pin - pub struct PC14 { - _mode: PhantomData, - } - impl PC14 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 0); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 1); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 2); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 3); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 4); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 5); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 6); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC14> { - _set_alternate_mode(14, 7); - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC14 { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC14 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC14> { - let offset = 2 * 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 14))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC14 { _mode: PhantomData } - } - } - impl PC14> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 14; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC14> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 14; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC14> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 14; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC14> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 14, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC14> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(14) }) - } - } - impl OutputPin for PC14> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(14) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(14) }) - } - } - impl toggleable::Default for PC14> {} - impl InputPin for PC14> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(14) }) - } - } - impl PC14> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 14, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC14> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(14) }) - } - } - /// Pin - pub struct PC15 { - _mode: PhantomData, - } - impl PC15 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 0); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 1); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 2); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 3); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 4); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 5); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 6); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PC15> { - _set_alternate_mode(15, 7); - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PC15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PC15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PC15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PC15 { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PC15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PC15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC15 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PC15> { - let offset = 2 * 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 15))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PC15 { _mode: PhantomData } - } - } - impl PC15> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 15; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PC15> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 15; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PC15> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 15; - unsafe { - let reg = &(*GPIOC::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PC15> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 15, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PC15> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_set_low(15) }) - } - } - impl OutputPin for PC15> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_high(15) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOC::ptr()).set_low(15) }) - } - } - impl toggleable::Default for PC15> {} - impl InputPin for PC15> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(15) }) - } - } - impl PC15> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 15, - port: GPIOC::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PC15> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOC::ptr()).is_low(15) }) - } - } - } - /// GPIO - #[cfg(any( - feature = "stm32f030", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070" - ))] - pub mod gpiod { - use core::marker::PhantomData; - use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{rcc::Rcc, pac::GPIOD}; - use cortex_m::interrupt::CriticalSection; - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, PullDown, PullUp, - PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, Pin, GpioRegExt, - }; - /// GPIO parts - pub struct Parts { - /// Pin - pub pd2: PD2>, - } - impl GpioExt for GPIOD { - type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.iopden().set_bit()); - Parts { - pd2: PD2 { _mode: PhantomData }, - } - } - } - fn _set_alternate_mode(index: usize, mode: u32) { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*GPIOD::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - } - } - /// Pin - pub struct PD2 { - _mode: PhantomData, - } - impl PD2 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 0); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 1); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 2); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 3); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 4); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 5); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 6); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PD2> { - _set_alternate_mode(2, 7); - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PD2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PD2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PD2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PD2 { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PD2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PD2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PD2 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PD2> { - let offset = 2 * 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 2))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PD2 { _mode: PhantomData } - } - } - - impl PD2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PD2> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 2; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PD2> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 2; - unsafe { - let reg = &(*GPIOD::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PD2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOD::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PD2> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOD::ptr()).is_set_low(2) }) - } - } - impl OutputPin for PD2> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOD::ptr()).set_high(2) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOD::ptr()).set_low(2) }) - } - } - impl toggleable::Default for PD2> {} - impl InputPin for PD2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOD::ptr()).is_low(2) }) - } - } - impl PD2> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 2, - port: GPIOD::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PD2> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOD::ptr()).is_low(2) }) - } - } - } - /// GPIO - #[cfg(any(feature = "stm32f030xc", feature = "stm32f070"))] - pub mod gpiof { - use core::marker::PhantomData; - use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{rcc::Rcc, pac::GPIOF}; - use cortex_m::interrupt::CriticalSection; - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, PullDown, PullUp, - PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, Pin, GpioRegExt, - }; - /// GPIO parts - pub struct Parts { - /// Pin - pub pf0: PF0>, - /// Pin - pub pf1: PF1>, - } - impl GpioExt for GPIOF { - type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.iopfen().set_bit()); - Parts { - pf0: PF0 { _mode: PhantomData }, - pf1: PF1 { _mode: PhantomData }, - } - } - } - fn _set_alternate_mode(index: usize, mode: u32) { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*GPIOF::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - } - } - /// Pin - pub struct PF0 { - _mode: PhantomData, - } - impl PF0 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 0); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 1); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 2); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 3); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 4); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 5); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 6); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PF0> { - _set_alternate_mode(0, 7); - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PF0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PF0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PF0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PF0 { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PF0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PF0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PF0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PF0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PF0 { _mode: PhantomData } - } - } - impl PF0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PF0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PF0> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 0; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PF0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOF::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PF0> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOF::ptr()).is_set_low(0) }) - } - } - impl OutputPin for PF0> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOF::ptr()).set_high(0) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOF::ptr()).set_low(0) }) - } - } - impl toggleable::Default for PF0> {} - impl InputPin for PF0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOF::ptr()).is_low(0) }) - } - } - impl PF0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOF::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PF0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOF::ptr()).is_low(0) }) - } - } - /// Pin - pub struct PF1 { - _mode: PhantomData, - } - impl PF1 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 0); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 1); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 2); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 3); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 4); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 5); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 6); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PF1> { - _set_alternate_mode(1, 7); - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PF1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PF1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PF1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PF1 { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PF1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PF1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PF1 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PF1> { - let offset = 2 * 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 1))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PF1 { _mode: PhantomData } - } - } - impl PF1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PF1> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 1; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PF1> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 1; - unsafe { - let reg = &(*GPIOF::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PF1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOF::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PF1> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOF::ptr()).is_set_low(1) }) - } - } - impl OutputPin for PF1> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOF::ptr()).set_high(1) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOF::ptr()).set_low(1) }) - } - } - impl toggleable::Default for PF1> {} - impl InputPin for PF1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOF::ptr()).is_low(1) }) - } - } - impl PF1> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 1, - port: GPIOF::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PF1> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOF::ptr()).is_low(1) }) - } - } - } -} \ No newline at end of file diff --git a/docs/gpioa0_stm32f0xx.rs b/docs/gpioa0_stm32f0xx.rs deleted file mode 100644 index 12226e4..0000000 --- a/docs/gpioa0_stm32f0xx.rs +++ /dev/null @@ -1,324 +0,0 @@ - /// GPIO - #[cfg(any(feature = "device-selected"))] - pub mod gpioa { - use core::marker::PhantomData; - use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin, toggleable}; - use crate::{rcc::Rcc, pac::GPIOA}; - use cortex_m::interrupt::CriticalSection; - use super::{ - Alternate, Analog, Floating, GpioExt, Input, OpenDrain, Output, PullDown, PullUp, - PushPull, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, Pin, GpioRegExt, - }; - /// GPIO parts - pub struct Parts { - /// Pin - pub pa0: PA0>, - /// Pin - pub pa1: PA1>, - /// Pin - pub pa2: PA2>, - /// Pin - pub pa3: PA3>, - /// Pin - pub pa4: PA4>, - /// Pin - pub pa5: PA5>, - /// Pin - pub pa6: PA6>, - /// Pin - pub pa7: PA7>, - /// Pin - pub pa8: PA8>, - /// Pin - pub pa9: PA9>, - /// Pin - pub pa10: PA10>, - /// Pin - pub pa11: PA11>, - /// Pin - pub pa12: PA12>, - /// Pin - pub pa13: PA13>, - /// Pin - pub pa14: PA14>, - /// Pin - pub pa15: PA15>, - } - impl GpioExt for GPIOA { - type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.regs.ahbenr.modify(|_, w| w.iopaen().set_bit()); - Parts { - pa0: PA0 { _mode: PhantomData }, - pa1: PA1 { _mode: PhantomData }, - pa2: PA2 { _mode: PhantomData }, - pa3: PA3 { _mode: PhantomData }, - pa4: PA4 { _mode: PhantomData }, - pa5: PA5 { _mode: PhantomData }, - pa6: PA6 { _mode: PhantomData }, - pa7: PA7 { _mode: PhantomData }, - pa8: PA8 { _mode: PhantomData }, - pa9: PA9 { _mode: PhantomData }, - pa10: PA10 { _mode: PhantomData }, - pa11: PA11 { _mode: PhantomData }, - pa12: PA12 { _mode: PhantomData }, - pa13: PA13 { _mode: PhantomData }, - pa14: PA14 { _mode: PhantomData }, - pa15: PA15 { _mode: PhantomData }, - } - } - } - fn _set_alternate_mode(index: usize, mode: u32) { - let offset = 2 * index; - let offset2 = 4 * index; - unsafe { - let reg = &(*GPIOA::ptr()); - if offset2 < 32 { - reg.afrl.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } else { - let offset2 = offset2 - 32; - reg.afrh.modify(|r, w| { - w.bits((r.bits() & !(0b1111 << offset2)) | (mode << offset2)) - }); - } - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - } - } - /// Pin - pub struct PA0 { - _mode: PhantomData, - } - impl PA0 { - /// Configures the pin to operate in AF0 mode - pub fn into_alternate_af0(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 0); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF1 mode - pub fn into_alternate_af1(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 1); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF2 mode - pub fn into_alternate_af2(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 2); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF3 mode - pub fn into_alternate_af3(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 3); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF4 mode - pub fn into_alternate_af4(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 4); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF5 mode - pub fn into_alternate_af5(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 5); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF6 mode - pub fn into_alternate_af6(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 6); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate in AF7 mode - pub fn into_alternate_af7(self, _cs: &CriticalSection) -> PA0> { - _set_alternate_mode(0, 7); - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as a floating input pin - pub fn into_floating_input(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled down input pin - pub fn into_pull_down_input(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b10 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as a pulled up input pin - pub fn into_pull_up_input(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an analog pin - pub fn into_analog(self, _cs: &CriticalSection) -> PA0 { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b11 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an open drain output pin - pub fn into_open_drain_output(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() | (0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin - pub fn into_push_pull_output(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA0 { _mode: PhantomData } - } - /// Configures the pin to operate as an push pull output pin with quick fall - /// and rise times - pub fn into_push_pull_output_hs(self, _cs: &CriticalSection) -> PA0> { - let offset = 2 * 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b00 << offset))); - reg.otyper.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.ospeedr.modify(|r, w| w.bits(r.bits() & !(0b1 << 0))); - reg.moder - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (0b01 << offset))); - } - PA0 { _mode: PhantomData } - } - } - impl PA0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(&mut self, _cs: &CriticalSection, on: bool) { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - } - } - impl PA0> { - /// Enables / disables the internal pull up - pub fn internal_pull_up(self, _cs: &CriticalSection, on: bool) -> Self { - let offset = 2 * 0; - let value = if on { 0b01 } else { 0b00 }; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.pupdr - .modify(|r, w| w.bits((r.bits() & !(0b11 << offset)) | (value << offset))); - } - self - } - } - impl PA0> { - /// Turns pin alternate configuration pin into open drain - pub fn set_open_drain(self, _cs: &CriticalSection) -> Self { - let offset = 0; - unsafe { - let reg = &(*GPIOA::ptr()); - reg.otyper.modify(|r, w| w.bits(r.bits() | (1 << offset))); - } - self - } - } - impl PA0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl StatefulOutputPin for PA0> { - fn is_set_high(&self) -> Result { - self.is_set_low().map(|v| !v) - } - fn is_set_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_set_low(0) }) - } - } - impl OutputPin for PA0> { - type Error = Infallible; - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_high(0) }) - } - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(unsafe { (*GPIOA::ptr()).set_low(0) }) - } - } - impl toggleable::Default for PA0> {} - impl InputPin for PA0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(0) }) - } - } - impl PA0> { - /// Erases the pin number from the type - /// - /// This is useful when you want to collect the pins into an array where you - /// need all the elements to have the same type - pub fn downgrade(self) -> Pin> { - Pin { - i: 0, - port: GPIOA::ptr() as *const dyn GpioRegExt, - _mode: self._mode, - } - } - } - impl InputPin for PA0> { - type Error = Infallible; - fn is_high(&self) -> Result { - self.is_low().map(|v| !v) - } - fn is_low(&self) -> Result { - Ok(unsafe { (*GPIOA::ptr()).is_low(0) }) - } - } - } \ No newline at end of file diff --git a/docs/sections_rtt.txt b/docs/sections_rtt.txt deleted file mode 100644 index 75528c1..0000000 --- a/docs/sections_rtt.txt +++ /dev/null @@ -1,3710 +0,0 @@ - -rtt_log: file format elf32-littlearm - - -Disassembly of section .text: - -000000c0 <__stext>: - c0: ldr r4, [pc, #0x2c] - c2: mov lr, r4 - c4: bl #0xdfc - c8: mov lr, r4 - ca: ldr r0, [pc, #0x28] - cc: ldr r1, [pc, #0x28] - ce: movs r2, #0x0 - d0: cmp r1, r0 - d2: beq #0x2 <__stext+0x18> - d4: stm r0!, {r2} - d6: b #-0xa <__stext+0x10> - d8: ldr r0, [pc, #0x20] - da: ldr r1, [pc, #0x24] - dc: ldr r2, [pc, #0x24] - de: cmp r1, r0 - e0: beq #0x4 <__stext+0x28> - e2: ldm r2!, {r3} - e4: stm r0!, {r3} - e6: b #-0xc <__stext+0x1e> - e8: bl #0x5a0 - ec: udf #0x0 - -000000ee <$d>: - ee: 00 00 .short 0x0000 - -000000f0 <$d>: - f0: ff ff ff ff .word 0xffffffff - f4: 00 00 00 10 .word 0x10000000 - f8: 3c 04 00 10 .word 0x1000043c - fc: 00 00 00 10 .word 0x10000000 - 100: 00 00 00 10 .word 0x10000000 - 104: 90 25 00 00 .word 0x00002590 - -00000108 : - 108: push {r7, lr} - 10a: add r7, sp, #0x0 - 10c: sub sp, #0x10 - 10e: str r0, [sp, #0x8] - 110: str r1, [sp, #0xc] - 112: bl #0x538 - 116: str r0, [sp, #0x4] - 118: b #-0x2 - 11a: ldr r1, [sp, #0x4] - 11c: movs r0, #0x1 - 11e: bics r0, r1 - 120: add sp, #0x10 - 122: pop {r7, pc} - -00000124 : - 124: push {r7, lr} - 126: add r7, sp, #0x0 - 128: sub sp, #0x30 - 12a: str r2, [sp, #0xc] - 12c: str r0, [sp, #0x10] - 12e: str r0, [sp, #0x18] - 130: str r1, [sp, #0x1c] - 132: str r2, [sp, #0x20] - 134: adds r0, #0x10 - 136: bl #0x183c - 13a: b #-0x2 - 13c: ldr r1, [sp, #0xc] - 13e: ldr r0, [sp, #0x10] - 140: adds r0, #0x14 - 142: bl #0x1830 - 146: b #-0x2 - 148: ldr r0, [sp, #0x10] - 14a: movs r1, #0x10 - 14c: bl #0x1a2c - 150: str r0, [sp, #0x8] - 152: b #-0x2 - 154: ldr r1, [sp, #0x8] - 156: ldr r0, [pc, #0x44] - 158: movs r2, #0x5 - 15a: bl #0x194c - 15e: b #-0x2 - 160: add r1, sp, #0x14 - 162: movs r0, #0x4 - 164: strb r0, [r1] - 166: ldr r0, [sp, #0x14] - 168: bl #0x167c - 16c: b #-0x2 - 16e: ldr r0, [sp, #0x10] - 170: movs r1, #0x10 - 172: bl #0x1a06 - 176: str r0, [sp, #0x4] - 178: b #-0x2 - 17a: ldr r0, [sp, #0x4] - 17c: str r0, [sp, #0x24] - 17e: movs r1, #0x4 - 180: str r1, [sp, #0x28] - 182: adds r0, r0, #0x4 - 184: str r0, [sp, #0x2c] - 186: ldr r0, [sp, #0x2c] - 188: str r0, [sp] - 18a: b #-0x2 - 18c: ldr r1, [sp] - 18e: ldr r0, [pc, #0x10] - 190: movs r2, #0xc - 192: bl #0x1914 - 196: b #-0x2 - 198: add sp, #0x30 - 19a: pop {r7, pc} - -0000019c <$d.8>: - 19c: 70 1d 00 00 .word 0x00001d70 - 1a0: 75 1d 00 00 .word 0x00001d75 - -000001a4 : - 1a4: push {r4, r6, r7, lr} - 1a6: add r7, sp, #0x8 - 1a8: sub sp, #0x28 - 1aa: str r3, [sp, #0x4] - 1ac: mov r4, r2 - 1ae: str r4, [sp, #0x8] - 1b0: str r0, [sp, #0xc] - 1b2: ldr r2, [r7, #0x8] - 1b4: str r2, [sp, #0x10] - 1b6: str r0, [sp, #0x14] - 1b8: str r1, [sp, #0x18] - 1ba: str r4, [sp, #0x1c] - 1bc: str r3, [sp, #0x20] - 1be: str r2, [sp, #0x24] - 1c0: bl #0x17a4 - 1c4: b #-0x2 - 1c6: ldr r1, [sp, #0x10] - 1c8: ldr r0, [sp, #0xc] - 1ca: adds r0, #0x8 - 1cc: bl #0x17a6 - 1d0: b #-0x2 - 1d2: ldr r1, [sp, #0x8] - 1d4: ldr r0, [sp, #0xc] - 1d6: bl #0x4e - 1da: b #-0x2 - 1dc: ldr r1, [sp, #0x4] - 1de: ldr r0, [sp, #0xc] - 1e0: adds r0, r0, #0x4 - 1e2: bl #0x179e - 1e6: b #-0x2 - 1e8: add sp, #0x28 - 1ea: pop {r4, r6, r7, pc} - -000001ec : - 1ec: push {r7, lr} - 1ee: add r7, sp, #0x0 - 1f0: sub sp, #0x18 - 1f2: str r0, [sp, #0x10] - 1f4: adds r0, #0x14 - 1f6: add r2, sp, #0xc - 1f8: movs r1, #0x4 - 1fa: strb r1, [r2] - 1fc: ldr r1, [sp, #0xc] - 1fe: bl #0x1302 - 202: str r0, [sp, #0x4] - 204: b #-0x2 - 206: ldr r0, [sp, #0x4] - 208: movs r1, #0x3 - 20a: ands r0, r1 - 20c: str r0, [sp] - 20e: str r0, [sp, #0x14] - 210: cmp r0, #0x3 - 212: blo #0x6 - 214: b #-0x2 - 216: movs r0, #0x0 - 218: str r0, [sp, #0x8] - 21a: b #0x4 - 21c: ldr r0, [sp] - 21e: str r0, [sp, #0x8] - 220: b #-0x2 - 222: ldr r0, [sp, #0x8] - 224: add sp, #0x18 - 226: pop {r7, pc} - -00000228 : - 228: push {r7, lr} - 22a: add r7, sp, #0x0 - 22c: sub sp, #0x20 - 22e: str r1, [sp, #0x4] - 230: str r0, [sp, #0x18] - 232: str r1, [sp, #0x1c] - 234: adds r0, #0x14 - 236: str r0, [sp, #0x8] - 238: add r2, sp, #0x10 - 23a: movs r1, #0x4 - 23c: strb r1, [r2] - 23e: ldr r1, [sp, #0x10] - 240: bl #0x12c0 - 244: str r0, [sp, #0xc] - 246: b #-0x2 - 248: ldr r0, [sp, #0x8] - 24a: ldr r2, [sp, #0x4] - 24c: ldr r1, [sp, #0xc] - 24e: movs r3, #0x3 - 250: bics r1, r3 - 252: orrs r1, r2 - 254: add r3, sp, #0x14 - 256: movs r2, #0x4 - 258: strb r2, [r3] - 25a: ldr r2, [sp, #0x14] - 25c: bl #0x135c - 260: b #-0x2 - 262: add sp, #0x20 - 264: pop {r7, pc} - -00000266 : - 266: push {r7, lr} - 268: add r7, sp, #0x0 - 26a: sub sp, #0x10 - 26c: str r1, [sp] - 26e: mov r1, r0 - 270: ldr r0, [sp] - 272: str r1, [sp, #0x4] - 274: str r0, [sp, #0xc] - 276: bl #0x18 - 27a: str r0, [sp, #0x8] - 27c: b #-0x2 - 27e: ldr r1, [sp, #0x4] - 280: ldr r0, [sp, #0x8] - 282: ldr r2, [sp] - 284: str r2, [r1] - 286: str r0, [r1, #0x4] - 288: movs r0, #0x0 - 28a: str r0, [r1, #0x8] - 28c: strb r0, [r1, #0xc] - 28e: add sp, #0x10 - 290: pop {r7, pc} - -00000292 : - 292: push {r7, lr} - 294: add r7, sp, #0x0 - 296: sub sp, #0x40 - 298: str r0, [sp, #0x10] - 29a: str r0, [sp, #0x34] - 29c: adds r0, #0xc - 29e: add r2, sp, #0x20 - 2a0: movs r1, #0x4 - 2a2: strb r1, [r2] - 2a4: ldr r1, [sp, #0x20] - 2a6: bl #0x125a - 2aa: mov r1, r0 - 2ac: str r1, [sp, #0x14] - 2ae: str r0, [sp, #0x38] - 2b0: b #-0x2 - 2b2: ldr r0, [sp, #0x10] - 2b4: adds r0, #0x10 - 2b6: add r2, sp, #0x24 - 2b8: movs r1, #0x4 - 2ba: strb r1, [r2] - 2bc: ldr r1, [sp, #0x24] - 2be: bl #0x1242 - 2c2: mov r1, r0 - 2c4: str r1, [sp, #0xc] - 2c6: str r0, [sp, #0x3c] - 2c8: b #-0x2 - 2ca: ldr r0, [sp, #0x14] - 2cc: ldr r1, [sp, #0x10] - 2ce: ldr r1, [r1, #0x8] - 2d0: cmp r0, r1 - 2d2: bhs #0x1e - 2d4: b #-0x2 - 2d6: ldr r1, [sp, #0xc] - 2d8: ldr r0, [sp, #0x10] - 2da: ldr r2, [r0, #0x8] - 2dc: movs r0, #0x1 - 2de: movs r3, #0x0 - 2e0: str r3, [sp, #0x4] - 2e2: cmp r1, r2 - 2e4: str r0, [sp, #0x8] - 2e6: bhs #0x2 - 2e8: ldr r0, [sp, #0x4] - 2ea: str r0, [sp, #0x8] - 2ec: ldr r0, [sp, #0x8] - 2ee: add r1, sp, #0x28 - 2f0: strb r0, [r1] - 2f2: b #0x6 - 2f4: add r1, sp, #0x28 - 2f6: movs r0, #0x1 - 2f8: strb r0, [r1] - 2fa: b #-0x2 - 2fc: add r0, sp, #0x28 - 2fe: ldrb r0, [r0] - 300: lsls r0, r0, #0x1f - 302: cmp r0, #0x0 - 304: bne #0xa - 306: b #-0x2 - 308: ldr r0, [sp, #0xc] - 30a: ldr r1, [sp, #0x14] - 30c: str r1, [sp, #0x18] - 30e: str r0, [sp, #0x1c] - 310: b #0x2e - 312: ldr r0, [sp, #0x10] - 314: adds r0, #0xc - 316: add r2, sp, #0x2c - 318: movs r1, #0x4 - 31a: strb r1, [r2] - 31c: ldr r2, [sp, #0x2c] - 31e: movs r1, #0x0 - 320: bl #0x1298 - 324: b #-0x2 - 326: ldr r0, [sp, #0x10] - 328: adds r0, #0x10 - 32a: add r2, sp, #0x30 - 32c: movs r1, #0x4 - 32e: strb r1, [r2] - 330: ldr r2, [sp, #0x30] - 332: movs r1, #0x0 - 334: bl #0x1284 - 338: b #-0x2 - 33a: movs r0, #0x0 - 33c: str r0, [sp, #0x18] - 33e: str r0, [sp, #0x1c] - 340: b #-0x2 - 342: ldr r0, [sp, #0x18] - 344: ldr r1, [sp, #0x1c] - 346: add sp, #0x40 - 348: pop {r7, pc} - -0000034a : - 34a: push {r7, lr} - 34c: add r7, sp, #0x0 - 34e: sub sp, #0x20 - 350: str r2, [sp, #0x4] - 352: str r1, [sp, #0x8] - 354: str r0, [sp, #0xc] - 356: str r0, [sp, #0x14] - 358: str r1, [sp, #0x18] - 35a: str r2, [sp, #0x1c] - 35c: ldr r0, [r0] - 35e: bl #-0x176 - 362: str r0, [sp, #0x10] - 364: b #-0x2 - 366: ldr r3, [sp, #0x4] - 368: ldr r2, [sp, #0x8] - 36a: ldr r1, [sp, #0x10] - 36c: ldr r0, [sp, #0xc] - 36e: bl #0x6 - 372: b #-0x2 - 374: add sp, #0x20 - 376: pop {r7, pc} - -00000378 : - 378: push {r7, lr} - 37a: add r7, sp, #0x0 - 37c: sub sp, #0x68 - 37e: str r0, [sp, #0x30] - 380: str r1, [sp, #0x34] - 382: str r2, [sp, #0x38] - 384: str r3, [sp, #0x3c] - 386: str r0, [sp, #0x54] - 388: b #-0x2 - 38a: ldr r0, [sp, #0x30] - 38c: adds r0, #0xc - 38e: ldr r1, [pc, #0x158] - 390: bl #0x2ba - 394: str r0, [sp, #0x2c] - 396: b #-0x2 - 398: ldr r0, [sp, #0x2c] - 39a: lsls r0, r0, #0x1f - 39c: cmp r0, #0x0 - 39e: bne #0x8 - 3a0: b #-0x2 - 3a2: add r1, sp, #0x40 - 3a4: movs r0, #0x0 - 3a6: strb r0, [r1] - 3a8: b #0x16 - 3aa: ldr r0, [sp, #0x38] - 3ac: ldr r1, [sp, #0x3c] - 3ae: bl #0x17d4 - 3b2: str r0, [sp, #0x28] - 3b4: b #-0x2 - 3b6: ldr r1, [sp, #0x28] - 3b8: movs r0, #0x1 - 3ba: bics r0, r1 - 3bc: add r1, sp, #0x40 - 3be: strb r0, [r1] - 3c0: b #-0x2 - 3c2: add r0, sp, #0x40 - 3c4: ldrb r0, [r0] - 3c6: lsls r0, r0, #0x1f - 3c8: cmp r0, #0x0 - 3ca: bne #0x2 - 3cc: b #-0x2 - 3ce: b #0x110 - 3d0: ldr r0, [sp, #0x30] - 3d2: bl #0x126 - 3d6: str r0, [sp, #0x24] - 3d8: b #-0x2 - 3da: ldr r0, [sp, #0x24] - 3dc: ldr r1, [sp, #0x3c] - 3de: bl #0x168a - 3e2: mov r1, r0 - 3e4: str r1, [sp, #0x20] - 3e6: str r0, [sp, #0x58] - 3e8: b #-0x2 - 3ea: ldr r0, [sp, #0x20] - 3ec: cmp r0, #0x0 - 3ee: bne #0x14 - 3f0: b #-0x2 - 3f2: ldr r0, [sp, #0x34] - 3f4: str r0, [sp, #0x1c] - 3f6: cmp r0, #0x0 - 3f8: beq #0x1a - 3fa: b #-0x2 - 3fc: ldr r0, [sp, #0x1c] - 3fe: cmp r0, #0x1 - 400: beq #0x20 - 402: b #-0x2 - 404: b #0x2a - 406: b #-0x2 - 408: ldr r0, [sp, #0x38] - 40a: ldr r1, [sp, #0x3c] - 40c: bl #0xab6 - 410: str r0, [sp, #0x18] - 412: b #0x32 - 414: trap - 416: ldr r1, [sp, #0x30] - 418: add r2, sp, #0x44 - 41a: movs r0, #0x2 - 41c: strb r0, [r2] - 41e: ldr r0, [sp, #0x44] - 420: strb r0, [r1, #0xc] - 422: b #0xbc - 424: ldr r1, [sp, #0x30] - 426: add r2, sp, #0x48 - 428: movs r0, #0x1 - 42a: strb r0, [r2] - 42c: ldr r0, [sp, #0x48] - 42e: strb r0, [r1, #0xc] - 430: b #-0x2c - 432: ldr r1, [sp, #0x30] - 434: ldr r0, [r1] - 436: adds r0, #0xc - 438: ldr r1, [r1, #0x4] - 43a: add r3, sp, #0x4c - 43c: movs r2, #0x4 - 43e: strb r2, [r3] - 440: ldr r2, [sp, #0x4c] - 442: bl #0x1176 - 446: b #-0xc0 - 448: ldr r1, [sp, #0x30] - 44a: ldr r0, [r1] - 44c: ldr r0, [r0, #0x4] - 44e: ldr r1, [r1, #0x4] - 450: str r0, [sp, #0x5c] - 452: str r1, [sp, #0x60] - 454: adds r0, r0, r1 - 456: str r0, [sp, #0x64] - 458: ldr r0, [sp, #0x64] - 45a: str r0, [sp, #0x14] - 45c: b #-0x2 - 45e: ldr r2, [sp, #0x20] - 460: ldr r1, [sp, #0x14] - 462: ldr r0, [sp, #0x18] - 464: bl #0x1642 - 468: b #-0x2 - 46a: ldr r0, [sp, #0x20] - 46c: ldr r1, [sp, #0x30] - 46e: ldr r1, [r1, #0x4] - 470: adds r0, r1, r0 - 472: str r0, [sp, #0x10] - 474: cmp r0, r1 - 476: blo #0x14 - 478: b #-0x2 - 47a: ldr r0, [sp, #0x20] - 47c: ldr r1, [sp, #0x30] - 47e: ldr r2, [sp, #0x10] - 480: str r2, [r1, #0x4] - 482: ldr r1, [r1, #0x8] - 484: adds r0, r1, r0 - 486: str r0, [sp, #0xc] - 488: cmp r0, r1 - 48a: blo #0x1e - 48c: b #0xa - 48e: ldr r0, [pc, #0x60] - 490: ldr r2, [pc, #0x64] - 492: movs r1, #0x1c - 494: bl #0x988 - 498: trap - 49a: ldr r1, [sp, #0x30] - 49c: ldr r0, [sp, #0xc] - 49e: str r0, [r1, #0x8] - 4a0: ldr r0, [r1, #0x4] - 4a2: ldr r1, [r1] - 4a4: ldr r1, [r1, #0x8] - 4a6: cmp r0, r1 - 4a8: bhs #0xe - 4aa: b #0xa - 4ac: ldr r0, [pc, #0x40] - 4ae: ldr r2, [pc, #0x44] - 4b0: movs r1, #0x1c - 4b2: bl #0x96a - 4b6: trap - 4b8: b #0x6 - 4ba: ldr r1, [sp, #0x30] - 4bc: movs r0, #0x0 - 4be: str r0, [r1, #0x4] - 4c0: b #-0x2 - 4c2: ldr r2, [sp, #0x20] - 4c4: ldr r0, [sp, #0x38] - 4c6: ldr r1, [sp, #0x3c] - 4c8: str r2, [sp, #0x50] - 4ca: ldr r2, [sp, #0x50] - 4cc: ldr r3, [pc, #0x1c] - 4ce: bl #0x15b2 - 4d2: str r0, [sp, #0x4] - 4d4: str r1, [sp, #0x8] - 4d6: b #-0x2 - 4d8: ldr r0, [sp, #0x8] - 4da: ldr r1, [sp, #0x4] - 4dc: str r1, [sp, #0x38] - 4de: str r0, [sp, #0x3c] - 4e0: b #-0x15a - 4e2: add sp, #0x68 - 4e4: pop {r7, pc} - 4e6: mov r8, r8 - -000004e8 <$d.22>: - 4e8: 21 1e 00 00 .word 0x00001e21 - 4ec: 44 1e 00 00 .word 0x00001e44 - 4f0: e0 1d 00 00 .word 0x00001de0 - 4f4: 34 1e 00 00 .word 0x00001e34 - 4f8: 24 1e 00 00 .word 0x00001e24 - -000004fc : - 4fc: push {r7, lr} - 4fe: add r7, sp, #0x0 - 500: sub sp, #0x28 - 502: str r0, [sp, #0x14] - 504: str r0, [sp, #0x20] - 506: ldr r0, [r0] - 508: bl #-0x27a - 50c: str r1, [sp, #0x18] - 50e: b #-0x2 - 510: ldr r0, [sp, #0x18] - 512: ldr r1, [sp, #0x14] - 514: str r0, [sp, #0x24] - 516: ldr r1, [r1, #0x4] - 518: cmp r0, r1 - 51a: bhi #0x8 - 51c: b #-0x2 - 51e: ldr r0, [sp, #0x18] - 520: cmp r0, #0x0 - 522: beq #0x40 - 524: b #0x50 - 526: ldr r0, [sp, #0x18] - 528: ldr r1, [sp, #0x14] - 52a: ldr r1, [r1, #0x4] - 52c: subs r2, r0, r1 - 52e: str r2, [sp, #0x10] - 530: cmp r0, r1 - 532: blo #0xc - 534: b #-0x2 - 536: ldr r0, [sp, #0x10] - 538: subs r1, r0, #0x1 - 53a: str r1, [sp, #0xc] - 53c: cmp r0, #0x1 - 53e: blo #0x12 - 540: b #0xa - 542: ldr r0, [pc, #0x84] - 544: ldr r2, [pc, #0x8c] - 546: movs r1, #0x21 - 548: bl #0x8d4 - 54c: trap - 54e: ldr r0, [sp, #0xc] - 550: str r0, [sp, #0x1c] - 552: b #0xa - 554: ldr r0, [pc, #0x70] - 556: ldr r2, [pc, #0x7c] - 558: movs r1, #0x21 - 55a: bl #0x8c2 - 55e: trap - 560: ldr r0, [sp, #0x1c] - 562: add sp, #0x28 - 564: pop {r7, pc} - 566: ldr r1, [sp, #0x14] - 568: ldr r0, [r1] - 56a: ldr r0, [r0, #0x8] - 56c: ldr r1, [r1, #0x4] - 56e: subs r2, r0, r1 - 570: str r2, [sp, #0x8] - 572: cmp r0, r1 - 574: blo #0x30 - 576: b #0x22 - 578: ldr r1, [sp, #0x14] - 57a: ldr r0, [r1] - 57c: ldr r0, [r0, #0x8] - 57e: ldr r1, [r1, #0x4] - 580: subs r2, r0, r1 - 582: str r2, [sp, #0x4] - 584: cmp r0, r1 - 586: blo #0x6 - 588: b #-0x2 - 58a: ldr r0, [sp, #0x4] - 58c: str r0, [sp, #0x1c] - 58e: b #-0x32 - 590: ldr r0, [pc, #0x34] - 592: ldr r2, [pc, #0x38] - 594: movs r1, #0x21 - 596: bl #0x886 - 59a: trap - 59c: ldr r0, [sp, #0x8] - 59e: subs r1, r0, #0x1 - 5a0: str r1, [sp] - 5a2: cmp r0, #0x1 - 5a4: blo #0x12 - 5a6: b #0xa - 5a8: ldr r0, [pc, #0x1c] - 5aa: ldr r2, [pc, #0x24] - 5ac: movs r1, #0x21 - 5ae: bl #0x86e - 5b2: trap - 5b4: ldr r0, [sp] - 5b6: str r0, [sp, #0x1c] - 5b8: b #-0x5c - 5ba: ldr r0, [pc, #0xc] - 5bc: ldr r2, [pc, #0x10] - 5be: movs r1, #0x21 - 5c0: bl #0x85c - 5c4: trap - 5c6: mov r8, r8 - -000005c8 <$d.24>: - 5c8: 00 1e 00 00 .word 0x00001e00 - 5cc: 64 1e 00 00 .word 0x00001e64 - 5d0: 74 1e 00 00 .word 0x00001e74 - 5d4: 54 1e 00 00 .word 0x00001e54 - -000005d8 : - 5d8: push {r7, lr} - 5da: add r7, sp, #0x0 - 5dc: sub sp, #0x8 - 5de: str r0, [sp, #0x4] - 5e0: adds r0, #0xc - 5e2: ldr r1, [pc, #0x14] - 5e4: bl #-0x4e0 - 5e8: str r0, [sp] - 5ea: b #-0x2 - 5ec: ldr r0, [sp] - 5ee: movs r1, #0x1 - 5f0: ands r0, r1 - 5f2: add sp, #0x8 - 5f4: pop {r7, pc} - 5f6: mov r8, r8 - -000005f8 <$d.26>: - 5f8: 84 1e 00 00 .word 0x00001e84 - -000005fc : - 5fc: push {r7, lr} - 5fe: add r7, sp, #0x0 - 600: sub sp, #0x10 - 602: str r0, [sp] - 604: str r0, [sp, #0xc] - 606: ldrb r0, [r0, #0xc] - 608: cmp r0, #0x2 - 60a: blo #0x4 - 60c: b #-0x2 - 60e: b #0x16 - 610: trap - 612: ldr r1, [sp] - 614: ldr r0, [r1] - 616: adds r0, #0xc - 618: ldr r1, [r1, #0x4] - 61a: add r3, sp, #0x4 - 61c: movs r2, #0x4 - 61e: strb r2, [r3] - 620: ldr r2, [sp, #0x4] - 622: bl #0xf96 - 626: b #0x4 - 628: b #-0x2 - 62a: add sp, #0x10 - 62c: pop {r7, pc} - 62e: ldr r1, [sp] - 630: add r2, sp, #0x8 - 632: movs r0, #0x2 - 634: strb r0, [r2] - 636: ldr r0, [sp, #0x8] - 638: strb r0, [r1, #0xc] - 63a: b #-0x14 - -0000063c <::drop::h7e3a87c98bceab77>: - 63c: push {r7, lr} - 63e: add r7, sp, #0x0 - 640: sub sp, #0x8 - 642: str r0, [sp, #0x4] - 644: bl #-0x4c - 648: b #-0x2 <::drop::h7e3a87c98bceab77+0xe> - 64a: add sp, #0x8 - 64c: pop {r7, pc} - -0000064e <::eq::h857abb5fffe1efd8>: - 64e: sub sp, #0x14 - 650: str r0, [sp, #0x4] - 652: str r1, [sp, #0x8] - 654: ldrb r0, [r0] - 656: str r0, [sp, #0xc] - 658: ldrb r1, [r1] - 65a: str r1, [sp, #0x10] - 65c: cmp r0, r1 - 65e: beq #0x8 <::eq::h857abb5fffe1efd8+0x1c> - 660: b #-0x2 <::eq::h857abb5fffe1efd8+0x14> - 662: mov r1, sp - 664: movs r0, #0x0 - 666: strb r0, [r1] - 668: b #0x6 <::eq::h857abb5fffe1efd8+0x24> - 66a: mov r1, sp - 66c: movs r0, #0x1 - 66e: strb r0, [r1] - 670: b #-0x2 <::eq::h857abb5fffe1efd8+0x24> - 672: mov r0, sp - 674: ldrb r0, [r0] - 676: add sp, #0x14 - 678: bx lr - -0000067a : - 67a: push {r7, lr} - 67c: add r7, sp, #0x0 - 67e: sub sp, #0x8 - 680: str r0, [sp, #0x4] - 682: bl #0x151c - 686: b #-0x2 - 688: add sp, #0x8 - 68a: pop {r7, pc} - -0000068c
: - 68c: push {r7, lr} - 68e: add r7, sp, #0x0 - 690: bl #0x4 - 694: trap - 696: movs r0, r0 - -00000698 : - 698: push {r7, lr} - 69a: add r7, sp, #0x0 - 69c: sub sp, #0x50 - 69e: ldr r0, [pc, #0xb0] - 6a0: str r0, [sp, #0x34] - 6a2: b #-0x2 - 6a4: ldr r0, [pc, #0xa8] - 6a6: movs r1, #0x0 - 6a8: movs r2, #0x1 - 6aa: bl #0x842 - 6ae: b #-0x2 - 6b0: ldr r0, [pc, #0x9c] - 6b2: str r0, [sp, #0x4c] - 6b4: b #-0x2 - 6b6: ldr r0, [pc, #0x98] - 6b8: str r0, [sp, #0x30] - 6ba: movs r0, #0x0 - 6bc: str r0, [sp, #0x24] - 6be: b #-0x2 - 6c0: ldr r1, [pc, #0x90] - 6c2: str r1, [sp, #0x3c] - 6c4: movs r0, #0x9 - 6c6: str r0, [sp, #0x40] - 6c8: str r1, [sp, #0x44] - 6ca: str r0, [sp, #0x48] - 6cc: ldr r0, [sp, #0x44] - 6ce: str r0, [sp, #0x18] - 6d0: ldr r0, [sp, #0x48] - 6d2: str r0, [sp, #0x1c] - 6d4: b #-0x2 - 6d6: ldr r1, [sp, #0x1c] - 6d8: ldr r0, [sp, #0x18] - 6da: bl #0x7e8 - 6de: str r0, [sp, #0x14] - 6e0: b #-0x2 - 6e2: ldr r0, [sp, #0x14] - 6e4: str r0, [sp, #0x24] - 6e6: movs r0, #0x0 - 6e8: str r0, [sp, #0x28] - 6ea: ldr r0, [pc, #0x64] - 6ec: adds r0, #0x18 - 6ee: str r0, [sp, #0x8] - 6f0: ldr r0, [sp, #0x24] - 6f2: str r0, [sp, #0xc] - 6f4: ldr r0, [sp, #0x28] - 6f6: str r0, [sp, #0x10] - 6f8: ldr r0, [pc, #0x5c] - 6fa: str r0, [sp, #0x38] - 6fc: b #-0x2 - 6fe: ldr r2, [sp, #0x10] - 700: ldr r1, [sp, #0xc] - 702: ldr r0, [sp, #0x8] - 704: ldr r3, [pc, #0x50] - 706: movs r4, #0x1 - 708: lsls r4, r4, #0xa - 70a: str r4, [sp] - 70c: bl #-0x56c - 710: b #-0x2 - 712: ldr r0, [pc, #0x3c] - 714: movs r1, #0x1 - 716: movs r2, #0x0 - 718: bl #-0x5f8 - 71c: b #-0x2 - 71e: ldr r0, [pc, #0x30] - 720: adds r0, #0x18 - 722: bl #0xb22 - 726: str r0, [sp, #0x4] - 728: b #-0x2 - 72a: ldr r0, [sp, #0x4] - 72c: str r0, [sp, #0x2c] - 72e: ldr r0, [sp, #0x2c] - 730: str r0, [sp, #0x20] - 732: ldr r0, [sp, #0x20] - 734: bl #0x8b4 - 738: b #-0x2 - 73a: ldr r1, [pc, #0x20] - 73c: movs r0, #0x0 - 73e: movs r2, #0xe - 740: bl #0x1184 - 744: b #-0x2 - 746: ldr r0, [pc, #0x18] - 748: bl #-0xd2 - 74c: b #-0x2 - 74e: b #-0x18 - -00000750 <$d.35>: - 750: 00 00 00 10 .word 0x10000000 - 754: 85 1e 00 00 .word 0x00001e85 - 758: 30 00 00 10 .word 0x10000030 - 75c: 8e 1e 00 00 .word 0x00001e8e - 760: 40 78 7d 01 .word 0x017d7840 - -00000764 : - 764: sub sp, #0x4 - 766: add sp, #0x4 - 768: bx lr - 76a: movs r0, r0 - -0000076c : - 76c: push {r7, lr} - 76e: add r7, sp, #0x0 - 770: sub sp, #0x38 - 772: str r2, [sp] - 774: mov r2, r1 - 776: ldr r1, [sp] - 778: str r2, [sp, #0x4] - 77a: mov r2, r0 - 77c: ldr r0, [sp, #0x4] - 77e: str r2, [sp, #0x8] - 780: str r0, [sp, #0xc] - 782: add r0, sp, #0xc - 784: str r0, [sp, #0x28] - 786: ldr r0, [pc, #0x24] - 788: str r0, [sp, #0x2c] - 78a: add r2, sp, #0x8 - 78c: str r2, [sp, #0x30] - 78e: str r0, [sp, #0x34] - 790: ldr r0, [pc, #0x1c] - 792: str r0, [sp, #0x10] - 794: movs r0, #0x2 - 796: str r0, [sp, #0x14] - 798: movs r2, #0x0 - 79a: str r2, [sp, #0x18] - 79c: str r2, [sp, #0x1c] - 79e: add r2, sp, #0x28 - 7a0: str r2, [sp, #0x20] - 7a2: str r0, [sp, #0x24] - 7a4: add r0, sp, #0x10 - 7a6: bl #0x152 - 7aa: trap - -000007ac <$d.48>: - 7ac: b5 07 00 00 .word 0x000007b5 - 7b0: 9c 1e 00 00 .word 0x00001e9c - -000007b4 ::fmt::hadbf8358ea5867cd>: - 7b4: push {r4, r5, r6, r7, lr} - 7b6: add r7, sp, #0xc - 7b8: sub sp, #0x84 - 7ba: str r1, [sp, #0x50] - 7bc: ldr r0, [r0] - 7be: add r1, sp, #0x5c - 7c0: movs r1, #0x27 - 7c2: ldr r2, [pc, #0x124] - 7c4: cmp r0, r2 - 7c6: str r1, [sp, #0x54] - 7c8: str r0, [sp, #0x58] - 7ca: bhi #0x12 ::fmt::hadbf8358ea5867cd+0x2c> - 7cc: b #-0x2 ::fmt::hadbf8358ea5867cd+0x1a> - 7ce: ldr r0, [sp, #0x54] - 7d0: ldr r1, [sp, #0x58] - 7d2: str r1, [sp, #0x40] - 7d4: str r0, [sp, #0x44] - 7d6: cmp r1, #0x63 - 7d8: str r1, [sp, #0x48] - 7da: str r0, [sp, #0x4c] - 7dc: bgt #0x78 ::fmt::hadbf8358ea5867cd+0xa4> - 7de: b #0xac ::fmt::hadbf8358ea5867cd+0xda> - 7e0: ldr r0, [sp, #0x58] - 7e2: ldr r4, [sp, #0x54] - 7e4: str r0, [sp, #0x2c] - 7e6: str r0, [sp, #0x20] - 7e8: ldr r1, [pc, #0x100] - 7ea: str r1, [sp, #0x1c] - 7ec: bl #0x13c2 - 7f0: ldr r1, [sp, #0x1c] - 7f2: mov r2, r0 - 7f4: ldr r0, [sp, #0x20] - 7f6: mov r3, r2 - 7f8: str r3, [sp, #0x3c] - 7fa: muls r1, r2, r1 - 7fc: subs r0, r0, r1 - 7fe: str r0, [sp, #0x28] - 800: uxth r0, r0 - 802: movs r1, #0x64 - 804: str r1, [sp, #0x24] - 806: bl #0x13a8 - 80a: ldr r2, [sp, #0x24] - 80c: ldr r1, [sp, #0x28] - 80e: mov r3, r0 - 810: lsls r0, r3, #0x1 - 812: muls r2, r3, r2 - 814: subs r1, r1, r2 - 816: lsls r1, r1, #0x11 - 818: lsrs r6, r1, #0x10 - 81a: subs r2, r4, #0x4 - 81c: str r2, [sp, #0x30] - 81e: ldr r3, [pc, #0xd0] - 820: adds r5, r3, r0 - 822: add r1, sp, #0x5c - 824: str r1, [sp, #0x38] - 826: adds r1, r1, r2 - 828: str r1, [sp, #0x34] - 82a: ldr r1, [sp, #0x38] - 82c: ldrb r5, [r5, #0x1] - 82e: ldrb r0, [r3, r0] - 830: strb r0, [r1, r2] - 832: ldr r2, [sp, #0x2c] - 834: ldr r1, [sp, #0x30] - 836: ldr r0, [sp, #0x34] - 838: strb r5, [r0, #0x1] - 83a: ldr r0, [sp, #0x38] - 83c: adds r5, r3, r6 - 83e: adds r4, r4, r0 - 840: ldr r0, [sp, #0x3c] - 842: subs r4, r4, #0x2 - 844: ldrb r3, [r3, r6] - 846: ldrb r5, [r5, #0x1] - 848: strb r5, [r4, #0x1] - 84a: strb r3, [r4] - 84c: ldr r3, [pc, #0xa4] - 84e: cmp r2, r3 - 850: str r1, [sp, #0x54] - 852: str r0, [sp, #0x58] - 854: bhi #-0x78 ::fmt::hadbf8358ea5867cd+0x2c> - 856: b #-0x8c ::fmt::hadbf8358ea5867cd+0x1a> - 858: ldr r0, [sp, #0x40] - 85a: str r0, [sp, #0x18] - 85c: uxth r0, r0 - 85e: movs r1, #0x64 - 860: str r1, [sp, #0x14] - 862: bl #0x134c - 866: ldr r3, [sp, #0x14] - 868: ldr r2, [sp, #0x18] - 86a: mov r1, r0 - 86c: ldr r0, [sp, #0x44] - 86e: muls r3, r1, r3 - 870: subs r2, r2, r3 - 872: lsls r2, r2, #0x11 - 874: lsrs r6, r2, #0x10 - 876: subs r0, r0, #0x2 - 878: ldr r4, [pc, #0x74] - 87a: adds r2, r4, r6 - 87c: add r5, sp, #0x5c - 87e: adds r3, r5, r0 - 880: ldrb r2, [r2, #0x1] - 882: ldrb r4, [r4, r6] - 884: strb r4, [r5, r0] - 886: strb r2, [r3, #0x1] - 888: str r1, [sp, #0x48] - 88a: str r0, [sp, #0x4c] - 88c: b #-0x2 ::fmt::hadbf8358ea5867cd+0xda> - 88e: ldr r0, [sp, #0x48] - 890: ldr r1, [sp, #0x4c] - 892: str r1, [sp, #0xc] - 894: str r0, [sp, #0x10] - 896: cmp r0, #0xa - 898: blt #0x1c ::fmt::hadbf8358ea5867cd+0x104> - 89a: b #-0x2 ::fmt::hadbf8358ea5867cd+0xe8> - 89c: ldr r0, [sp, #0xc] - 89e: ldr r1, [sp, #0x10] - 8a0: lsls r5, r1, #0x1 - 8a2: subs r0, r0, #0x2 - 8a4: ldr r3, [pc, #0x48] - 8a6: adds r1, r3, r5 - 8a8: add r4, sp, #0x5c - 8aa: adds r2, r4, r0 - 8ac: ldrb r1, [r1, #0x1] - 8ae: ldrb r3, [r3, r5] - 8b0: strb r3, [r4, r0] - 8b2: strb r1, [r2, #0x1] - 8b4: str r0, [sp, #0x8] - 8b6: b #0xe ::fmt::hadbf8358ea5867cd+0x114> - 8b8: ldr r1, [sp, #0x10] - 8ba: ldr r0, [sp, #0xc] - 8bc: subs r0, r0, #0x1 - 8be: adds r1, #0x30 - 8c0: add r2, sp, #0x5c - 8c2: strb r1, [r2, r0] - 8c4: str r0, [sp, #0x8] - 8c6: b #-0x2 ::fmt::hadbf8358ea5867cd+0x114> - 8c8: ldr r0, [sp, #0x50] - 8ca: ldr r3, [sp, #0x8] - 8cc: add r1, sp, #0x5c - 8ce: adds r1, r1, r3 - 8d0: movs r2, #0x27 - 8d2: subs r2, r2, r3 - 8d4: str r2, [sp, #0x4] - 8d6: str r1, [sp] - 8d8: ldr r2, [pc, #0x1c] - 8da: movs r1, #0x1 - 8dc: movs r3, #0x0 - 8de: bl #0x52 - 8e2: add sp, #0x84 - 8e4: pop {r4, r5, r6, r7, pc} - 8e6: mov r8, r8 - -000008e8 <$d.50>: - 8e8: 0f 27 00 00 .word 0x0000270f - 8ec: 10 27 00 00 .word 0x00002710 - 8f0: ae 1f 00 00 .word 0x00001fae - 8f4: ff e0 f5 05 .word 0x05f5e0ff - 8f8: ac 1e 00 00 .word 0x00001eac - -000008fc : - 8fc: push {r7, lr} - 8fe: add r7, sp, #0x0 - 900: sub sp, #0x10 - 902: ldr r2, [pc, #0x14] - 904: str r2, [sp] - 906: ldr r2, [pc, #0x14] - 908: str r2, [sp, #0x4] - 90a: str r0, [sp, #0x8] - 90c: str r1, [sp, #0xc] - 90e: mov r0, sp - 910: bl #0x5fe - 914: trap - 916: mov r8, r8 - -00000918 <$d.52>: - 918: ac 1e 00 00 .word 0x00001eac - 91c: ac 1e 00 00 .word 0x00001eac - -00000920 >>::hf8c61914ce9c9fa0>: - 920: bx lr - 922: movs r0, r0 - -00000924 <::type_id::hd6987cca06ab622a>: - 924: ldr r0, [pc, #0x4] - 926: ldr r1, [pc, #0x8] - 928: bx lr - 92a: mov r8, r8 - -0000092c <$d.55>: - 92c: f1 45 73 29 .word 0x297345f1 - 930: fe 77 68 12 .word 0x126877fe - -00000934 : - 934: push {r4, r5, r7, lr} - 936: add r7, sp, #0x8 - 938: sub sp, #0x160 - 93a: str r3, [sp, #0x14c] - 93c: str r2, [sp, #0x150] - 93e: str r0, [sp, #0x154] - 940: ldr r0, [r7, #0xc] - 942: str r0, [sp, #0x158] - 944: ldr r0, [r7, #0x8] - 946: str r0, [sp, #0x15c] - 948: cmp r1, #0x0 - 94a: beq #0x30 - 94c: b #-0x2 - 94e: ldr r0, [sp, #0x154] - 950: ldr r1, [r0] - 952: str r1, [sp, #0x13c] - 954: movs r0, #0x1 - 956: ands r1, r0 - 958: str r1, [sp, #0x140] - 95a: movs r0, #0x11 - 95c: lsls r0, r0, #0x10 - 95e: movs r2, #0x2b - 960: str r2, [sp, #0x144] - 962: cmp r1, #0x0 - 964: str r0, [sp, #0x148] - 966: beq #0x2 - 968: ldr r0, [sp, #0x144] - 96a: str r0, [sp, #0x148] - 96c: ldr r2, [sp, #0x13c] - 96e: ldr r0, [sp, #0x140] - 970: ldr r3, [sp, #0x158] - 972: ldr r1, [sp, #0x148] - 974: adds r0, r0, r3 - 976: str r2, [sp, #0x130] - 978: str r1, [sp, #0x134] - 97a: str r0, [sp, #0x138] - 97c: b #0x10 - 97e: ldr r1, [sp, #0x154] - 980: ldr r0, [sp, #0x158] - 982: adds r0, r0, #0x1 - 984: ldr r2, [r1] - 986: movs r1, #0x2d - 988: str r2, [sp, #0x130] - 98a: str r1, [sp, #0x134] - 98c: str r0, [sp, #0x138] - 98e: b #-0x2 - 990: ldr r3, [sp, #0x130] - 992: ldr r1, [sp, #0x134] - 994: ldr r0, [sp, #0x138] - 996: str r0, [sp, #0x118] - 998: str r1, [sp, #0x11c] - 99a: str r3, [sp, #0x120] - 99c: movs r1, #0x0 - 99e: mov r2, r1 - 9a0: lsls r3, r3, #0x1d - 9a2: cmp r3, #0x0 - 9a4: str r2, [sp, #0x124] - 9a6: str r1, [sp, #0x128] - 9a8: str r0, [sp, #0x12c] - 9aa: bpl #0x54 - 9ac: b #-0x2 - 9ae: ldr r2, [sp, #0x14c] - 9b0: ldr r1, [sp, #0x150] - 9b2: mov r0, r1 - 9b4: str r0, [sp, #0x108] - 9b6: adds r1, r1, r2 - 9b8: str r1, [sp, #0x10c] - 9ba: movs r1, #0x0 - 9bc: cmp r2, #0x0 - 9be: str r1, [sp, #0x110] - 9c0: str r0, [sp, #0x114] - 9c2: beq #0x2a - 9c4: b #-0x2 - 9c6: ldr r0, [sp, #0x110] - 9c8: ldr r1, [sp, #0x114] - 9ca: str r0, [sp, #0xfc] - 9cc: adds r2, r1, #0x1 - 9ce: str r2, [sp, #0x100] - 9d0: ldrb r1, [r1] - 9d2: adds r0, r0, #0x1 - 9d4: lsrs r1, r1, #0x6 - 9d6: cmp r1, #0x2 - 9d8: str r0, [sp, #0x104] - 9da: bne #0x2 - 9dc: ldr r0, [sp, #0xfc] - 9de: str r0, [sp, #0x104] - 9e0: ldr r0, [sp, #0x100] - 9e2: ldr r2, [sp, #0x10c] - 9e4: ldr r1, [sp, #0x104] - 9e6: cmp r0, r2 - 9e8: str r1, [sp, #0x110] - 9ea: str r0, [sp, #0x114] - 9ec: bne #-0x2a - 9ee: b #-0x2 - 9f0: ldr r1, [sp, #0x14c] - 9f2: ldr r2, [sp, #0x108] - 9f4: ldr r3, [sp, #0x118] - 9f6: ldr r0, [sp, #0x110] - 9f8: adds r0, r0, r3 - 9fa: str r2, [sp, #0x124] - 9fc: str r1, [sp, #0x128] - 9fe: str r0, [sp, #0x12c] - a00: b #-0x2 - a02: ldr r0, [sp, #0x154] - a04: ldr r1, [sp, #0x124] - a06: ldr r2, [sp, #0x128] - a08: ldr r3, [sp, #0x12c] - a0a: str r3, [sp, #0xf0] - a0c: str r2, [sp, #0xf4] - a0e: str r1, [sp, #0xf8] - a10: ldr r0, [r0, #0x8] - a12: cmp r0, #0x1 - a14: beq #0x1a - a16: b #-0x2 - a18: ldr r3, [sp, #0xf4] - a1a: ldr r2, [sp, #0xf8] - a1c: ldr r1, [sp, #0x11c] - a1e: ldr r0, [sp, #0x154] - a20: bl #0x35c - a24: mov r1, r0 - a26: movs r0, #0x1 - a28: cmp r1, #0x0 - a2a: str r0, [sp, #0xec] - a2c: beq #0x0 - a2e: b #0x344 - a30: b #0x330 - a32: ldr r1, [sp, #0xf0] - a34: ldr r0, [sp, #0x154] - a36: ldr r0, [r0, #0xc] - a38: str r0, [sp, #0xe8] - a3a: cmp r0, r1 - a3c: bls #0xa - a3e: b #-0x2 - a40: ldr r0, [sp, #0x120] - a42: lsls r0, r0, #0x1c - a44: cmp r0, #0x0 - a46: bpl #0x2a - a48: b #0x102 - a4a: ldr r3, [sp, #0xf4] - a4c: ldr r2, [sp, #0xf8] - a4e: ldr r1, [sp, #0x11c] - a50: ldr r0, [sp, #0x154] - a52: bl #0x32a - a56: mov r1, r0 - a58: movs r0, #0x1 - a5a: cmp r1, #0x0 - a5c: str r0, [sp, #0xec] - a5e: beq #0x0 - a60: b #0x312 - a62: ldr r2, [sp, #0x158] - a64: ldr r1, [sp, #0x15c] - a66: ldr r3, [sp, #0x154] - a68: ldr r0, [r3, #0x18] - a6a: ldr r3, [r3, #0x1c] - a6c: ldr r3, [r3, #0xc] - a6e: blx r3 - a70: str r0, [sp, #0xec] - a72: b #0x300 - a74: ldr r0, [sp, #0x154] - a76: ldr r1, [sp, #0xe8] - a78: ldr r2, [sp, #0xf0] - a7a: subs r1, r1, r2 - a7c: str r1, [sp, #0xdc] - a7e: movs r1, #0x20 - a80: ldrb r1, [r0, r1] - a82: str r1, [sp, #0xe0] - a84: movs r0, #0x1 - a86: cmp r1, #0x3 - a88: str r0, [sp, #0xe4] - a8a: beq #0x2 - a8c: ldr r0, [sp, #0xe0] - a8e: str r0, [sp, #0xe4] - a90: ldr r0, [sp, #0xe4] - a92: str r0, [sp, #0xd4] - a94: movs r1, #0x3 - a96: ands r0, r1 - a98: movs r1, #0x0 - a9a: str r1, [sp, #0xd8] - a9c: cmp r0, #0x2 - a9e: beq #0x20 - aa0: b #-0x2 - aa2: ldr r0, [sp, #0xd8] - aa4: ldr r1, [sp, #0xdc] - aa6: ldr r2, [sp, #0xd4] - aa8: lsls r2, r2, #0x1e - aaa: cmp r2, #0x0 - aac: str r1, [sp, #0xcc] - aae: str r0, [sp, #0xd0] - ab0: beq #0x1c - ab2: b #-0x2 - ab4: b #0x0 - ab6: trap - ab8: ldr r0, [sp, #0xdc] - aba: movs r1, #0x0 - abc: str r1, [sp, #0xcc] - abe: str r0, [sp, #0xd0] - ac0: b #0xc - ac2: ldr r1, [sp, #0xdc] - ac4: lsrs r0, r1, #0x1 - ac6: adds r1, r1, #0x1 - ac8: lsrs r1, r1, #0x1 - aca: str r1, [sp, #0xcc] - acc: str r0, [sp, #0xd0] - ace: b #-0x2 - ad0: ldr r1, [sp, #0x154] - ad2: ldr r0, [sp, #0xcc] - ad4: ldr r2, [sp, #0xd0] - ad6: str r2, [sp, #0xac] - ad8: str r0, [sp, #0xb0] - ada: mov r0, r1 - adc: adds r0, #0x18 - ade: str r0, [sp, #0xb4] - ae0: ldr r0, [r1, #0x18] - ae2: str r0, [sp, #0xb8] - ae4: mov r0, r1 - ae6: adds r0, #0x1c - ae8: str r0, [sp, #0xbc] - aea: ldr r0, [r1, #0x1c] - aec: ldr r1, [r1, #0x4] - aee: str r1, [sp, #0xc0] - af0: adds r0, #0x10 - af2: str r0, [sp, #0xc4] - af4: movs r0, #0x0 - af6: str r0, [sp, #0xc8] - af8: b #-0x2 - afa: ldr r1, [sp, #0xac] - afc: ldr r0, [sp, #0xc8] - afe: str r0, [sp, #0xa8] - b00: cmp r0, r1 - b02: beq #0x20 - b04: b #-0x2 - b06: ldr r1, [sp, #0xc0] - b08: ldr r0, [sp, #0xb8] - b0a: ldr r2, [sp, #0xc4] - b0c: ldr r3, [sp, #0xa8] - b0e: adds r3, r3, #0x1 - b10: str r3, [sp, #0xa4] - b12: ldr r2, [r2] - b14: blx r2 - b16: ldr r1, [sp, #0xa4] - b18: mov r2, r0 - b1a: movs r0, #0x1 - b1c: cmp r2, #0x0 - b1e: str r1, [sp, #0xc8] - b20: str r0, [sp, #0xec] - b22: beq #-0x2c - b24: b #0x24e - b26: ldr r1, [sp, #0xc0] - b28: movs r0, #0x11 - b2a: lsls r2, r0, #0x10 - b2c: str r2, [sp, #0x9c] - b2e: movs r0, #0x0 - b30: cmp r1, r2 - b32: str r0, [sp, #0xa0] - b34: beq #0x2 - b36: ldr r0, [sp, #0xb0] - b38: str r0, [sp, #0xa0] - b3a: ldr r1, [sp, #0xc0] - b3c: ldr r2, [sp, #0x9c] - b3e: ldr r0, [sp, #0xa0] - b40: str r0, [sp, #0x98] - b42: movs r0, #0x1 - b44: cmp r1, r2 - b46: str r0, [sp, #0xec] - b48: bne #0x0 - b4a: b #0x228 - b4c: b #0x184 - b4e: ldr r3, [sp, #0xf4] - b50: ldr r2, [sp, #0xf8] - b52: ldr r1, [sp, #0x11c] - b54: ldr r0, [sp, #0x154] - b56: adds r4, r0, #0x4 - b58: str r4, [sp, #0x84] - b5a: ldr r4, [r0, #0x4] - b5c: str r4, [sp, #0x88] - b5e: movs r4, #0x30 - b60: str r4, [r0, #0x4] - b62: mov r4, r0 - b64: adds r4, #0x20 - b66: str r4, [sp, #0x8c] - b68: movs r5, #0x20 - b6a: ldrb r4, [r0, r5] - b6c: str r4, [sp, #0x90] - b6e: movs r4, #0x1 - b70: str r4, [sp, #0x94] - b72: strb r4, [r0, r5] - b74: bl #0x208 - b78: mov r1, r0 - b7a: ldr r0, [sp, #0x94] - b7c: cmp r1, #0x0 - b7e: str r0, [sp, #0xec] - b80: beq #0x0 - b82: b #0x1f0 - b84: ldr r0, [sp, #0x8c] - b86: ldr r1, [sp, #0xe8] - b88: ldr r2, [sp, #0xf0] - b8a: subs r1, r1, r2 - b8c: str r1, [sp, #0x78] - b8e: ldrb r1, [r0] - b90: str r1, [sp, #0x7c] - b92: movs r0, #0x1 - b94: cmp r1, #0x3 - b96: str r0, [sp, #0x80] - b98: beq #0x2 - b9a: ldr r0, [sp, #0x7c] - b9c: str r0, [sp, #0x80] - b9e: ldr r0, [sp, #0x80] - ba0: str r0, [sp, #0x70] - ba2: movs r1, #0x3 - ba4: ands r0, r1 - ba6: movs r1, #0x0 - ba8: str r1, [sp, #0x74] - baa: cmp r0, #0x2 - bac: beq #0x20 - bae: b #-0x2 - bb0: ldr r0, [sp, #0x74] - bb2: ldr r1, [sp, #0x78] - bb4: ldr r2, [sp, #0x70] - bb6: lsls r2, r2, #0x1e - bb8: cmp r2, #0x0 - bba: str r1, [sp, #0x68] - bbc: str r0, [sp, #0x6c] - bbe: beq #0x1c - bc0: b #-0x2 - bc2: b #0x0 - bc4: trap - bc6: ldr r0, [sp, #0x78] - bc8: movs r1, #0x0 - bca: str r1, [sp, #0x68] - bcc: str r0, [sp, #0x6c] - bce: b #0xc - bd0: ldr r1, [sp, #0x78] - bd2: lsrs r0, r1, #0x1 - bd4: adds r1, r1, #0x1 - bd6: lsrs r1, r1, #0x1 - bd8: str r1, [sp, #0x68] - bda: str r0, [sp, #0x6c] - bdc: b #-0x2 - bde: ldr r1, [sp, #0x84] - be0: ldr r0, [sp, #0x154] - be2: ldr r2, [sp, #0x68] - be4: ldr r3, [sp, #0x6c] - be6: str r3, [sp, #0x48] - be8: str r2, [sp, #0x4c] - bea: mov r2, r0 - bec: adds r2, #0x18 - bee: str r2, [sp, #0x50] - bf0: ldr r2, [r0, #0x18] - bf2: str r2, [sp, #0x54] - bf4: mov r2, r0 - bf6: adds r2, #0x1c - bf8: str r2, [sp, #0x58] - bfa: ldr r0, [r0, #0x1c] - bfc: ldr r1, [r1] - bfe: str r1, [sp, #0x5c] - c00: adds r0, #0x10 - c02: str r0, [sp, #0x60] - c04: movs r0, #0x0 - c06: str r0, [sp, #0x64] - c08: b #-0x2 - c0a: ldr r1, [sp, #0x48] - c0c: ldr r0, [sp, #0x64] - c0e: str r0, [sp, #0x44] - c10: cmp r0, r1 - c12: beq #0x20 - c14: b #-0x2 - c16: ldr r1, [sp, #0x5c] - c18: ldr r0, [sp, #0x54] - c1a: ldr r2, [sp, #0x60] - c1c: ldr r3, [sp, #0x44] - c1e: adds r3, r3, #0x1 - c20: str r3, [sp, #0x40] - c22: ldr r2, [r2] - c24: blx r2 - c26: ldr r1, [sp, #0x40] - c28: mov r2, r0 - c2a: movs r0, #0x1 - c2c: cmp r2, #0x0 - c2e: str r1, [sp, #0x64] - c30: str r0, [sp, #0xec] - c32: beq #-0x2c - c34: b #0x13e - c36: ldr r1, [sp, #0x5c] - c38: movs r0, #0x11 - c3a: lsls r2, r0, #0x10 - c3c: str r2, [sp, #0x38] - c3e: movs r0, #0x0 - c40: cmp r1, r2 - c42: str r0, [sp, #0x3c] - c44: beq #0x2 - c46: ldr r0, [sp, #0x4c] - c48: str r0, [sp, #0x3c] - c4a: ldr r1, [sp, #0x5c] - c4c: ldr r2, [sp, #0x38] - c4e: ldr r0, [sp, #0x3c] - c50: str r0, [sp, #0x34] - c52: movs r0, #0x1 - c54: cmp r1, r2 - c56: str r0, [sp, #0xec] - c58: bne #0x0 - c5a: b #0x118 - c5c: ldr r2, [sp, #0x158] - c5e: ldr r1, [sp, #0x15c] - c60: ldr r3, [sp, #0x58] - c62: ldr r0, [sp, #0x50] - c64: ldr r0, [r0] - c66: ldr r3, [r3] - c68: ldr r3, [r3, #0xc] - c6a: blx r3 - c6c: mov r1, r0 - c6e: movs r0, #0x1 - c70: cmp r1, #0x0 - c72: str r0, [sp, #0xec] - c74: bne #0xfe - c76: b #-0x2 - c78: ldr r0, [sp, #0x58] - c7a: ldr r1, [sp, #0x50] - c7c: ldr r1, [r1] - c7e: str r1, [sp, #0x28] - c80: ldr r0, [r0] - c82: adds r0, #0x10 - c84: str r0, [sp, #0x2c] - c86: movs r0, #0x0 - c88: str r0, [sp, #0x30] - c8a: b #-0x2 - c8c: ldr r1, [sp, #0x34] - c8e: ldr r0, [sp, #0x30] - c90: str r0, [sp, #0x24] - c92: cmp r0, r1 - c94: beq #0x2a - c96: b #-0x2 - c98: ldr r1, [sp, #0x5c] - c9a: ldr r0, [sp, #0x28] - c9c: ldr r2, [sp, #0x2c] - c9e: ldr r3, [sp, #0x24] - ca0: adds r3, r3, #0x1 - ca2: str r3, [sp, #0x20] - ca4: ldr r2, [r2] - ca6: blx r2 - ca8: mov r1, r0 - caa: ldr r0, [sp, #0x20] - cac: cmp r1, #0x0 - cae: str r0, [sp, #0x30] - cb0: beq #-0x28 - cb2: b #-0x2 - cb4: ldr r1, [sp, #0x24] - cb6: ldr r2, [sp, #0x34] - cb8: movs r0, #0x1 - cba: cmp r1, r2 - cbc: str r0, [sp, #0xec] - cbe: blo #0xb4 - cc0: b #-0x2 - cc2: ldr r0, [sp, #0x90] - cc4: ldr r1, [sp, #0x8c] - cc6: ldr r2, [sp, #0x88] - cc8: ldr r3, [sp, #0x84] - cca: str r2, [r3] - ccc: strb r0, [r1] - cce: movs r0, #0x0 - cd0: str r0, [sp, #0xec] - cd2: b #0xa0 - cd4: ldr r3, [sp, #0xf4] - cd6: ldr r2, [sp, #0xf8] - cd8: ldr r1, [sp, #0x11c] - cda: ldr r0, [sp, #0x154] - cdc: bl #0xa0 - ce0: mov r1, r0 - ce2: movs r0, #0x1 - ce4: cmp r1, #0x0 - ce6: str r0, [sp, #0xec] - ce8: bne #0x8a - cea: b #-0x2 - cec: ldr r2, [sp, #0x158] - cee: ldr r1, [sp, #0x15c] - cf0: ldr r3, [sp, #0xbc] - cf2: ldr r0, [sp, #0xb4] - cf4: ldr r0, [r0] - cf6: ldr r3, [r3] - cf8: ldr r3, [r3, #0xc] - cfa: blx r3 - cfc: mov r1, r0 - cfe: movs r0, #0x1 - d00: cmp r1, #0x0 - d02: str r0, [sp, #0xec] - d04: bne #0x6e - d06: b #-0x2 - d08: ldr r0, [sp, #0xbc] - d0a: ldr r1, [sp, #0xb4] - d0c: ldr r1, [r1] - d0e: str r1, [sp, #0x14] - d10: ldr r0, [r0] - d12: adds r0, #0x10 - d14: str r0, [sp, #0x18] - d16: movs r0, #0x0 - d18: str r0, [sp, #0x1c] - d1a: b #-0x2 - d1c: ldr r0, [sp, #0x98] - d1e: ldr r1, [sp, #0x1c] - d20: str r1, [sp, #0xc] - d22: cmp r1, r0 - d24: str r0, [sp, #0x10] - d26: beq #0x20 - d28: b #-0x2 - d2a: ldr r3, [sp, #0xc] - d2c: ldr r1, [sp, #0xc0] - d2e: ldr r0, [sp, #0x14] - d30: ldr r2, [sp, #0x18] - d32: adds r3, r3, #0x1 - d34: str r3, [sp, #0x8] - d36: ldr r2, [r2] - d38: blx r2 - d3a: ldr r1, [sp, #0x8] - d3c: mov r2, r0 - d3e: ldr r0, [sp, #0xc] - d40: cmp r2, #0x0 - d42: str r1, [sp, #0x1c] - d44: str r0, [sp, #0x10] - d46: beq #-0x2e - d48: b #-0x2 - d4a: ldr r2, [sp, #0x98] - d4c: ldr r1, [sp, #0x10] - d4e: movs r0, #0x1 - d50: movs r3, #0x0 - d52: str r3, [sp] - d54: cmp r1, r2 - d56: str r0, [sp, #0x4] - d58: blo #0x2 - d5a: ldr r0, [sp] - d5c: str r0, [sp, #0x4] - d5e: ldr r0, [sp, #0x4] - d60: str r0, [sp, #0xec] - d62: b #0x10 - d64: ldr r2, [sp, #0x158] - d66: ldr r1, [sp, #0x15c] - d68: ldr r3, [sp, #0x154] - d6a: ldr r0, [r3, #0x18] - d6c: ldr r3, [r3, #0x1c] - d6e: ldr r3, [r3, #0xc] - d70: blx r3 - d72: str r0, [sp, #0xec] - d74: b #-0x2 - d76: ldr r0, [sp, #0xec] - d78: movs r1, #0x1 - d7a: ands r0, r1 - d7c: add sp, #0x160 - d7e: pop {r4, r5, r7, pc} - -00000d80 : - d80: push {r7, lr} - d82: add r7, sp, #0x0 - d84: sub sp, #0x18 - d86: str r3, [sp, #0x8] - d88: str r2, [sp, #0xc] - d8a: str r1, [sp, #0x10] - d8c: str r0, [sp, #0x14] - d8e: movs r0, #0x11 - d90: lsls r0, r0, #0x10 - d92: cmp r1, r0 - d94: beq #0x18 - d96: b #-0x2 - d98: ldr r1, [sp, #0x10] - d9a: ldr r2, [sp, #0x14] - d9c: ldr r0, [r2, #0x18] - d9e: ldr r2, [r2, #0x1c] - da0: ldr r2, [r2, #0x10] - da2: blx r2 - da4: mov r1, r0 - da6: movs r0, #0x1 - da8: cmp r1, #0x0 - daa: str r0, [sp, #0x4] - dac: bne #0xc - dae: b #-0x2 - db0: ldr r1, [sp, #0xc] - db2: movs r0, #0x0 - db4: cmp r1, #0x0 - db6: str r0, [sp, #0x4] - db8: bne #0xa - dba: b #-0x2 - dbc: ldr r0, [sp, #0x4] - dbe: movs r1, #0x1 - dc0: ands r0, r1 - dc2: add sp, #0x18 - dc4: pop {r7, pc} - dc6: ldr r2, [sp, #0x8] - dc8: ldr r1, [sp, #0xc] - dca: ldr r3, [sp, #0x14] - dcc: ldr r0, [r3, #0x18] - dce: ldr r3, [r3, #0x1c] - dd0: ldr r3, [r3, #0xc] - dd2: blx r3 - dd4: str r0, [sp, #0x4] - dd6: b #-0x1e - -00000dd8 : - dd8: push {r7, lr} - dda: add r7, sp, #0x0 - ddc: sub sp, #0x38 - dde: str r2, [sp] - de0: mov r2, r1 - de2: ldr r1, [sp] - de4: str r2, [sp, #0x4] - de6: mov r2, r0 - de8: ldr r0, [sp, #0x4] - dea: str r2, [sp, #0x8] - dec: str r0, [sp, #0xc] - dee: add r0, sp, #0x8 - df0: str r0, [sp, #0x28] - df2: ldr r0, [pc, #0x24] - df4: str r0, [sp, #0x2c] - df6: add r2, sp, #0xc - df8: str r2, [sp, #0x30] - dfa: str r0, [sp, #0x34] - dfc: ldr r0, [pc, #0x1c] - dfe: str r0, [sp, #0x10] - e00: movs r0, #0x2 - e02: str r0, [sp, #0x14] - e04: movs r2, #0x0 - e06: str r2, [sp, #0x18] - e08: str r2, [sp, #0x1c] - e0a: add r2, sp, #0x28 - e0c: str r2, [sp, #0x20] - e0e: str r0, [sp, #0x24] - e10: add r0, sp, #0x10 - e12: bl #-0x51a - e16: trap - -00000e18 <$d.61>: - e18: b5 07 00 00 .word 0x000007b5 - e1c: 78 20 00 00 .word 0x00002078 - -00000e20 : - e20: push {r7, lr} - e22: add r7, sp, #0x0 - e24: sub sp, #0x28 - e26: str r2, [sp] - e28: mov r2, r1 - e2a: ldr r1, [sp] - e2c: str r2, [sp, #0x4] - e2e: mov r2, r0 - e30: ldr r0, [sp, #0x4] - e32: str r2, [sp, #0x20] - e34: str r0, [sp, #0x24] - e36: add r0, sp, #0x20 - e38: str r0, [sp, #0x8] - e3a: movs r0, #0x1 - e3c: str r0, [sp, #0xc] - e3e: movs r0, #0x0 - e40: str r0, [sp, #0x10] - e42: str r0, [sp, #0x14] - e44: ldr r2, [pc, #0xc] - e46: str r2, [sp, #0x18] - e48: str r0, [sp, #0x1c] - e4a: add r0, sp, #0x8 - e4c: bl #-0x554 - e50: trap - e52: mov r8, r8 - -00000e54 <$d.103>: - e54: ac 1e 00 00 .word 0x00001eac - -00000e58 : - e58: push {r7, lr} - e5a: add r7, sp, #0x0 - e5c: sub sp, #0x8 - e5e: mov r1, r0 - e60: add r0, sp, #0x4 - e62: strb r1, [r0] - e64: ldrb r0, [r0] - e66: str r0, [sp] - e68: ldr r0, [sp] - e6a: lsls r1, r0, #0x2 - e6c: adr r0, #4 - e6e: ldr r0, [r0, r1] - e70: mov pc, r0 - e72: mov r8, r8 - -00000e74 <$d.1465>: - e74: 8b 0e 00 00 .word 0x00000e8b - e78: 97 0e 00 00 .word 0x00000e97 - e7c: 99 0e 00 00 .word 0x00000e99 - e80: 9b 0e 00 00 .word 0x00000e9b - e84: 9d 0e 00 00 .word 0x00000e9d - -00000e88 <$t.1466>: - e88: trap - e8a: ldr r0, [pc, #0x18] - e8c: ldr r2, [pc, #0x18] - e8e: movs r1, #0x32 - e90: bl #-0x74 - e94: trap - e96: b #0x4 <$t.1466+0x16> - e98: b #0x2 <$t.1466+0x16> - e9a: b #0x0 <$t.1466+0x16> - e9c: b #-0x2 <$t.1466+0x16> - e9e: add sp, #0x8 - ea0: pop {r7, pc} - ea2: mov r8, r8 - -00000ea4 <$d.1467>: - ea4: 6c 22 00 00 .word 0x0000226c - ea8: a0 22 00 00 .word 0x000022a0 - -00000eac : - eac: push {r7, lr} - eae: add r7, sp, #0x0 - eb0: sub sp, #0x8 - eb2: b #-0x2 - eb4: add r1, sp, #0x4 - eb6: movs r0, #0x4 - eb8: strb r0, [r1] - eba: ldr r0, [sp, #0x4] - ebc: bl #-0x68 - ec0: b #-0x2 - ec2: b #-0x12 - -00000ec4 <__pre_init>: - ec4: bx lr - -00000ec6 ::as_ptr::ha1620f742e591c34>: - ec6: sub sp, #0x8 - ec8: str r0, [sp] - eca: str r1, [sp, #0x4] - ecc: add sp, #0x8 - ece: bx lr - -00000ed0 ::guaranteed_eq::h0f3980c48e6fad12>: - ed0: sub sp, #0x10 - ed2: str r0, [sp, #0x4] - ed4: str r1, [sp, #0x8] - ed6: subs r0, r0, r1 - ed8: rsbs r1, r0, #0 - eda: adcs r0, r1 - edc: add r1, sp, #0xc - ede: strb r0, [r1] - ee0: ldr r0, [sp, #0xc] - ee2: str r0, [sp] - ee4: b #-0x2 ::guaranteed_eq::h0f3980c48e6fad12+0x16> - ee6: ldr r0, [sp] - ee8: movs r1, #0x1 - eea: ands r0, r1 - eec: add sp, #0x10 - eee: bx lr - -00000ef0 : - ef0: push {r7, lr} - ef2: add r7, sp, #0x0 - ef4: sub sp, #0x10 - ef6: mov r3, r2 - ef8: mov r2, r1 - efa: str r0, [sp, #0x4] - efc: add r1, sp, #0x8 - efe: strb r2, [r1] - f00: str r3, [sp, #0xc] - f02: movs r1, #0x30 - f04: muls r1, r3, r1 - f06: uxtb r2, r2 - f08: bl #0xe06 - f0c: b #-0x2 - f0e: add sp, #0x10 - f10: pop {r7, pc} - -00000f12 : - f12: push {r7, lr} - f14: add r7, sp, #0x0 - f16: sub sp, #0x8 - f18: str r0, [sp, #0x4] - f1a: b #-0x2 - f1c: mov r1, sp - f1e: movs r0, #0x4 - f20: strb r0, [r1] - f22: ldr r0, [sp] - f24: bl #0x4 - f28: b #-0x2 - f2a: b #-0x12 - -00000f2c : - f2c: push {r7, lr} - f2e: add r7, sp, #0x0 - f30: sub sp, #0x8 - f32: mov r1, r0 - f34: add r0, sp, #0x4 - f36: strb r1, [r0] - f38: ldrb r0, [r0] - f3a: str r0, [sp] - f3c: ldr r0, [sp] - f3e: lsls r1, r0, #0x2 - f40: adr r0, #4 - f42: ldr r0, [r0, r1] - f44: mov pc, r0 - f46: mov r8, r8 - -00000f48 <$d.1510>: - f48: 5f 0f 00 00 .word 0x00000f5f - f4c: 6b 0f 00 00 .word 0x00000f6b - f50: 6d 0f 00 00 .word 0x00000f6d - f54: 6f 0f 00 00 .word 0x00000f6f - f58: 71 0f 00 00 .word 0x00000f71 - -00000f5c <$t.1511>: - f5c: trap - f5e: ldr r0, [pc, #0x18] - f60: ldr r2, [pc, #0x18] - f62: movs r1, #0x32 - f64: bl #-0x148 - f68: trap - f6a: b #0x4 <$t.1511+0x16> - f6c: b #0x2 <$t.1511+0x16> - f6e: b #0x0 <$t.1511+0x16> - f70: b #-0x2 <$t.1511+0x16> - f72: add sp, #0x8 - f74: pop {r7, pc} - f76: mov r8, r8 - -00000f78 <$d.1512>: - f78: ff 22 00 00 .word 0x000022ff - f7c: 34 23 00 00 .word 0x00002334 - -00000f80 : - f80: push {r7, lr} - f82: add r7, sp, #0x0 - f84: sub sp, #0x10 - f86: str r1, [sp] - f88: str r0, [sp, #0x8] - f8a: str r1, [sp, #0xc] - f8c: ldr r2, [r1] - f8e: ldr r1, [pc, #0x1c] - f90: blx r2 - f92: b #-0x2 - f94: ldr r1, [sp] - f96: add r2, sp, #0x4 - f98: movs r0, #0x4 - f9a: strb r0, [r2] - f9c: ldr r2, [sp, #0x4] - f9e: ldr r0, [pc, #0x10] - fa0: bl #0x818 - fa4: b #-0x2 - fa6: add sp, #0x10 - fa8: pop {r7, pc} - faa: mov r8, r8 - -00000fac <$d.1520>: - fac: c5 1a 00 00 .word 0x00001ac5 - fb0: 30 04 00 10 .word 0x10000430 - -00000fb4 : - fb4: push {r7, lr} - fb6: add r7, sp, #0x0 - fb8: sub sp, #0x20 - fba: str r1, [sp, #0xc] - fbc: str r0, [sp, #0x14] - fbe: str r1, [sp, #0x18] - fc0: ldr r0, [pc, #0x24] - fc2: str r0, [sp, #0x1c] - fc4: b #-0x2 - fc6: ldr r0, [sp, #0xc] - fc8: str r0, [sp, #0x10] - fca: ldr r0, [sp, #0x10] - fcc: bl #0x2ae - fd0: str r0, [sp, #0x4] - fd2: str r1, [sp, #0x8] - fd4: b #-0x2 - fd6: ldr r2, [sp, #0x8] - fd8: ldr r1, [sp, #0x4] - fda: ldr r0, [pc, #0xc] - fdc: bl #0x9dc - fe0: b #-0x2 - fe2: add sp, #0x20 - fe4: pop {r7, pc} - fe6: mov r8, r8 - -00000fe8 <$d.1522>: - fe8: 34 04 00 10 .word 0x10000434 - -00000fec : - fec: push {r7, lr} - fee: add r7, sp, #0x0 - ff0: sub sp, #0x8 - ff2: str r0, [sp, #0x4] - ff4: ldr r1, [pc, #0x8] - ff6: bl #-0x7a - ffa: b #-0x2 - ffc: add sp, #0x8 - ffe: pop {r7, pc} - -00001000 <$d.1524>: - 1000: 94 23 00 00 .word 0x00002394 - -00001004 : - 1004: push {r7, lr} - 1006: add r7, sp, #0x0 - 1008: sub sp, #0x10 - 100a: str r1, [sp] - 100c: mov r1, r0 - 100e: ldr r0, [sp] - 1010: str r1, [sp, #0x4] - 1012: str r0, [sp, #0x8] - 1014: str r2, [sp, #0xc] - 1016: ldr r1, [r1] - 1018: ldr r0, [r0] - 101a: blx r1 - 101c: b #-0x2 - 101e: add sp, #0x10 - 1020: pop {r7, pc} - -00001022 : - 1022: push {r7, lr} - 1024: add r7, sp, #0x0 - 1026: sub sp, #0x18 - 1028: str r1, [sp, #0x4] - 102a: str r2, [sp, #0x8] - 102c: str r0, [sp, #0x14] - 102e: add r0, sp, #0x8 - 1030: str r0, [sp, #0xc] - 1032: add r0, sp, #0x4 - 1034: str r0, [sp, #0x10] - 1036: ldr r0, [sp, #0xc] - 1038: ldr r1, [sp, #0x10] - 103a: bl #0x6c - 103e: b #-0x2 - 1040: add sp, #0x18 - 1042: pop {r7, pc} - -00001044 : - 1044: sub sp, #0x18 - 1046: str r0, [sp, #0x10] - 1048: str r1, [sp, #0x14] - 104a: str r0, [sp, #0x8] - 104c: str r1, [sp, #0xc] - 104e: ldr r1, [sp, #0x8] - 1050: ldr r0, [sp, #0xc] - 1052: str r1, [sp] - 1054: str r0, [sp, #0x4] - 1056: ldr r0, [sp] - 1058: ldr r1, [sp, #0x4] - 105a: add sp, #0x18 - 105c: bx lr - -0000105e : - 105e: sub sp, #0x10 - 1060: str r0, [sp, #0x8] - 1062: str r1, [sp, #0xc] - 1064: str r0, [sp] - 1066: str r1, [sp, #0x4] - 1068: ldr r0, [sp, #0x4] - 106a: add sp, #0x10 - 106c: bx lr - -0000106e <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E>: - 106e: sub sp, #0xc - 1070: mov r1, r0 - 1072: mov r0, sp - 1074: strb r1, [r0] - 1076: ldrb r0, [r0] - 1078: lsls r0, r0, #0x1f - 107a: cmp r0, #0x0 - 107c: beq #0x4 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x16> - 107e: b #-0x2 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x12> - 1080: b #0x8 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x1e> - 1082: trap - 1084: add r1, sp, #0x4 - 1086: movs r0, #0x1 - 1088: strb r0, [r1] - 108a: b #0x6 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x26> - 108c: add r1, sp, #0x4 - 108e: movs r0, #0x0 - 1090: strb r0, [r1] - 1092: b #-0x2 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x26> - 1094: mov r0, sp - 1096: ldrb r0, [r0] - 1098: lsls r0, r0, #0x1f - 109a: cmp r0, #0x0 - 109c: bne #0x8 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x3a> - 109e: b #-0x2 <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x32> - 10a0: add r0, sp, #0x4 - 10a2: ldrb r0, [r0] - 10a4: add sp, #0xc - 10a6: bx lr - 10a8: b #-0xc <_ZN4core6result19Result$LT$T$C$E$GT$2ok17h1068562803c156f7E+0x32> - -000010aa : - 10aa: push {r7, lr} - 10ac: add r7, sp, #0x0 - 10ae: sub sp, #0x28 - 10b0: str r1, [sp, #0x4] - 10b2: str r0, [sp, #0x8] - 10b4: str r0, [sp, #0x1c] - 10b6: str r1, [sp, #0x20] - 10b8: bl #0x62 - 10bc: mov r1, r0 - 10be: str r1, [sp, #0xc] - 10c0: add r1, sp, #0x24 - 10c2: strb r0, [r1] - 10c4: b #-0x2 - 10c6: bl #0x3c - 10ca: b #-0x2 - 10cc: bl #-0x96c - 10d0: b #-0x2 - 10d2: ldr r1, [sp, #0x4] - 10d4: ldr r0, [sp, #0x8] - 10d6: add r2, sp, #0x14 - 10d8: str r2, [sp, #0x10] - 10da: ldr r2, [sp, #0x10] - 10dc: bl #-0xdc - 10e0: b #-0x2 - 10e2: ldr r0, [sp, #0xc] - 10e4: movs r1, #0x1 - 10e6: ands r0, r1 - 10e8: bl #0x68 - 10ec: str r0, [sp] - 10ee: b #-0x2 - 10f0: ldr r0, [sp] - 10f2: lsls r0, r0, #0x1f - 10f4: cmp r0, #0x0 - 10f6: bne #0x2 - 10f8: b #-0x2 - 10fa: b #0x4 - 10fc: bl #0x12 - 1100: b #-0x2 - 1102: add sp, #0x28 - 1104: pop {r7, pc} - -00001106 : - 1106: push {r7, lr} - 1108: add r7, sp, #0x0 - 110a: bl #0xa8c - 110e: b #-0x2 - 1110: pop {r7, pc} - -00001112 : - 1112: push {r7, lr} - 1114: add r7, sp, #0x0 - 1116: bl #0xa84 - 111a: b #-0x2 - 111c: pop {r7, pc} - -0000111e : - 111e: push {r7, lr} - 1120: add r7, sp, #0x0 - 1122: sub sp, #0x10 - 1124: bl #0xa84 - 1128: mov r1, r0 - 112a: str r1, [sp, #0x4] - 112c: str r0, [sp, #0xc] - 112e: b #-0x2 - 1130: ldr r0, [sp, #0x4] - 1132: lsls r0, r0, #0x1f - 1134: cmp r0, #0x0 - 1136: bne #0x8 - 1138: b #-0x2 - 113a: add r1, sp, #0x8 - 113c: movs r0, #0x0 - 113e: strb r0, [r1] - 1140: b #0x6 - 1142: add r1, sp, #0x8 - 1144: movs r0, #0x1 - 1146: strb r0, [r1] - 1148: b #-0x2 - 114a: add r0, sp, #0x8 - 114c: ldrb r0, [r0] - 114e: add sp, #0x10 - 1150: pop {r7, pc} - 1152: movs r0, r0 - -00001154 : - 1154: push {r7, lr} - 1156: add r7, sp, #0x0 - 1158: sub sp, #0x8 - 115a: mov r1, r0 - 115c: add r0, sp, #0x4 - 115e: strb r1, [r0] - 1160: ldr r1, [pc, #0x10] - 1162: bl #0x12 - 1166: str r0, [sp] - 1168: b #-0x2 - 116a: ldr r0, [sp] - 116c: movs r1, #0x1 - 116e: ands r0, r1 - 1170: add sp, #0x8 - 1172: pop {r7, pc} - -00001174 <$d.1539>: - 1174: 98 23 00 00 .word 0x00002398 - -00001178 <::eq::hda62a8fb7b550211>: - 1178: sub sp, #0x14 - 117a: str r0, [sp, #0x4] - 117c: str r1, [sp, #0x8] - 117e: ldrb r0, [r0] - 1180: str r0, [sp, #0xc] - 1182: ldrb r1, [r1] - 1184: str r1, [sp, #0x10] - 1186: cmp r0, r1 - 1188: beq #0x8 <::eq::hda62a8fb7b550211+0x1c> - 118a: b #-0x2 <::eq::hda62a8fb7b550211+0x14> - 118c: mov r1, sp - 118e: movs r0, #0x0 - 1190: strb r0, [r1] - 1192: b #0x6 <::eq::hda62a8fb7b550211+0x24> - 1194: mov r1, sp - 1196: movs r0, #0x1 - 1198: strb r0, [r1] - 119a: b #-0x2 <::eq::hda62a8fb7b550211+0x24> - 119c: mov r0, sp - 119e: ldrb r0, [r0] - 11a0: add sp, #0x14 - 11a2: bx lr - -000011a4 ::cmp::hcfda16d2cd3e733a>: - 11a4: sub sp, #0x14 - 11a6: str r1, [sp] - 11a8: str r0, [sp, #0x4] - 11aa: str r0, [sp, #0xc] - 11ac: str r1, [sp, #0x10] - 11ae: ldr r0, [r0] - 11b0: ldr r1, [r1] - 11b2: cmp r0, r1 - 11b4: blo #0xe ::cmp::hcfda16d2cd3e733a+0x22> - 11b6: b #-0x2 ::cmp::hcfda16d2cd3e733a+0x14> - 11b8: ldr r1, [sp] - 11ba: ldr r0, [sp, #0x4] - 11bc: ldr r0, [r0] - 11be: ldr r1, [r1] - 11c0: cmp r0, r1 - 11c2: beq #0x16 ::cmp::hcfda16d2cd3e733a+0x38> - 11c4: b #0xc ::cmp::hcfda16d2cd3e733a+0x30> - 11c6: add r1, sp, #0x8 - 11c8: movs r0, #0xff - 11ca: strb r0, [r1] - 11cc: b #-0x2 ::cmp::hcfda16d2cd3e733a+0x2a> - 11ce: ldr r0, [sp, #0x8] - 11d0: add sp, #0x14 - 11d2: bx lr - 11d4: add r1, sp, #0x8 - 11d6: movs r0, #0x1 - 11d8: strb r0, [r1] - 11da: b #0x6 ::cmp::hcfda16d2cd3e733a+0x40> - 11dc: add r1, sp, #0x8 - 11de: movs r0, #0x0 - 11e0: strb r0, [r1] - 11e2: b #-0x2 ::cmp::hcfda16d2cd3e733a+0x40> - 11e4: b #-0x1a ::cmp::hcfda16d2cd3e733a+0x2a> - -000011e6 ::cast::h4944994fe6bd4f89>: - 11e6: sub sp, #0x4 - 11e8: str r0, [sp] - 11ea: add sp, #0x4 - 11ec: bx lr - -000011ee ::len::h321e01cad807760e>: - 11ee: push {r7, lr} - 11f0: add r7, sp, #0x0 - 11f2: sub sp, #0x10 - 11f4: str r0, [sp, #0x8] - 11f6: str r1, [sp, #0xc] - 11f8: bl #-0x19e - 11fc: str r0, [sp, #0x4] - 11fe: b #-0x2 ::len::h321e01cad807760e+0x12> - 1200: ldr r0, [sp, #0x4] - 1202: add sp, #0x10 - 1204: pop {r7, pc} - -00001206 ::as_ptr::hb713d318849bf6be>: - 1206: sub sp, #0x8 - 1208: str r0, [sp] - 120a: str r1, [sp, #0x4] - 120c: add sp, #0x8 - 120e: bx lr - -00001210 <::write_str::h02406515239dbb93>: - 1210: push {r7, lr} - 1212: add r7, sp, #0x0 - 1214: sub sp, #0x30 - 1216: str r0, [sp, #0x14] - 1218: str r1, [sp, #0x18] - 121a: str r2, [sp, #0x1c] - 121c: str r0, [sp, #0x4] - 121e: str r1, [sp, #0x20] - 1220: str r2, [sp, #0x24] - 1222: str r1, [sp, #0x28] - 1224: str r2, [sp, #0x2c] - 1226: ldr r0, [sp, #0x28] - 1228: str r0, [sp, #0x8] - 122a: ldr r0, [sp, #0x2c] - 122c: str r0, [sp, #0xc] - 122e: b #-0x2 <::write_str::h02406515239dbb93+0x20> - 1230: ldr r2, [sp, #0xc] - 1232: ldr r1, [sp, #0x8] - 1234: ldr r0, [sp, #0x4] - 1236: bl #-0xef0 - 123a: b #-0x2 <::write_str::h02406515239dbb93+0x2c> - 123c: add r0, sp, #0x10 - 123e: movs r1, #0x0 - 1240: strb r1, [r0] - 1242: ldrb r0, [r0] - 1244: add sp, #0x30 - 1246: pop {r7, pc} - -00001248 : - 1248: sub sp, #0x8 - 124a: str r0, [sp, #0x4] - 124c: str r0, [sp] - 124e: ldr r0, [sp] - 1250: add sp, #0x8 - 1252: bx lr - -00001254 : - 1254: sub sp, #0x4 - 1256: str r0, [sp] - 1258: ldr r0, [r0] - 125a: add sp, #0x4 - 125c: bx lr - -0000125e : - 125e: push {r7, lr} - 1260: add r7, sp, #0x0 - 1262: sub sp, #0x10 - 1264: str r0, [sp, #0xc] - 1266: bl #-0x16 - 126a: str r0, [sp, #0x8] - 126c: b #-0x2 - 126e: ldr r0, [sp, #0x8] - 1270: bl #-0x1088 - 1274: str r0, [sp, #0x4] - 1276: b #-0x2 - 1278: ldr r0, [sp, #0x4] - 127a: add sp, #0x10 - 127c: pop {r7, pc} - -0000127e : - 127e: sub sp, #0xc - 1280: str r0, [sp, #0x8] - 1282: str r0, [sp] - 1284: mov r1, sp - 1286: movs r0, #0x0 - 1288: strb r0, [r1, #0x4] - 128a: ldr r0, [sp] - 128c: ldr r1, [sp, #0x4] - 128e: add sp, #0xc - 1290: bx lr - 1292: movs r0, r0 - -00001294 : - 1294: push {r4, r6, r7, lr} - 1296: add r7, sp, #0x8 - 1298: sub sp, #0x68 - 129a: str r1, [sp, #0x14] - 129c: mov r1, r0 - 129e: ldr r0, [sp, #0x14] - 12a0: str r1, [sp, #0x18] - 12a2: mov r1, r2 - 12a4: str r1, [sp, #0x1c] - 12a6: str r0, [sp, #0x60] - 12a8: add r1, sp, #0x64 - 12aa: strb r2, [r1] - 12ac: bl #-0x5c - 12b0: str r0, [sp, #0x20] - 12b2: b #-0x2 - 12b4: ldr r1, [sp, #0x20] - 12b6: add r0, sp, #0x24 - 12b8: bl #-0x1056 - 12bc: b #-0x2 - 12be: ldr r0, [sp, #0x1c] - 12c0: ldr r1, [sp, #0x14] - 12c2: ldrb r1, [r1, #0x4] - 12c4: uxtb r0, r0 - 12c6: cmp r0, r1 - 12c8: bne #0x2 - 12ca: b #-0x2 - 12cc: b #0xc6 - 12ce: ldr r0, [sp, #0x14] - 12d0: bl #-0x76 - 12d4: str r0, [sp, #0x34] - 12d6: b #-0x2 - 12d8: ldr r1, [pc, #0xec] - 12da: add r0, sp, #0x34 - 12dc: bl #0xf4 - 12e0: str r0, [sp, #0x10] - 12e2: b #-0x2 - 12e4: ldr r0, [sp, #0x10] - 12e6: lsls r0, r0, #0x1f - 12e8: cmp r0, #0x0 - 12ea: bne #0x6 - 12ec: b #-0x2 - 12ee: ldr r0, [sp, #0x34] - 12f0: str r0, [sp, #0x38] - 12f2: b #0x4 - 12f4: movs r0, #0x0 - 12f6: str r0, [sp, #0x38] - 12f8: b #-0x2 - 12fa: ldr r0, [sp, #0x1c] - 12fc: ldr r1, [sp, #0x38] - 12fe: str r1, [sp, #0x4] - 1300: ldr r1, [pc, #0xc8] - 1302: str r1, [sp, #0x8] - 1304: ldrb r3, [r1, #0xc] - 1306: ldrb r2, [r1, #0xd] - 1308: lsls r2, r2, #0x8 - 130a: adds r3, r2, r3 - 130c: ldrb r4, [r1, #0xe] - 130e: ldrb r2, [r1, #0xf] - 1310: lsls r2, r2, #0x8 - 1312: adds r2, r2, r4 - 1314: lsls r2, r2, #0x10 - 1316: adds r2, r2, r3 - 1318: str r2, [sp, #0x4c] - 131a: ldrb r3, [r1, #0x8] - 131c: ldrb r2, [r1, #0x9] - 131e: lsls r2, r2, #0x8 - 1320: adds r3, r2, r3 - 1322: ldrb r4, [r1, #0xa] - 1324: ldrb r2, [r1, #0xb] - 1326: lsls r2, r2, #0x8 - 1328: adds r2, r2, r4 - 132a: lsls r2, r2, #0x10 - 132c: adds r2, r2, r3 - 132e: str r2, [sp, #0x48] - 1330: ldrb r3, [r1, #0x4] - 1332: ldrb r2, [r1, #0x5] - 1334: lsls r2, r2, #0x8 - 1336: adds r3, r2, r3 - 1338: ldrb r4, [r1, #0x6] - 133a: ldrb r2, [r1, #0x7] - 133c: lsls r2, r2, #0x8 - 133e: adds r2, r2, r4 - 1340: lsls r2, r2, #0x10 - 1342: adds r2, r2, r3 - 1344: str r2, [sp, #0x44] - 1346: ldrb r3, [r1] - 1348: ldrb r2, [r1, #0x1] - 134a: lsls r2, r2, #0x8 - 134c: adds r2, r2, r3 - 134e: ldrb r3, [r1, #0x2] - 1350: ldrb r1, [r1, #0x3] - 1352: lsls r1, r1, #0x8 - 1354: adds r1, r1, r3 - 1356: lsls r1, r1, #0x10 - 1358: adds r1, r1, r2 - 135a: str r1, [sp, #0x40] - 135c: movs r1, #0xf - 135e: ands r0, r1 - 1360: str r0, [sp, #0xc] - 1362: cmp r0, #0xf - 1364: bhi #0x1a - 1366: b #-0x2 - 1368: ldr r1, [sp, #0x4] - 136a: ldr r2, [sp, #0xc] - 136c: add r0, sp, #0x40 - 136e: ldrb r0, [r0, r2] - 1370: add r2, sp, #0x3c - 1372: movs r3, #0xff - 1374: strb r3, [r2] - 1376: strb r0, [r2, #0x1] - 1378: add r0, sp, #0x24 - 137a: movs r3, #0x2 - 137c: bl #-0x1008 - 1380: b #0xa - 1382: ldr r0, [sp, #0xc] - 1384: ldr r2, [pc, #0x48] - 1386: movs r1, #0x10 - 1388: bl #-0xc20 - 138c: trap - 138e: ldr r0, [sp, #0x1c] - 1390: ldr r1, [sp, #0x14] - 1392: strb r0, [r1, #0x4] - 1394: b #-0x2 - 1396: ldr r1, [sp, #0x18] - 1398: ldr r2, [sp, #0x1c] - 139a: ldr r0, [sp, #0x14] - 139c: ldr r3, [sp, #0x30] - 139e: str r3, [sp, #0x5c] - 13a0: ldr r3, [sp, #0x2c] - 13a2: str r3, [sp, #0x58] - 13a4: ldr r3, [sp, #0x28] - 13a6: str r3, [sp, #0x54] - 13a8: ldr r3, [sp, #0x24] - 13aa: str r3, [sp, #0x50] - 13ac: adds r0, r0, #0x4 - 13ae: ldr r3, [sp, #0x5c] - 13b0: str r3, [r1, #0xc] - 13b2: ldr r3, [sp, #0x58] - 13b4: str r3, [r1, #0x8] - 13b6: ldr r3, [sp, #0x54] - 13b8: str r3, [r1, #0x4] - 13ba: ldr r3, [sp, #0x50] - 13bc: str r3, [r1] - 13be: strb r2, [r1, #0x14] - 13c0: str r0, [r1, #0x10] - 13c2: add sp, #0x68 - 13c4: pop {r4, r6, r7, pc} - 13c6: mov r8, r8 - -000013c8 <$d.1570>: - 13c8: c4 21 00 00 .word 0x000021c4 - 13cc: 1c 21 00 00 .word 0x0000211c - 13d0: 9c 23 00 00 .word 0x0000239c - -000013d4 <::eq::h3c8a541bfd9596b3>: - 13d4: sub sp, #0x14 - 13d6: str r0, [sp, #0x4] - 13d8: str r1, [sp, #0x8] - 13da: ldr r0, [r0] - 13dc: str r0, [sp, #0xc] - 13de: ldr r1, [r1] - 13e0: str r1, [sp, #0x10] - 13e2: cmp r0, r1 - 13e4: beq #0x8 <::eq::h3c8a541bfd9596b3+0x1c> - 13e6: b #-0x2 <::eq::h3c8a541bfd9596b3+0x14> - 13e8: mov r1, sp - 13ea: movs r0, #0x0 - 13ec: strb r0, [r1] - 13ee: b #0x6 <::eq::h3c8a541bfd9596b3+0x24> - 13f0: mov r1, sp - 13f2: movs r0, #0x1 - 13f4: strb r0, [r1] - 13f6: b #-0x2 <::eq::h3c8a541bfd9596b3+0x24> - 13f8: mov r0, sp - 13fa: ldrb r0, [r0] - 13fc: add sp, #0x14 - 13fe: bx lr - -00001400 <::drop::hfae1663c98e98fa9>: - 1400: push {r7, lr} - 1402: add r7, sp, #0x0 - 1404: sub sp, #0x10 - 1406: str r0, [sp, #0x4] - 1408: str r0, [sp, #0xc] - 140a: bl #-0xe36 - 140e: str r0, [sp, #0x8] - 1410: b #-0x2 <::drop::hfae1663c98e98fa9+0x12> - 1412: ldr r0, [sp, #0x8] - 1414: lsls r0, r0, #0x1f - 1416: cmp r0, #0x0 - 1418: beq #0x2 <::drop::hfae1663c98e98fa9+0x1e> - 141a: b #-0x2 <::drop::hfae1663c98e98fa9+0x1c> - 141c: b #0x8 <::drop::hfae1663c98e98fa9+0x28> - 141e: ldr r1, [sp, #0x4] - 1420: ldrb r0, [r1, #0x14] - 1422: ldr r1, [r1, #0x10] - 1424: strb r0, [r1] - 1426: b #-0x2 <::drop::hfae1663c98e98fa9+0x28> - 1428: add sp, #0x10 - 142a: pop {r7, pc} - -0000142c < as core::slice::index::SliceIndex<[T]>>::get_unchecked::h0c92a9412d192c5a>: - 142c: push {r7, lr} - 142e: add r7, sp, #0x0 - 1430: sub sp, #0x48 - 1432: str r3, [sp, #0x10] - 1434: str r2, [sp, #0x18] - 1436: mov r2, r1 - 1438: ldr r1, [sp, #0x10] - 143a: str r2, [sp, #0x14] - 143c: mov r3, r0 - 143e: ldr r0, [sp, #0x18] - 1440: str r3, [sp, #0x1c] - 1442: str r3, [sp, #0x24] - 1444: str r2, [sp, #0x28] - 1446: str r0, [sp, #0x2c] - 1448: str r1, [sp, #0x30] - 144a: bl #-0x248 - 144e: str r0, [sp, #0x20] - 1450: b #-0x2 < as core::slice::index::SliceIndex<[T]>>::get_unchecked::h0c92a9412d192c5a+0x26> - 1452: ldr r0, [sp, #0x20] - 1454: ldr r1, [sp, #0x1c] - 1456: str r0, [sp, #0x34] - 1458: str r1, [sp, #0x38] - 145a: str r0, [sp, #0x3c] - 145c: str r1, [sp, #0x40] - 145e: adds r0, r0, r1 - 1460: str r0, [sp, #0x44] - 1462: ldr r0, [sp, #0x44] - 1464: str r0, [sp, #0xc] - 1466: b #-0x2 < as core::slice::index::SliceIndex<[T]>>::get_unchecked::h0c92a9412d192c5a+0x3c> - 1468: ldr r0, [sp, #0xc] - 146a: ldr r1, [sp, #0x14] - 146c: ldr r2, [sp, #0x1c] - 146e: subs r1, r1, r2 - 1470: bl #0x51e - 1474: str r0, [sp, #0x4] - 1476: str r1, [sp, #0x8] - 1478: b #-0x2 < as core::slice::index::SliceIndex<[T]>>::get_unchecked::h0c92a9412d192c5a+0x4e> - 147a: ldr r1, [sp, #0x8] - 147c: ldr r0, [sp, #0x4] - 147e: add sp, #0x48 - 1480: pop {r7, pc} - -00001482 < as core::slice::index::SliceIndex<[T]>>::get_unchecked::hd6fd858cb8e268a6>: - 1482: push {r7, lr} - 1484: add r7, sp, #0x0 - 1486: sub sp, #0x30 - 1488: str r2, [sp, #0xc] - 148a: mov r2, r1 - 148c: ldr r1, [sp, #0xc] - 148e: str r2, [sp, #0x10] - 1490: mov r2, r0 - 1492: ldr r0, [sp, #0x10] - 1494: str r2, [sp, #0x14] - 1496: str r2, [sp, #0x24] - 1498: str r0, [sp, #0x28] - 149a: str r1, [sp, #0x2c] - 149c: bl #-0x2b2 - 14a0: str r0, [sp, #0x18] - 14a2: b #-0x2 < as core::slice::index::SliceIndex<[T]>>::get_unchecked::hd6fd858cb8e268a6+0x22> - 14a4: ldr r3, [sp, #0xc] - 14a6: ldr r2, [sp, #0x10] - 14a8: ldr r0, [sp, #0x18] - 14aa: ldr r1, [sp, #0x14] - 14ac: str r1, [sp, #0x1c] - 14ae: str r0, [sp, #0x20] - 14b0: ldr r0, [sp, #0x1c] - 14b2: ldr r1, [sp, #0x20] - 14b4: bl #-0x8c - 14b8: str r0, [sp, #0x4] - 14ba: str r1, [sp, #0x8] - 14bc: b #-0x2 < as core::slice::index::SliceIndex<[T]>>::get_unchecked::hd6fd858cb8e268a6+0x3c> - 14be: ldr r1, [sp, #0x8] - 14c0: ldr r0, [sp, #0x4] - 14c2: add sp, #0x30 - 14c4: pop {r7, pc} - -000014c6 < as core::slice::index::SliceIndex<[T]>>::index::h0aa7dbaa7b33970c>: - 14c6: push {r7, lr} - 14c8: add r7, sp, #0x0 - 14ca: sub sp, #0x28 - 14cc: str r3, [sp, #0xc] - 14ce: str r2, [sp, #0x10] - 14d0: str r1, [sp, #0x14] - 14d2: str r0, [sp, #0x18] - 14d4: str r0, [sp, #0x1c] - 14d6: str r1, [sp, #0x20] - 14d8: str r2, [sp, #0x24] - 14da: cmp r0, r2 - 14dc: bhi #0x10 < as core::slice::index::SliceIndex<[T]>>::index::h0aa7dbaa7b33970c+0x2a> - 14de: b #-0x2 < as core::slice::index::SliceIndex<[T]>>::index::h0aa7dbaa7b33970c+0x1a> - 14e0: ldr r2, [sp, #0x10] - 14e2: ldr r1, [sp, #0x14] - 14e4: ldr r0, [sp, #0x18] - 14e6: bl #-0x68 - 14ea: str r0, [sp, #0x4] - 14ec: str r1, [sp, #0x8] - 14ee: b #0xa < as core::slice::index::SliceIndex<[T]>>::index::h0aa7dbaa7b33970c+0x36> - 14f0: ldr r2, [sp, #0xc] - 14f2: ldr r1, [sp, #0x10] - 14f4: ldr r0, [sp, #0x18] - 14f6: bl #-0x722 - 14fa: trap - 14fc: ldr r1, [sp, #0x8] - 14fe: ldr r0, [sp, #0x4] - 1500: add sp, #0x28 - 1502: pop {r7, pc} - -00001504 : - 1504: push {r7, lr} - 1506: add r7, sp, #0x0 - 1508: sub sp, #0x18 - 150a: mov r2, r1 - 150c: str r2, [sp, #0x4] - 150e: str r0, [sp, #0xc] - 1510: add r2, sp, #0x10 - 1512: strb r1, [r2] - 1514: mov r1, r0 - 1516: str r1, [sp, #0x8] - 1518: str r0, [sp, #0x14] - 151a: b #-0x2 - 151c: ldr r1, [sp, #0x4] - 151e: ldr r0, [sp, #0x8] - 1520: bl #0xc - 1524: str r0, [sp] - 1526: b #-0x2 - 1528: ldr r0, [sp] - 152a: add sp, #0x18 - 152c: pop {r7, pc} - 152e: movs r0, r0 - -00001530 : - 1530: push {r7, lr} - 1532: add r7, sp, #0x0 - 1534: sub sp, #0x18 - 1536: mov r2, r1 - 1538: mov r1, r0 - 153a: str r1, [sp, #0x4] - 153c: add r0, sp, #0xc - 153e: strb r2, [r0] - 1540: str r1, [sp, #0x14] - 1542: ldrb r0, [r0] - 1544: str r0, [sp, #0x8] - 1546: ldr r0, [sp, #0x8] - 1548: lsls r1, r0, #0x2 - 154a: adr r0, #4 - 154c: ldr r0, [r0, r1] - 154e: mov pc, r0 - -00001550 <$d.1587>: - 1550: 67 15 00 00 .word 0x00001567 - 1554: 6f 15 00 00 .word 0x0000156f - 1558: 7b 15 00 00 .word 0x0000157b - 155c: 87 15 00 00 .word 0x00001587 - 1560: 93 15 00 00 .word 0x00001593 - -00001564 <$t.1588>: - 1564: trap - 1566: ldr r0, [sp, #0x4] - 1568: ldr r0, [r0] - 156a: str r0, [sp, #0x10] - 156c: b #0x38 <$t.1588+0x44> - 156e: ldr r0, [pc, #0x44] - 1570: ldr r2, [pc, #0x44] - 1572: movs r1, #0x28 - 1574: bl #-0x758 - 1578: trap - 157a: ldr r0, [sp, #0x4] - 157c: ldr r0, [r0] - 157e: dmb sy - 1582: str r0, [sp, #0x10] - 1584: b #0x1e <$t.1588+0x42> - 1586: ldr r0, [pc, #0x24] - 1588: ldr r2, [pc, #0x24] - 158a: movs r1, #0x31 - 158c: bl #-0x770 - 1590: trap - 1592: ldr r0, [sp, #0x4] - 1594: ldr r0, [r0] - 1596: dmb sy - 159a: str r0, [sp, #0x10] - 159c: b #-0x2 <$t.1588+0x3a> - 159e: b #-0x2 <$t.1588+0x3c> - 15a0: ldr r0, [sp, #0x10] - 15a2: add sp, #0x18 - 15a4: pop {r7, pc} - 15a6: b #-0xa <$t.1588+0x3c> - 15a8: b #-0xc <$t.1588+0x3c> - 15aa: mov r8, r8 - -000015ac <$d.1589>: - 15ac: 40 24 00 00 .word 0x00002440 - 15b0: 74 24 00 00 .word 0x00002474 - 15b4: 06 24 00 00 .word 0x00002406 - 15b8: 30 24 00 00 .word 0x00002430 - -000015bc : - 15bc: push {r7, lr} - 15be: add r7, sp, #0x0 - 15c0: sub sp, #0x20 - 15c2: str r1, [sp, #0x4] - 15c4: mov r3, r2 - 15c6: str r3, [sp, #0x8] - 15c8: str r0, [sp, #0x10] - 15ca: str r1, [sp, #0x14] - 15cc: add r1, sp, #0x18 - 15ce: strb r2, [r1] - 15d0: mov r1, r0 - 15d2: str r1, [sp, #0xc] - 15d4: str r0, [sp, #0x1c] - 15d6: b #-0x2 - 15d8: ldr r2, [sp, #0x8] - 15da: ldr r1, [sp, #0x4] - 15dc: ldr r0, [sp, #0xc] - 15de: bl #0x6 - 15e2: b #-0x2 - 15e4: add sp, #0x20 - 15e6: pop {r7, pc} - -000015e8 : - 15e8: push {r7, lr} - 15ea: add r7, sp, #0x0 - 15ec: sub sp, #0x18 - 15ee: mov r3, r2 - 15f0: str r1, [sp] - 15f2: mov r2, r0 - 15f4: str r2, [sp, #0x4] - 15f6: add r0, sp, #0xc - 15f8: strb r3, [r0] - 15fa: str r2, [sp, #0x10] - 15fc: str r1, [sp, #0x14] - 15fe: ldrb r0, [r0] - 1600: str r0, [sp, #0x8] - 1602: ldr r0, [sp, #0x8] - 1604: lsls r1, r0, #0x2 - 1606: adr r0, #4 - 1608: ldr r0, [r0, r1] - 160a: mov pc, r0 - -0000160c <$d.1592>: - 160c: 23 16 00 00 .word 0x00001623 - 1610: 2b 16 00 00 .word 0x0000162b - 1614: 37 16 00 00 .word 0x00001637 - 1618: 43 16 00 00 .word 0x00001643 - 161c: 4f 16 00 00 .word 0x0000164f - -00001620 <$t.1593>: - 1620: trap - 1622: ldr r0, [sp] - 1624: ldr r1, [sp, #0x4] - 1626: str r0, [r1] - 1628: b #0x3a <$t.1593+0x46> - 162a: ldr r0, [sp] - 162c: ldr r1, [sp, #0x4] - 162e: dmb sy - 1632: str r0, [r1] - 1634: b #0x2c <$t.1593+0x44> - 1636: ldr r0, [pc, #0x38] - 1638: ldr r2, [pc, #0x38] - 163a: movs r1, #0x2a - 163c: bl #-0x820 - 1640: trap - 1642: ldr r0, [pc, #0x24] - 1644: ldr r2, [pc, #0x24] - 1646: movs r1, #0x32 - 1648: bl #-0x82c - 164c: trap - 164e: ldr r0, [sp] - 1650: ldr r1, [sp, #0x4] - 1652: dmb sy - 1656: str r0, [r1] - 1658: dmb sy - 165c: b #-0x2 <$t.1593+0x3e> - 165e: b #-0x2 <$t.1593+0x40> - 1660: add sp, #0x18 - 1662: pop {r7, pc} - 1664: b #-0x8 <$t.1593+0x40> - 1666: b #-0xa <$t.1593+0x40> - -00001668 <$d.1594>: - 1668: 10 25 00 00 .word 0x00002510 - 166c: 44 25 00 00 .word 0x00002544 - 1670: d3 24 00 00 .word 0x000024d3 - 1674: 00 25 00 00 .word 0x00002500 - -00001678 : - 1678: push {r7, lr} - 167a: add r7, sp, #0x0 - 167c: sub sp, #0x18 - 167e: mov r2, r1 - 1680: mov r1, r0 - 1682: str r1, [sp, #0x4] - 1684: add r0, sp, #0xc - 1686: strb r2, [r0] - 1688: str r1, [sp, #0x14] - 168a: ldrb r0, [r0] - 168c: str r0, [sp, #0x8] - 168e: ldr r0, [sp, #0x8] - 1690: lsls r1, r0, #0x2 - 1692: adr r0, #4 - 1694: ldr r0, [r0, r1] - 1696: mov pc, r0 - -00001698 <$d.1596>: - 1698: af 16 00 00 .word 0x000016af - 169c: b7 16 00 00 .word 0x000016b7 - 16a0: c3 16 00 00 .word 0x000016c3 - 16a4: cf 16 00 00 .word 0x000016cf - 16a8: db 16 00 00 .word 0x000016db - -000016ac <$t.1597>: - 16ac: trap - 16ae: ldr r0, [sp, #0x4] - 16b0: ldr r0, [r0] - 16b2: str r0, [sp, #0x10] - 16b4: b #0x38 <$t.1597+0x44> - 16b6: ldr r0, [pc, #0x44] - 16b8: ldr r2, [pc, #0x44] - 16ba: movs r1, #0x28 - 16bc: bl #-0x8a0 - 16c0: trap - 16c2: ldr r0, [sp, #0x4] - 16c4: ldr r0, [r0] - 16c6: dmb sy - 16ca: str r0, [sp, #0x10] - 16cc: b #0x1e <$t.1597+0x42> - 16ce: ldr r0, [pc, #0x24] - 16d0: ldr r2, [pc, #0x24] - 16d2: movs r1, #0x31 - 16d4: bl #-0x8b8 - 16d8: trap - 16da: ldr r0, [sp, #0x4] - 16dc: ldr r0, [r0] - 16de: dmb sy - 16e2: str r0, [sp, #0x10] - 16e4: b #-0x2 <$t.1597+0x3a> - 16e6: b #-0x2 <$t.1597+0x3c> - 16e8: ldr r0, [sp, #0x10] - 16ea: add sp, #0x18 - 16ec: pop {r7, pc} - 16ee: b #-0xa <$t.1597+0x3c> - 16f0: b #-0xc <$t.1597+0x3c> - 16f2: mov r8, r8 - -000016f4 <$d.1598>: - 16f4: 40 24 00 00 .word 0x00002440 - 16f8: 74 24 00 00 .word 0x00002474 - 16fc: 06 24 00 00 .word 0x00002406 - 1700: 30 24 00 00 .word 0x00002430 - -00001704 : - 1704: push {r7, lr} - 1706: add r7, sp, #0x0 - 1708: sub sp, #0x18 - 170a: mov r3, r2 - 170c: str r1, [sp] - 170e: mov r2, r0 - 1710: str r2, [sp, #0x4] - 1712: add r0, sp, #0xc - 1714: strb r3, [r0] - 1716: str r2, [sp, #0x10] - 1718: str r1, [sp, #0x14] - 171a: ldrb r0, [r0] - 171c: str r0, [sp, #0x8] - 171e: ldr r0, [sp, #0x8] - 1720: lsls r1, r0, #0x2 - 1722: adr r0, #4 - 1724: ldr r0, [r0, r1] - 1726: mov pc, r0 - -00001728 <$d.1600>: - 1728: 3f 17 00 00 .word 0x0000173f - 172c: 47 17 00 00 .word 0x00001747 - 1730: 53 17 00 00 .word 0x00001753 - 1734: 5f 17 00 00 .word 0x0000175f - 1738: 6b 17 00 00 .word 0x0000176b - -0000173c <$t.1601>: - 173c: trap - 173e: ldr r0, [sp] - 1740: ldr r1, [sp, #0x4] - 1742: str r0, [r1] - 1744: b #0x3a <$t.1601+0x46> - 1746: ldr r0, [sp] - 1748: ldr r1, [sp, #0x4] - 174a: dmb sy - 174e: str r0, [r1] - 1750: b #0x2c <$t.1601+0x44> - 1752: ldr r0, [pc, #0x38] - 1754: ldr r2, [pc, #0x38] - 1756: movs r1, #0x2a - 1758: bl #-0x93c - 175c: trap - 175e: ldr r0, [pc, #0x24] - 1760: ldr r2, [pc, #0x24] - 1762: movs r1, #0x32 - 1764: bl #-0x948 - 1768: trap - 176a: ldr r0, [sp] - 176c: ldr r1, [sp, #0x4] - 176e: dmb sy - 1772: str r0, [r1] - 1774: dmb sy - 1778: b #-0x2 <$t.1601+0x3e> - 177a: b #-0x2 <$t.1601+0x40> - 177c: add sp, #0x18 - 177e: pop {r7, pc} - 1780: b #-0x8 <$t.1601+0x40> - 1782: b #-0xa <$t.1601+0x40> - -00001784 <$d.1602>: - 1784: 10 25 00 00 .word 0x00002510 - 1788: 44 25 00 00 .word 0x00002544 - 178c: d3 24 00 00 .word 0x000024d3 - 1790: 00 25 00 00 .word 0x00002500 - -00001794 ::load::hc0f9982edb353ad9>: - 1794: push {r7, lr} - 1796: add r7, sp, #0x0 - 1798: sub sp, #0x18 - 179a: mov r2, r1 - 179c: str r2, [sp, #0x4] - 179e: str r0, [sp, #0xc] - 17a0: add r2, sp, #0x10 - 17a2: strb r1, [r2] - 17a4: str r0, [sp, #0x14] - 17a6: str r0, [sp, #0x8] - 17a8: b #-0x2 ::load::hc0f9982edb353ad9+0x16> - 17aa: ldr r1, [sp, #0x4] - 17ac: ldr r0, [sp, #0x8] - 17ae: bl #-0x13a - 17b2: str r0, [sp] - 17b4: b #-0x2 ::load::hc0f9982edb353ad9+0x22> - 17b6: ldr r0, [sp] - 17b8: add sp, #0x18 - 17ba: pop {r7, pc} - -000017bc ::store::hdd3a69388fba2090>: - 17bc: push {r7, lr} - 17be: add r7, sp, #0x0 - 17c0: sub sp, #0x20 - 17c2: str r1, [sp, #0x4] - 17c4: mov r3, r2 - 17c6: str r3, [sp, #0x8] - 17c8: str r0, [sp, #0x10] - 17ca: str r1, [sp, #0x14] - 17cc: add r1, sp, #0x18 - 17ce: strb r2, [r1] - 17d0: str r0, [sp, #0x1c] - 17d2: str r0, [sp, #0xc] - 17d4: b #-0x2 ::store::hdd3a69388fba2090+0x1a> - 17d6: ldr r2, [sp, #0x8] - 17d8: ldr r1, [sp, #0x4] - 17da: ldr r0, [sp, #0xc] - 17dc: bl #-0xdc - 17e0: b #-0x2 ::store::hdd3a69388fba2090+0x26> - 17e2: add sp, #0x20 - 17e4: pop {r7, pc} - 17e6: movs r0, r0 - -000017e8 : - 17e8: push {r7, lr} - 17ea: add r7, sp, #0x0 - 17ec: sub sp, #0x8 - 17ee: mov r1, r0 - 17f0: add r0, sp, #0x4 - 17f2: strb r1, [r0] - 17f4: ldrb r0, [r0] - 17f6: str r0, [sp] - 17f8: ldr r0, [sp] - 17fa: lsls r1, r0, #0x2 - 17fc: adr r0, #4 - 17fe: ldr r0, [r0, r1] - 1800: mov pc, r0 - 1802: mov r8, r8 - -00001804 <$d.1606>: - 1804: 1b 18 00 00 .word 0x0000181b - 1808: 27 18 00 00 .word 0x00001827 - 180c: 2d 18 00 00 .word 0x0000182d - 1810: 33 18 00 00 .word 0x00001833 - 1814: 39 18 00 00 .word 0x00001839 - -00001818 <$t.1607>: - 1818: trap - 181a: ldr r0, [pc, #0x28] - 181c: ldr r2, [pc, #0x28] - 181e: movs r1, #0x29 - 1820: bl #-0xa04 - 1824: trap - 1826: dmb sy - 182a: b #0x10 <$t.1607+0x26> - 182c: dmb sy - 1830: b #0xa <$t.1607+0x26> - 1832: dmb sy - 1836: b #0x4 <$t.1607+0x26> - 1838: dmb sy - 183c: b #-0x2 <$t.1607+0x26> - 183e: add sp, #0x8 - 1840: pop {r7, pc} - 1842: mov r8, r8 - -00001844 <$d.1608>: - 1844: 54 25 00 00 .word 0x00002554 - 1848: 80 25 00 00 .word 0x00002580 - -0000184c : - 184c: push {r4, r5, r6, r7, lr} - 184e: add r7, sp, #0xc - 1850: sub sp, #0x4c - 1852: str r0, [sp, #0x38] - 1854: str r1, [sp, #0x3c] - 1856: mov r0, r1 - 1858: str r0, [sp, #0x4] - 185a: str r1, [sp, #0x40] - 185c: ldr r0, [pc, #0x30] - 185e: str r0, [sp, #0x48] - 1860: b #-0x2 - 1862: ldr r0, [sp, #0x4] - 1864: ldr r1, [pc, #0x28] - 1866: str r1, [sp, #0x44] - 1868: adds r2, r0, #0x4 - 186a: str r2, [sp] - 186c: ldrb r2, [r0] - 186e: add r0, sp, #0x20 - 1870: bl #-0x5e0 - 1874: b #-0x2 - 1876: ldr r0, [sp] - 1878: add r3, sp, #0x20 - 187a: add r1, sp, #0x8 - 187c: mov r2, r1 - 187e: ldm r3!, {r4, r5, r6} - 1880: stm r2!, {r4, r5, r6} - 1882: ldm r3!, {r4, r5, r6} - 1884: stm r2!, {r4, r5, r6} - 1886: bl #0xa - 188a: b #-0x2 - 188c: add sp, #0x4c - 188e: pop {r4, r5, r6, r7, pc} - -00001890 <$d.1610>: - 1890: 34 04 00 10 .word 0x10000434 - -00001894 : - 1894: push {r7, lr} - 1896: add r7, sp, #0x0 - 1898: sub sp, #0x10 - 189a: str r1, [sp, #0x4] - 189c: mov r1, r0 - 189e: ldr r0, [sp, #0x4] - 18a0: str r1, [sp, #0xc] - 18a2: ldr r2, [r1] - 18a4: ldr r1, [r2] - 18a6: ldr r2, [r2, #0x4] - 18a8: bl #-0x69c - 18ac: str r0, [sp, #0x8] - 18ae: b #-0x2 - 18b0: ldr r0, [sp, #0x8] - 18b2: movs r1, #0x1 - 18b4: ands r0, r1 - 18b6: bl #-0x84c - 18ba: b #-0x2 - 18bc: ldr r0, [sp, #0x4] - 18be: bl #0x26a - 18c2: b #-0x2 - 18c4: add sp, #0x10 - 18c6: pop {r7, pc} - -000018c8 : - 18c8: push {r7, lr} - 18ca: add r7, sp, #0x0 - 18cc: sub sp, #0x10 - 18ce: str r1, [sp] - 18d0: str r2, [sp, #0x4] - 18d2: add r1, sp, #0xc - 18d4: strb r0, [r1] - 18d6: mov r1, sp - 18d8: str r1, [sp, #0x8] - 18da: ldr r1, [sp, #0x8] - 18dc: bl #0x8 - 18e0: b #-0x2 - 18e2: add sp, #0x10 - 18e4: pop {r7, pc} - 18e6: movs r0, r0 - -000018e8 : - 18e8: push {r4, r6, r7, lr} - 18ea: add r7, sp, #0x8 - 18ec: sub sp, #0x30 - 18ee: str r1, [sp, #0x8] - 18f0: mov r2, r0 - 18f2: str r2, [sp, #0xc] - 18f4: add r2, sp, #0x24 - 18f6: strb r0, [r2] - 18f8: str r1, [sp, #0x28] - 18fa: add r1, sp, #0x20 - 18fc: movs r0, #0x0 - 18fe: strb r0, [r1] - 1900: movs r0, #0x1 - 1902: strb r0, [r1] - 1904: add r1, sp, #0x14 - 1906: movs r0, #0x4 - 1908: strb r0, [r1] - 190a: ldr r1, [sp, #0x14] - 190c: ldr r0, [pc, #0x50] - 190e: bl #-0x17e - 1912: mov r1, r0 - 1914: str r1, [sp, #0x10] - 1916: str r0, [sp, #0x2c] - 1918: b #-0x2 - 191a: ldr r0, [sp, #0x10] - 191c: bl #0x23a - 1920: str r0, [sp, #0x4] - 1922: b #-0x2 - 1924: ldr r0, [sp, #0x4] - 1926: lsls r0, r0, #0x1f - 1928: cmp r0, #0x0 - 192a: beq #0x2 - 192c: b #-0x2 - 192e: b #0x1a - 1930: ldr r1, [sp, #0x10] - 1932: ldr r2, [sp, #0x8] - 1934: ldr r3, [sp, #0xc] - 1936: add r4, sp, #0x20 - 1938: movs r0, #0x0 - 193a: strb r0, [r4] - 193c: add r0, sp, #0x18 - 193e: strb r3, [r0] - 1940: str r2, [sp, #0x1c] - 1942: ldr r2, [r1] - 1944: ldr r1, [pc, #0x1c] - 1946: blx r2 - 1948: b #-0x2 - 194a: b #-0x2 - 194c: add r0, sp, #0x20 - 194e: ldrb r0, [r0] - 1950: lsls r0, r0, #0x1f - 1952: cmp r0, #0x0 - 1954: bne #0x4 - 1956: b #-0x2 - 1958: add sp, #0x30 - 195a: pop {r4, r6, r7, pc} - 195c: b #-0x8 - 195e: mov r8, r8 - -00001960 <$d.1617>: - 1960: 30 04 00 10 .word 0x10000430 - 1964: f9 1a 00 00 .word 0x00001af9 - -00001968 : - 1968: sub sp, #0x8 - 196a: str r0, [sp] - 196c: str r1, [sp, #0x4] - 196e: str r1, [r0] - 1970: b #-0x2 - 1972: add sp, #0x8 - 1974: bx lr - -00001976 : - 1976: sub sp, #0x8 - 1978: str r0, [sp] - 197a: str r1, [sp, #0x4] - 197c: str r1, [r0] - 197e: b #-0x2 - 1980: add sp, #0x8 - 1982: bx lr - -00001984 : - 1984: sub sp, #0x8 - 1986: str r0, [sp] - 1988: str r1, [sp, #0x4] - 198a: str r1, [r0] - 198c: b #-0x2 - 198e: add sp, #0x8 - 1990: bx lr - -00001992 : - 1992: push {r7, lr} - 1994: add r7, sp, #0x0 - 1996: sub sp, #0x18 - 1998: str r1, [sp, #0x8] - 199a: str r0, [sp, #0x10] - 199c: str r1, [sp, #0x14] - 199e: bl #-0x7bc - 19a2: str r0, [sp, #0xc] - 19a4: b #-0x2 - 19a6: ldr r1, [sp, #0x8] - 19a8: ldr r0, [sp, #0xc] - 19aa: bl #-0x96a - 19ae: str r0, [sp] - 19b0: str r1, [sp, #0x4] - 19b2: b #-0x2 - 19b4: ldr r1, [sp, #0x4] - 19b6: ldr r0, [sp] - 19b8: add sp, #0x18 - 19ba: pop {r7, pc} - -000019bc : - 19bc: sub sp, #0x10 - 19be: str r1, [sp] - 19c0: mov r1, r0 - 19c2: ldr r0, [sp] - 19c4: str r0, [sp, #0x4] - 19c6: add r0, sp, #0x4 - 19c8: strb r2, [r0, #0x4] - 19ca: str r1, [sp, #0xc] - 19cc: ldr r0, [sp, #0x8] - 19ce: str r0, [r1, #0x4] - 19d0: ldr r0, [sp, #0x4] - 19d2: str r0, [r1] - 19d4: add sp, #0x10 - 19d6: bx lr - -000019d8 : - 19d8: push {r7, lr} - 19da: add r7, sp, #0x0 - 19dc: sub sp, #0x10 - 19de: str r0, [sp, #0x8] - 19e0: str r1, [sp, #0xc] - 19e2: bl #0xa - 19e6: str r0, [sp, #0x4] - 19e8: b #-0x2 - 19ea: ldr r0, [sp, #0x4] - 19ec: add sp, #0x10 - 19ee: pop {r7, pc} - -000019f0 : - 19f0: push {r7, lr} - 19f2: add r7, sp, #0x0 - 19f4: sub sp, #0x28 - 19f6: str r0, [sp, #0x4] - 19f8: str r1, [sp, #0x8] - 19fa: add r2, sp, #0x20 - 19fc: movs r0, #0x0 - 19fe: strb r0, [r2] - 1a00: add r1, sp, #0x1c - 1a02: strb r0, [r1] - 1a04: movs r0, #0x1 - 1a06: strb r0, [r2] - 1a08: strb r0, [r1] - 1a0a: add r0, sp, #0x4 - 1a0c: str r0, [sp, #0x14] - 1a0e: add r0, sp, #0x8 - 1a10: str r0, [sp, #0x18] - 1a12: ldr r0, [sp, #0x14] - 1a14: ldr r1, [sp, #0x18] - 1a16: bl #0xc2 - 1a1a: add r1, sp, #0x10 - 1a1c: strb r0, [r1] - 1a1e: b #-0x2 - 1a20: add r0, sp, #0x10 - 1a22: ldrb r0, [r0] - 1a24: sxtb r0, r0 - 1a26: adds r0, r0, #0x1 - 1a28: cmp r0, #0x2 - 1a2a: blo #0x4 - 1a2c: b #-0x2 - 1a2e: b #0xc - 1a30: trap - 1a32: add r1, sp, #0x20 - 1a34: movs r0, #0x0 - 1a36: strb r0, [r1] - 1a38: ldr r0, [sp, #0x4] - 1a3a: str r0, [sp, #0xc] - 1a3c: b #0xa - 1a3e: add r1, sp, #0x1c - 1a40: movs r0, #0x0 - 1a42: strb r0, [r1] - 1a44: ldr r0, [sp, #0x8] - 1a46: str r0, [sp, #0xc] - 1a48: b #-0x2 - 1a4a: add r0, sp, #0x1c - 1a4c: ldrb r0, [r0] - 1a4e: lsls r0, r0, #0x1f - 1a50: cmp r0, #0x0 - 1a52: bne #0xc - 1a54: b #-0x2 - 1a56: add r0, sp, #0x20 - 1a58: ldrb r0, [r0] - 1a5a: lsls r0, r0, #0x1f - 1a5c: cmp r0, #0x0 - 1a5e: bne #0x8 - 1a60: b #0x0 - 1a62: b #-0x10 - 1a64: ldr r0, [sp, #0xc] - 1a66: add sp, #0x28 - 1a68: pop {r7, pc} - 1a6a: b #-0xa - -00001a6c : - 1a6c: push {r7, lr} - 1a6e: add r7, sp, #0x0 - 1a70: sub sp, #0x10 - 1a72: str r0, [sp, #0x8] - 1a74: str r1, [sp, #0xc] - 1a76: bl #-0xa2 - 1a7a: str r0, [sp, #0x4] - 1a7c: b #-0x2 - 1a7e: ldr r0, [sp, #0x4] - 1a80: add sp, #0x10 - 1a82: pop {r7, pc} - -00001a84 for [T]>::index::h86947429ae1348be>: - 1a84: push {r7, lr} - 1a86: add r7, sp, #0x0 - 1a88: sub sp, #0x18 - 1a8a: str r2, [sp] - 1a8c: mov r2, r1 - 1a8e: mov r1, r0 - 1a90: ldr r0, [sp] - 1a92: str r1, [sp, #0xc] - 1a94: str r2, [sp, #0x10] - 1a96: str r0, [sp, #0x14] - 1a98: bl #-0x5d6 - 1a9c: str r0, [sp, #0x4] - 1a9e: str r1, [sp, #0x8] - 1aa0: b #-0x2 for [T]>::index::h86947429ae1348be+0x1e> - 1aa2: ldr r1, [sp, #0x8] - 1aa4: ldr r0, [sp, #0x4] - 1aa6: add sp, #0x18 - 1aa8: pop {r7, pc} - -00001aaa : - 1aaa: push {r7, lr} - 1aac: add r7, sp, #0x0 - 1aae: sub sp, #0x10 - 1ab0: str r1, [sp] - 1ab2: mov r1, r0 - 1ab4: ldr r0, [sp] - 1ab6: str r1, [sp, #0x4] - 1ab8: str r0, [sp, #0x8] - 1aba: str r2, [sp, #0xc] - 1abc: bl #0x238 - 1ac0: add sp, #0x10 - 1ac2: pop {r7, pc} - -00001ac4 : - 1ac4: push {r7, lr} - 1ac6: add r7, sp, #0x0 - 1ac8: sub sp, #0x8 - 1aca: str r0, [sp, #0x4] - 1acc: ldr r1, [sp, #0x4] - 1ace: mov r0, sp - 1ad0: bl #-0xb20 - 1ad4: b #-0x2 - 1ad6: b #-0x2 - 1ad8: add sp, #0x8 - 1ada: pop {r7, pc} - -00001adc : - 1adc: push {r7, lr} - 1ade: add r7, sp, #0x0 - 1ae0: sub sp, #0x10 - 1ae2: str r0, [sp, #0x4] - 1ae4: str r1, [sp, #0x8] - 1ae6: ldr r0, [sp, #0x4] - 1ae8: ldr r1, [sp, #0x8] - 1aea: bl #-0x94a - 1aee: str r0, [sp] - 1af0: b #-0x2 - 1af2: ldr r0, [sp] - 1af4: add sp, #0x10 - 1af6: pop {r7, pc} - -00001af8 : - 1af8: push {r7, lr} - 1afa: add r7, sp, #0x0 - 1afc: sub sp, #0x8 - 1afe: str r0, [sp, #0x4] - 1b00: ldr r1, [sp, #0x4] - 1b02: mov r0, sp - 1b04: bl #-0x2bc - 1b08: b #-0x2 - 1b0a: b #-0x2 - 1b0c: add sp, #0x8 - 1b0e: pop {r7, pc} - -00001b10 : - 1b10: push {r7, lr} - 1b12: add r7, sp, #0x0 - 1b14: sub sp, #0x10 - 1b16: str r0, [sp, #0x8] - 1b18: str r1, [sp, #0xc] - 1b1a: ldr r1, [sp, #0x8] - 1b1c: ldr r2, [sp, #0xc] - 1b1e: add r0, sp, #0x4 - 1b20: bl #-0xb02 - 1b24: b #-0x2 - 1b26: b #-0x2 - 1b28: add sp, #0x10 - 1b2a: pop {r7, pc} - -00001b2c ::ha4649676972818ec>: - 1b2c: push {r7, lr} - 1b2e: add r7, sp, #0x0 - 1b30: sub sp, #0x8 - 1b32: str r0, [sp] - 1b34: str r0, [sp, #0x4] - 1b36: bl #-0x73a - 1b3a: b #-0x2 ::ha4649676972818ec+0x10> - 1b3c: ldr r0, [sp] - 1b3e: bl #0x6 - 1b42: b #-0x2 ::ha4649676972818ec+0x18> - 1b44: add sp, #0x8 - 1b46: pop {r7, pc} - -00001b48 ::heb3a81130ff82566>: - 1b48: push {r7, lr} - 1b4a: add r7, sp, #0x0 - 1b4c: sub sp, #0x8 - 1b4e: str r0, [sp, #0x4] - 1b50: bl #-0x1518 - 1b54: b #-0x2 ::heb3a81130ff82566+0xe> - 1b56: add sp, #0x8 - 1b58: pop {r7, pc} - -00001b5a ::is_null::h2a01a490030b8614>: - 1b5a: push {r7, lr} - 1b5c: add r7, sp, #0x0 - 1b5e: sub sp, #0x10 - 1b60: str r0, [sp, #0xc] - 1b62: str r0, [sp, #0x8] - 1b64: b #-0x2 ::is_null::h2a01a490030b8614+0xc> - 1b66: ldr r0, [sp, #0x8] - 1b68: movs r1, #0x0 - 1b6a: bl #-0xc9e - 1b6e: str r0, [sp, #0x4] - 1b70: b #-0x2 ::is_null::h2a01a490030b8614+0x18> - 1b72: ldr r0, [sp, #0x4] - 1b74: movs r1, #0x1 - 1b76: ands r0, r1 - 1b78: add sp, #0x10 - 1b7a: pop {r7, pc} - -00001b7c ::as_mut_ptr::h1268a525c0d17097>: - 1b7c: sub sp, #0x8 - 1b7e: str r0, [sp] - 1b80: str r1, [sp, #0x4] - 1b82: add sp, #0x8 - 1b84: bx lr - -00001b86 ::is_empty::h1c258da3c1db0ddb>: - 1b86: sub sp, #0xc - 1b88: str r1, [sp] - 1b8a: mov r1, r0 - 1b8c: ldr r0, [sp] - 1b8e: str r1, [sp, #0x4] - 1b90: str r0, [sp, #0x8] - 1b92: rsbs r1, r0, #0 - 1b94: adcs r0, r1 - 1b96: add sp, #0xc - 1b98: bx lr - -00001b9a <__cpsid>: - 1b9a: cpsid i - 1b9c: bx lr - -00001b9e <__cpsie>: - 1b9e: cpsie i - 1ba0: bx lr - -00001ba2 <__delay>: - 1ba2: lsrs r0, r0, #0x1 - 1ba4: adds r0, r0, #0x1 - 1ba6: subs r0, #0x1 - 1ba8: bne #-0x6 <__delay+0x4> - 1baa: bx lr - -00001bac <__primask_r>: - 1bac: mrs r0, primask - 1bb0: bx lr - -00001bb2 <__aeabi_uidiv>: - 1bb2: push {r7, lr} - 1bb4: add r7, sp, #0x0 - 1bb6: bl #0x2 - 1bba: pop {r7, pc} - -00001bbc : - 1bbc: push {r4, r5, r6, r7, lr} - 1bbe: add r7, sp, #0xc - 1bc0: sub sp, #0xc - 1bc2: mov r2, r0 - 1bc4: cmp r0, r1 - 1bc6: bhs #0x6 - 1bc8: movs r0, #0x0 - 1bca: mov r1, r2 - 1bcc: add sp, #0xc - 1bce: pop {r4, r5, r6, r7, pc} - 1bd0: lsrs r5, r2, #0x10 - 1bd2: cmp r1, r5 - 1bd4: mov r0, r2 - 1bd6: bls #0x72 - 1bd8: lsrs r6, r0, #0x8 - 1bda: cmp r1, r6 - 1bdc: bls #0x74 - 1bde: lsrs r3, r0, #0x4 - 1be0: cmp r1, r3 - 1be2: bls #0x76 - 1be4: str r3, [sp, #0x4] - 1be6: lsrs r3, r0, #0x2 - 1be8: cmp r1, r3 - 1bea: bhi #0x0 - 1bec: mov r0, r3 - 1bee: str r3, [sp, #0x8] - 1bf0: lsrs r3, r0, #0x1 - 1bf2: movs r4, #0x1 - 1bf4: movs r0, #0x0 - 1bf6: cmp r1, r3 - 1bf8: mov r3, r4 - 1bfa: bls #0x0 - 1bfc: mov r3, r0 - 1bfe: cmp r1, r5 - 1c00: mov r5, r4 - 1c02: bls #0x0 - 1c04: mov r5, r0 - 1c06: str r3, [sp] - 1c08: lsls r5, r5, #0x4 - 1c0a: cmp r1, r6 - 1c0c: mov r6, r4 - 1c0e: bls #0x0 - 1c10: mov r6, r0 - 1c12: lsls r3, r6, #0x3 - 1c14: adds r5, r3, r5 - 1c16: ldr r3, [sp, #0x4] - 1c18: cmp r1, r3 - 1c1a: mov r3, r4 - 1c1c: bls #0x0 - 1c1e: mov r3, r0 - 1c20: lsls r3, r3, #0x2 - 1c22: adds r3, r5, r3 - 1c24: ldr r5, [sp, #0x8] - 1c26: cmp r1, r5 - 1c28: mov r5, r4 - 1c2a: bls #0x0 - 1c2c: mov r5, r0 - 1c2e: lsls r0, r5, #0x1 - 1c30: adds r0, r3, r0 - 1c32: ldr r3, [sp] - 1c34: adds r3, r0, r3 - 1c36: lsls r4, r3 - 1c38: mov r5, r1 - 1c3a: lsls r5, r3 - 1c3c: subs r6, r2, r5 - 1c3e: cmp r6, r1 - 1c40: bhs #0x24 - 1c42: mov r2, r6 - 1c44: mov r0, r4 - 1c46: mov r1, r2 - 1c48: add sp, #0xc - 1c4a: pop {r4, r5, r6, r7, pc} - 1c4c: mov r0, r5 - 1c4e: lsrs r6, r0, #0x8 - 1c50: cmp r1, r6 - 1c52: bhi #-0x78 - 1c54: mov r0, r6 - 1c56: lsrs r3, r0, #0x4 - 1c58: cmp r1, r3 - 1c5a: bhi #-0x7a - 1c5c: mov r0, r3 - 1c5e: str r3, [sp, #0x4] - 1c60: lsrs r3, r0, #0x2 - 1c62: cmp r1, r3 - 1c64: bls #-0x7c - 1c66: b #-0x7c - 1c68: cmp r5, #0x0 - 1c6a: bmi #0x6 - 1c6c: mov r1, r4 - 1c6e: mov r0, r4 - 1c70: mov r2, r6 - 1c72: b #0x2a - 1c74: lsrs r5, r5, #0x1 - 1c76: subs r2, r6, r5 - 1c78: subs r3, r3, #0x1 - 1c7a: movs r0, #0x1f - 1c7c: str r3, [sp, #0x4] - 1c7e: ands r0, r3 - 1c80: str r0, [sp, #0x8] - 1c82: movs r0, #0x1 - 1c84: ldr r3, [sp, #0x8] - 1c86: lsls r0, r3 - 1c88: cmp r2, #0x0 - 1c8a: str r0, [sp, #0x8] - 1c8c: bge #0x0 - 1c8e: movs r0, #0x0 - 1c90: cmp r2, #0x0 - 1c92: bge #0x0 - 1c94: mov r2, r6 - 1c96: orrs r0, r4 - 1c98: cmp r2, r1 - 1c9a: ldr r1, [sp, #0x8] - 1c9c: ldr r3, [sp, #0x4] - 1c9e: blo #-0xd8 - 1ca0: subs r1, r1, #0x1 - 1ca2: cmp r3, #0x0 - 1ca4: beq #0x14 - 1ca6: subs r5, r5, #0x1 - 1ca8: mov r4, r2 - 1caa: mov r2, r3 - 1cac: lsls r4, r4, #0x1 - 1cae: subs r4, r4, r5 - 1cb0: asrs r6, r4, #0x1f - 1cb2: ands r6, r5 - 1cb4: adds r4, r6, r4 - 1cb6: subs r2, r2, #0x1 - 1cb8: bne #-0x10 - 1cba: b #0x0 - 1cbc: mov r4, r2 - 1cbe: movs r2, #0x1f - 1cc0: ands r3, r2 - 1cc2: mov r2, r4 - 1cc4: lsrs r2, r3 - 1cc6: ands r1, r4 - 1cc8: orrs r0, r1 - 1cca: mov r1, r2 - 1ccc: add sp, #0xc - 1cce: pop {r4, r5, r6, r7, pc} - -00001cd0 : - 1cd0: push {r4, r6, r7, lr} - 1cd2: add r7, sp, #0x8 - 1cd4: cmp r2, #0x0 - 1cd6: beq #0xc - 1cd8: mov r3, r0 - 1cda: ldrb r4, [r1] - 1cdc: strb r4, [r3] - 1cde: adds r1, r1, #0x1 - 1ce0: adds r3, r3, #0x1 - 1ce2: subs r2, r2, #0x1 - 1ce4: bne #-0xe - 1ce6: pop {r4, r6, r7, pc} - -00001ce8 : - 1ce8: cmp r2, #0x0 - 1cea: beq #0x8 - 1cec: mov r3, r0 - 1cee: strb r1, [r3] - 1cf0: adds r3, r3, #0x1 - 1cf2: subs r2, r2, #0x1 - 1cf4: bne #-0xa - 1cf6: bx lr - -00001cf8 <__aeabi_memcpy>: - 1cf8: push {r7, lr} - 1cfa: add r7, sp, #0x0 - 1cfc: bl #-0x30 - 1d00: pop {r7, pc} - -00001d02 <__aeabi_memset>: - 1d02: push {r7, lr} - 1d04: add r7, sp, #0x0 - 1d06: mov r3, r1 - 1d08: mov r1, r2 - 1d0a: mov r2, r3 - 1d0c: bl #-0x28 - 1d10: pop {r7, pc} - -00001d12 <__aeabi_memset4>: - 1d12: push {r4, r6, r7, lr} - 1d14: add r7, sp, #0x8 - 1d16: mov r3, r2 - 1d18: uxtb r2, r2 - 1d1a: cmp r1, #0x4 - 1d1c: blo #0x12 <__aeabi_memset4+0x20> - 1d1e: lsls r3, r3, #0x18 - 1d20: adds r3, r2, r3 - 1d22: lsls r4, r2, #0x10 - 1d24: adds r3, r3, r4 - 1d26: lsls r4, r2, #0x8 - 1d28: adds r3, r3, r4 - 1d2a: stm r0!, {r3} - 1d2c: subs r1, r1, #0x4 - 1d2e: cmp r1, #0x3 - 1d30: bhi #-0xa <__aeabi_memset4+0x18> - 1d32: bl #-0x34 - 1d36: pop {r4, r6, r7, pc} - -00001d38 : - 1d38: mov r0, lr - 1d3a: movs r1, #0x4 - 1d3c: tst r0, r1 - 1d3e: bne #0x4 - 1d40: mrs r0, msp - 1d44: b #0x4 - 1d46: mrs r0, psp - 1d4a: b #-0x2 - -00001d4c : - 1d4c: push {r7, lr} - 1d4e: add r7, sp, #0x0 - 1d50: sub sp, #0x8 - 1d52: str r0, [sp, #0x4] - 1d54: b #-0x2 - 1d56: mov r1, sp - 1d58: movs r0, #0x4 - 1d5a: strb r0, [r1] - 1d5c: ldr r0, [sp] - 1d5e: bl #-0xf0a - 1d62: b #-0x2 - 1d64: b #-0x12 - 1d66: movs r0, r0 diff --git a/va108xx-hal-rs b/va108xx-hal-rs index 2fc9829..f13af5d 160000 --- a/va108xx-hal-rs +++ b/va108xx-hal-rs @@ -1 +1 @@ -Subproject commit 2fc982996138216e9c060772481aba53a711dc9b +Subproject commit f13af5d32bfad661bcf985948eac36f885d9ddaf diff --git a/vorago-reb1-rs b/vorago-reb1-rs index 448b18c..eb7b036 160000 --- a/vorago-reb1-rs +++ b/vorago-reb1-rs @@ -1 +1 @@ -Subproject commit 448b18c9ed17e43b781f317962d3133322aa98a6 +Subproject commit eb7b036377cb194935c472c7a5bbb0196f52e8fe