pub struct Serial<UART, TXPIN, RXPIN>{ /* private fields */ }Implementations§
Source§impl<UART, TXPIN, RXPIN> Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> Serial<UART, TXPIN, RXPIN>
Sourcepub fn new(
uart: UART,
pins: (TXPIN, RXPIN),
config: Config,
) -> Result<Self, InitError<UART, TXPIN, RXPIN>>
pub fn new( uart: UART, pins: (TXPIN, RXPIN), config: Config, ) -> Result<Self, InitError<UART, TXPIN, RXPIN>>
Examples found in repository?
examples/serial.rs (line 29)
15pub extern "C" fn main() -> ! {
16 let peripherals = Peripherals::take().unwrap();
17
18 let rcc_config = RCC::default();
19 RCC::init(&rcc_config);
20
21 peripherals
22 .pm
23 .clk_apb_m_set()
24 .modify(|_, w| w.pad_config().enable().pm().enable());
25
26 let rx = Pin08::new().into_serial_port();
27 let tx = Pin09::new().into_serial_port();
28
29 let serial = Serial::new(peripherals.usart_1, (tx, rx), Config::default()).unwrap();
30 let (mut tx, _rx) = serial.split();
31
32 loop {
33 let _ = writeln!(tx, "Hello from MIK32 USART1");
34 delay(MESSAGE_DELAY_SPINS);
35 }
36}pub fn release(self) -> (UART, (TXPIN, RXPIN))
Sourcepub fn split(self) -> (Tx<UART, TXPIN, Owned>, Rx<UART, RXPIN, Borrowed>)
pub fn split(self) -> (Tx<UART, TXPIN, Owned>, Rx<UART, RXPIN, Borrowed>)
Examples found in repository?
examples/serial.rs (line 30)
15pub extern "C" fn main() -> ! {
16 let peripherals = Peripherals::take().unwrap();
17
18 let rcc_config = RCC::default();
19 RCC::init(&rcc_config);
20
21 peripherals
22 .pm
23 .clk_apb_m_set()
24 .modify(|_, w| w.pad_config().enable().pm().enable());
25
26 let rx = Pin08::new().into_serial_port();
27 let tx = Pin09::new().into_serial_port();
28
29 let serial = Serial::new(peripherals.usart_1, (tx, rx), Config::default()).unwrap();
30 let (mut tx, _rx) = serial.split();
31
32 loop {
33 let _ = writeln!(tx, "Hello from MIK32 USART1");
34 delay(MESSAGE_DELAY_SPINS);
35 }
36}pub fn reunite( tx: Tx<UART, TXPIN, Owned>, rx: Rx<UART, RXPIN, Borrowed>, ) -> Serial<UART, TXPIN, RXPIN>
Trait Implementations§
Auto Trait Implementations§
impl<UART, TXPIN, RXPIN> Freeze for Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> RefUnwindSafe for Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> Send for Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> Sync for Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> Unpin for Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> UnsafeUnpin for Serial<UART, TXPIN, RXPIN>
impl<UART, TXPIN, RXPIN> UnwindSafe for Serial<UART, TXPIN, RXPIN>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more