/// Changes the resolution for all analog pins
/// 
/// Possible values are 6, 8, 10 and 12 bit resolutions. 10 bits are the default.
/// Panics if resolution value is invalid.
Changes the resolution for all analog pins
Possible values are 6, 8, 10 and 12 bit resolutions. 10 bits are the default.
Panics if resolution value is invalid.
Changes the resolution for all analog pins Possible values are 6 8 10 and 12 bit resolutions . 10 bits are the default . Panics if resolution value is invalid .
pub fn adc_resolution(res: u8) -> Result<(), ProgError> {
  let peripheral_ptr;
  unsafe {peripheral_ptr = stm32f4::stm32f446::Peripherals::steal();}
  let rcc = &peripheral_ptr.RCC;
  let adc1 = &peripheral_ptr.ADC1;
  let adc2 = &peripheral_ptr.ADC2;
  let adc3 = &peripheral_ptr.ADC3;
  let enc_res = match res {
    6  => 3,
    8  => 2,
    10 => 1,
    12 => 0,
    _ => {
      rprintln!("{} is not a available ADC resolution! | adc_resolution()", res);
      return Err(ProgError::InvalidConfiguration);
    }
  };
  if rcc.apb2enr.read().adc1en().is_enabled() {adc1.cr1.modify(|_, w| w.res().bits(enc_res));}
  if rcc.apb2enr.read().adc2en().is_enabled() {adc2.cr1.modify(|_, w| w.res().bits(enc_res));}
  if rcc.apb2enr.read().adc3en().is_enabled() {adc3.cr1.modify(|_, w| w.res().bits(enc_res));}
  return Ok(());
}
pub fn adc_resolution ( res : u8 ) -> Result < ( ) , ProgError > { let peripheral_ptr ; unsafe { peripheral_ptr = stm32f4 :: stm32f446 :: Peripherals :: steal ( ) ; } let rcc = & peripheral_ptr . RCC ; let adc1 = & peripheral_ptr . ADC1 ; let adc2 = & peripheral_ptr . ADC2 ; let adc3 = & peripheral_ptr . ADC3 ; let enc_res = match res { 6 => 3 , 8 => 2 , 10 => 1 , 12 => 0 , _ => { rprintln ! ( " " res ) ; return Err ( ProgError :: InvalidConfiguration ) ; } } ; if rcc . apb2enr . read ( ) . adc1en ( ) . is_enabled ( ) { adc1 . cr1 . modify ( | _ , w | w . res ( ) . bits ( enc_res ) ) ; } if rcc . apb2enr . read ( ) . adc2en ( ) . is_enabled ( ) { adc2 . cr1 . modify ( | _ , w | w . res ( ) . bits ( enc_res ) ) ; } if rcc . apb2enr . read ( ) . adc3en ( ) . is_enabled ( ) { adc3 . cr1 . modify ( | _ , w | w . res ( ) . bits ( enc_res ) ) ; } return Ok ( ( ) ) ; }
Changes the resolution for all analog pins
Possible values are 6, 8, 10 and 12 bit resolutions.
Changes the resolution for all analog pins Possible values are 6 8 10 and 12 bit resolutions .
res
u8