pub unsafe fn pinmode_analog_force(pin: (char, u8)) -> Result<Pin<Analog>, ProgError> {
  let peripheral_ptr;
  peripheral_ptr = stm32f4::stm32f446::Peripherals::steal();
  let rcc = &peripheral_ptr.RCC;

  let channel_data: (u8, u8);

  if let Err(error) = check_pin(pin) {return Err(error);}

  match pin.0 {
    'a' => {
      let gpioa = &peripheral_ptr.GPIOA;
      rcc.ahb1enr.modify(|_, w| w.gpioaen().enabled());
      gpioa.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'b' => {
      let gpiob = &peripheral_ptr.GPIOB;
      rcc.ahb1enr.modify(|_, w| w.gpioben().enabled());
      gpiob.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'c' => {
      let gpioc = &peripheral_ptr.GPIOC;
      rcc.ahb1enr.modify(|_, w| w.gpiocen().enabled());
      gpioc.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'd' => {
      let gpiod = &peripheral_ptr.GPIOD;
      rcc.ahb1enr.modify(|_, w| w.gpioden().enabled());
      gpiod.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'h' => {
      let gpioh = &peripheral_ptr.GPIOH;
      rcc.ahb1enr.modify(|_, w| w.gpiohen().enabled());
      gpioh.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    _   => unreachable!()
  };

  return Ok(Pin {
    block: pin.0,
    number: pin.1,
    inner: Analog {
      core: channel_data.0,
      channel: channel_data.1
    }
  });
}
/// Configures a pin to be an analog input.
/// 
/// Takes pin identifier [A0, C5, etc.](crate::include::pins) as an argument and returns a [pin-struct](crate::gpio::Pin)
/// for other functions.
/// Panics if pin identifier is not a pin that can be used the the internal ADCs.  To see witch pins are available
/// for analog functionality see the docs of [ADC_MAP](crate::include::ADC_MAP).
/// 
/// # Safety
/// 
/// This function can be used to get more than one pin-structs of a configured pin. Keep in mind that the registers of
/// the pin will still be configured. This can easily break other functions for the pin.
Configures a pin to be an analog input.
Configures a pin to be an analog input .
pub unsafe fn pinmode_analog_force(pin: (char, u8)) -> Result<Pin<Analog>, ProgError> {
  let peripheral_ptr;
  peripheral_ptr = stm32f4::stm32f446::Peripherals::steal();
  let rcc = &peripheral_ptr.RCC;
  let channel_data: (u8, u8);
  if let Err(error) = check_pin(pin) {return Err(error);}
  match pin.0 {
    'a' => {
      let gpioa = &peripheral_ptr.GPIOA;
      rcc.ahb1enr.modify(|_, w| w.gpioaen().enabled());
      gpioa.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'b' => {
      let gpiob = &peripheral_ptr.GPIOB;
      rcc.ahb1enr.modify(|_, w| w.gpioben().enabled());
      gpiob.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'c' => {
      let gpioc = &peripheral_ptr.GPIOC;
      rcc.ahb1enr.modify(|_, w| w.gpiocen().enabled());
      gpioc.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'd' => {
      let gpiod = &peripheral_ptr.GPIOD;
      rcc.ahb1enr.modify(|_, w| w.gpioden().enabled());
      gpiod.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    'h' => {
      let gpioh = &peripheral_ptr.GPIOH;
      rcc.ahb1enr.modify(|_, w| w.gpiohen().enabled());
      gpioh.moder.modify(|r, w| unsafe {w.bits(r.bits() & !(3 << (2 * pin.1)) | (3 << (2 * pin.1)))});
      channel_data = match enable_channel(pin) {
        Ok(value) => value,
        Err(error) => return Err(error)
      };
    },
    _   => unreachable!()
  };
  return Ok(Pin {
    block: pin.0,
    number: pin.1,
    inner: Analog {
      core: channel_data.0,
      channel: channel_data.1
    }
  });
}
pub unsafe fn pinmode_analog_force ( pin : ( char , u8 ) ) -> Result < Pin < Analog > , ProgError > { let peripheral_ptr ; peripheral_ptr = stm32f4 :: stm32f446 :: Peripherals :: steal ( ) ; let rcc = & peripheral_ptr . RCC ; let channel_data : ( u8 , u8 ) ; if let Err ( error ) = check_pin ( pin ) { return Err ( error ) ; } match pin . 0 { 'a' => { let gpioa = & peripheral_ptr . GPIOA ; rcc . ahb1enr . modify ( | _ , w | w . gpioaen ( ) . enabled ( ) ) ; gpioa . moder . modify ( | r , w | unsafe { w . bits ( r . bits ( ) & ! ( 3 << ( 2 * pin . 1 ) ) | ( 3 << ( 2 * pin . 1 ) ) ) } ) ; channel_data = match enable_channel ( pin ) { Ok ( value ) => value , Err ( error ) => return Err ( error ) } ; } , 'b' => { let gpiob = & peripheral_ptr . GPIOB ; rcc . ahb1enr . modify ( | _ , w | w . gpioben ( ) . enabled ( ) ) ; gpiob . moder . modify ( | r , w | unsafe { w . bits ( r . bits ( ) & ! ( 3 << ( 2 * pin . 1 ) ) | ( 3 << ( 2 * pin . 1 ) ) ) } ) ; channel_data = match enable_channel ( pin ) { Ok ( value ) => value , Err ( error ) => return Err ( error ) } ; } , 'c' => { let gpioc = & peripheral_ptr . GPIOC ; rcc . ahb1enr . modify ( | _ , w | w . gpiocen ( ) . enabled ( ) ) ; gpioc . moder . modify ( | r , w | unsafe { w . bits ( r . bits ( ) & ! ( 3 << ( 2 * pin . 1 ) ) | ( 3 << ( 2 * pin . 1 ) ) ) } ) ; channel_data = match enable_channel ( pin ) { Ok ( value ) => value , Err ( error ) => return Err ( error ) } ; } , 'd' => { let gpiod = & peripheral_ptr . GPIOD ; rcc . ahb1enr . modify ( | _ , w | w . gpioden ( ) . enabled ( ) ) ; gpiod . moder . modify ( | r , w | unsafe { w . bits ( r . bits ( ) & ! ( 3 << ( 2 * pin . 1 ) ) | ( 3 << ( 2 * pin . 1 ) ) ) } ) ; channel_data = match enable_channel ( pin ) { Ok ( value ) => value , Err ( error ) => return Err ( error ) } ; } , 'h' => { let gpioh = & peripheral_ptr . GPIOH ; rcc . ahb1enr . modify ( | _ , w | w . gpiohen ( ) . enabled ( ) ) ; gpioh . moder . modify ( | r , w | unsafe { w . bits ( r . bits ( ) & ! ( 3 << ( 2 * pin . 1 ) ) | ( 3 << ( 2 * pin . 1 ) ) ) } ) ; channel_data = match enable_channel ( pin ) { Ok ( value ) => value , Err ( error ) => return Err ( error ) } ; } , _ => unreachable ! ( ) } ; return Ok ( Pin { block : pin . 0 , number : pin . 1 , inner : Analog { core : channel_data . 0 , channel : channel_data . 1 } } ) ; }
Configures a pin to be an analog input.
Configures a pin to be an analog input .
pin
(char, u8)
pin
(char, u8)
safety
This function can be used to get more than one pin-structs of a configured pin. Keep in mind that the registers of
the pin will still be configured. This can easily break other functions for the pin.
This function can be used to get more than one pin - structs of a configured pin . Keep in mind that the registers of the pin will still be configured . This can easily break other functions for the pin .