Struct stm32_hal2::usart::Usart
source · [−]pub struct Usart<R> {
pub regs: R,
/* private fields */
}
Expand description
Represents the USART peripheral, for serial communications.
Fields
regs: R
Implementations
sourceimpl<R> Usart<R> where
R: Deref<Target = RegisterBlock> + RccPeriph + BaudPeriph,
impl<R> Usart<R> where
R: Deref<Target = RegisterBlock> + RccPeriph + BaudPeriph,
sourcepub fn new(regs: R, baud: u32, config: UsartConfig, clock_cfg: &Clocks) -> Self
pub fn new(regs: R, baud: u32, config: UsartConfig, clock_cfg: &Clocks) -> Self
Initialize a U[s]ART peripheral, including configuration register writes, and enabling and
resetting its RCC peripheral clock. baud
is the baud rate, in bytes-per-second.
sourcepub fn set_baud(&mut self, baud: u32, clock_cfg: &Clocks)
pub fn set_baud(&mut self, baud: u32, clock_cfg: &Clocks)
Set the BAUD rate. Called during init, and can be called later to change BAUD during program execution.
sourcepub fn write(&mut self, data: &[u8])
pub fn write(&mut self, data: &[u8])
Transmit data, as a sequence of u8. See L44 RM, section 38.5.2: “Character transmission procedure”
sourcepub fn read(&mut self, buf: &mut [u8])
pub fn read(&mut self, buf: &mut [u8])
Receive data into a u8 buffer. See L44 RM, section 38.5.3: “Character reception procedure”
sourcepub fn read_one(&mut self) -> u8
pub fn read_one(&mut self) -> u8
Read a single word, without confirming if it’s ready. This is useful in async concepts, when you know word is ready to be read.
sourcepub unsafe fn write_dma<D>(
&mut self,
buf: &[u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
pub unsafe fn write_dma<D>(
&mut self,
buf: &[u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
Transmit data using DMA. (L44 RM, section 38.5.15)
Note that the channel
argument is only used on F3 and L4.
sourcepub unsafe fn read_dma<D>(
&mut self,
buf: &mut [u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
pub unsafe fn read_dma<D>(
&mut self,
buf: &mut [u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
Receive data using DMA. (L44 RM, section 38.5.15; G4 RM section 37.5.19.
Note that the channel
argument is only used on F3 and L4.
sourcepub fn enable_interrupt(&mut self, interrupt: UsartInterrupt)
pub fn enable_interrupt(&mut self, interrupt: UsartInterrupt)
Enable a specific type of interrupt.
sourcepub fn clear_interrupt(&mut self, interrupt: UsartInterrupt)
pub fn clear_interrupt(&mut self, interrupt: UsartInterrupt)
Clears the interrupt pending flag for a specific type of interrupt.
Trait Implementations
sourceimpl<R> Read<u8> for Usart<R> where
R: Deref<Target = RegisterBlock> + RccPeriph + BaudPeriph,
impl<R> Read<u8> for Usart<R> where
R: Deref<Target = RegisterBlock> + RccPeriph + BaudPeriph,
sourceimpl<R> Write<u8> for Usart<R> where
R: Deref<Target = RegisterBlock> + RccPeriph + BaudPeriph,
impl<R> Write<u8> for Usart<R> where
R: Deref<Target = RegisterBlock> + RccPeriph + BaudPeriph,
Auto Trait Implementations
impl<R> RefUnwindSafe for Usart<R> where
R: RefUnwindSafe,
impl<R> Send for Usart<R> where
R: Send,
impl<R> Sync for Usart<R> where
R: Sync,
impl<R> Unpin for Usart<R> where
R: Unpin,
impl<R> UnwindSafe for Usart<R> where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more