/// Sends a raw byte over the serial connection. Returns an error-enum if problems with the connection are detected.
Sends a raw byte over the serial connection. Returns an error-enum if problems with the connection are detected.
Sends a raw byte over the serial connection . Returns an error - enum if problems with the connection are detected .
pub fn write(&self, data: u8) -> Result<(), SerialError> {
    let peripheral_ptr;
    unsafe {peripheral_ptr = stm32f4::stm32f446::Peripherals::steal();}
    match self.core {
      1 => {
        let uart1 = &peripheral_ptr.USART1;
        while uart1.sr.read().txe().bit_is_clear() {
          if let Err(error) = check_uart_errors(uart1.sr.read().bits()) {return Err(error);}
        }
        uart1.dr.write(|w| w.dr().bits(data.into()));
      },
      2 => {
        let uart2 = &peripheral_ptr.USART2;
        while uart2.sr.read().txe().bit_is_clear() {
          if let Err(error) = check_uart_errors(uart2.sr.read().bits()) {return Err(error);}
        }
        uart2.dr.write(|w| w.dr().bits(data.into()));
      },
      3 => {
        let uart3 = &peripheral_ptr.USART3;
        while uart3.sr.read().txe().bit_is_clear() {
          if let Err(error) = check_uart_errors(uart3.sr.read().bits()) {return Err(error);}
        }
        uart3.dr.write(|w| w.dr().bits(data.into()));
      },
      4 => {
        let uart4 = &peripheral_ptr.UART4;
        while uart4.sr.read().txe().bit_is_clear() {
          if let Err(error) = check_uart_errors(uart4.sr.read().bits()) {return Err(error);}
        }
        uart4.dr.write(|w| w.dr().bits(data.into()));
      },
      5 => {
        let uart5 = &peripheral_ptr.UART5;
        while uart5.sr.read().txe().bit_is_clear() {
          if let Err(error) = check_uart_errors(uart5.sr.read().bits()) {return Err(error);}
        }
        uart5.dr.write(|w| w.dr().bits(data.into()));
      },
      6 => {
        let uart6 = &peripheral_ptr.USART6;
        while uart6.sr.read().txe().bit_is_clear() {
          if let Err(error) = check_uart_errors(uart6.sr.read().bits()) {return Err(error);}
        }
        uart6.dr.write(|w| w.dr().bits(data.into()));
      },
      _ => unreachable!()
    };
    return Ok(());
  }
pub fn write ( & self , data : u8 ) -> Result < ( ) , SerialError > { let peripheral_ptr ; unsafe { peripheral_ptr = stm32f4 :: stm32f446 :: Peripherals :: steal ( ) ; } match self . core { 1 => { let uart1 = & peripheral_ptr . USART1 ; while uart1 . sr . read ( ) . txe ( ) . bit_is_clear ( ) { if let Err ( error ) = check_uart_errors ( uart1 . sr . read ( ) . bits ( ) ) { return Err ( error ) ; } } uart1 . dr . write ( | w | w . dr ( ) . bits ( data . into ( ) ) ) ; } , 2 => { let uart2 = & peripheral_ptr . USART2 ; while uart2 . sr . read ( ) . txe ( ) . bit_is_clear ( ) { if let Err ( error ) = check_uart_errors ( uart2 . sr . read ( ) . bits ( ) ) { return Err ( error ) ; } } uart2 . dr . write ( | w | w . dr ( ) . bits ( data . into ( ) ) ) ; } , 3 => { let uart3 = & peripheral_ptr . USART3 ; while uart3 . sr . read ( ) . txe ( ) . bit_is_clear ( ) { if let Err ( error ) = check_uart_errors ( uart3 . sr . read ( ) . bits ( ) ) { return Err ( error ) ; } } uart3 . dr . write ( | w | w . dr ( ) . bits ( data . into ( ) ) ) ; } , 4 => { let uart4 = & peripheral_ptr . UART4 ; while uart4 . sr . read ( ) . txe ( ) . bit_is_clear ( ) { if let Err ( error ) = check_uart_errors ( uart4 . sr . read ( ) . bits ( ) ) { return Err ( error ) ; } } uart4 . dr . write ( | w | w . dr ( ) . bits ( data . into ( ) ) ) ; } , 5 => { let uart5 = & peripheral_ptr . UART5 ; while uart5 . sr . read ( ) . txe ( ) . bit_is_clear ( ) { if let Err ( error ) = check_uart_errors ( uart5 . sr . read ( ) . bits ( ) ) { return Err ( error ) ; } } uart5 . dr . write ( | w | w . dr ( ) . bits ( data . into ( ) ) ) ; } , 6 => { let uart6 = & peripheral_ptr . USART6 ; while uart6 . sr . read ( ) . txe ( ) . bit_is_clear ( ) { if let Err ( error ) = check_uart_errors ( uart6 . sr . read ( ) . bits ( ) ) { return Err ( error ) ; } } uart6 . dr . write ( | w | w . dr ( ) . bits ( data . into ( ) ) ) ; } , _ => unreachable ! ( ) } ; return Ok ( ( ) ) ; }
Sends a raw byte over the serial connection.
Sends a raw byte over the serial connection .
&self
data
u8