pub struct LpUart<R> {
pub regs: R,
/* private fields */
}Expand description
Represents the USART peripheral, for serial communications.
Fields§
§regs: RImplementations§
Source§impl<R> LpUart<R>
impl<R> LpUart<R>
Sourcepub fn write(&mut self, data: &[u8]) -> Result<()>
pub fn write(&mut self, data: &[u8]) -> Result<()>
Transmit data, as a sequence of u8. See L44 RM, section 38.5.2: “Character transmission procedure”
Sourcepub fn write_one(&mut self, word: u8)
pub fn write_one(&mut self, word: u8)
Write a single word, without waiting until ready for the next. Compared to the write() function, this
does not block.
Sourcepub fn read(&mut self, buf: &mut [u8]) -> Result<()>
pub fn read(&mut self, buf: &mut [u8]) -> Result<()>
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 waiting until ready for the next. Compared to the read() function, this
does not block.
Sourcepub unsafe fn write_dma(
&mut self,
buf: &[u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma_periph: DmaPeriph,
) -> Result<()>
pub unsafe fn write_dma( &mut self, buf: &[u8], channel: DmaChannel, channel_cfg: ChannelCfg, dma_periph: DmaPeriph, ) -> Result<()>
Transmit data using DMA. (L44 RM, section 38.5.15)
Note that the channel argument is unused on F3 and L4, since it is hard-coded,
and can’t be configured using the DMAMUX peripheral. (dma::mux() fn).
Sourcepub unsafe fn read_dma(
&mut self,
buf: &mut [u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma_periph: DmaPeriph,
) -> Result<()>
pub unsafe fn read_dma( &mut self, buf: &mut [u8], channel: DmaChannel, channel_cfg: ChannelCfg, dma_periph: DmaPeriph, ) -> Result<()>
Receive data using DMA. (L44 RM, section 38.5.15; G4 RM section 37.5.19.
Note that the channel argument is unused on F3 and L4, since it is hard-coded,
and can’t be configured using the DMAMUX peripheral. (dma::mux() fn).
Sourcepub fn enable_interrupt(&mut self, interrupt: UsartInterrupt) -> Result<()>
pub fn enable_interrupt(&mut self, interrupt: UsartInterrupt) -> Result<()>
Enable a specific type of interrupt. See G4 RM, Table 349: USART interrupt requests.
If Some, the inner value of CharDetect sets the address of the char to match.
If None, the interrupt is enabled without changing the char to match.
Sourcepub fn disable_interrupt(&mut self, interrupt: UsartInterrupt)
pub fn disable_interrupt(&mut self, interrupt: UsartInterrupt)
Disable a specific type of interrupt. See G4 RM, Table 349: USART interrupt requests.
Note that the inner value of CharDetect doesn’t do anything here.
Sourcepub fn read_status(&self) -> u32
pub fn read_status(&self) -> u32
Print the (raw) contents of the status register.
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. Note that
it can also clear error flags, like Overrun and framing errors. See G4 RM,
Table 349: USART interrupt requests.
Note that the inner value of CharDetect doesn’t do anything here.
Sourcepub fn check_status_flag(&mut self, flag: UsartInterrupt) -> bool
pub fn check_status_flag(&mut self, flag: UsartInterrupt) -> bool
Checks if a given status flag is set. Returns true if the status flag is set. Note that this preforms
a read each time called. If checking multiple flags, this isn’t optimal.
Trait Implementations§
Source§impl<R> Read for LpUart<R>
impl<R> Read for LpUart<R>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read more