pub struct UsartDriver<'a> {
regs: *mut RegisterBlock,
_callback: Option<Box<dyn FnMut(Event) + 'a>>,
config: Config,
tx_count: u32,
rx_count: u32,
}Expand description
A polling-based USART driver for STM32F407.
Fields§
§regs: *mut RegisterBlock§_callback: Option<Box<dyn FnMut(Event) + 'a>>§config: Config§tx_count: u32§rx_count: u32Implementations§
Source§impl<'a> UsartDriver<'a>
impl<'a> UsartDriver<'a>
pub fn new(usart_base_addr: u32, config: Config) -> Self
Sourcepub fn new_usart1(config: Config) -> Self
pub fn new_usart1(config: Config) -> Self
Create a new USART1 driver instance (APB2 clock)
Sourcepub fn new_usart2(config: Config) -> Self
pub fn new_usart2(config: Config) -> Self
Create a new USART2 driver instance (APB1 clock)
Sourcepub fn new_usart3(config: Config) -> Self
pub fn new_usart3(config: Config) -> Self
Create a new USART3 driver instance (APB1 clock)
fn regs(&self) -> &mut RegisterBlock
fn is_on_apb2(&self) -> bool
fn compute_brr(&self, baudrate: u32) -> u32
fn write_cr1(&mut self, f: impl FnOnce(u32) -> u32)
fn write_cr2(&mut self, f: impl FnOnce(u32) -> u32)
fn write_cr3(&mut self, f: impl FnOnce(u32) -> u32)
fn wait_txe(&self)
fn wait_rxne(&self)
fn wait_tc(&self)
Trait Implementations§
Source§impl<'a> Usart<'a> for UsartDriver<'a>
impl<'a> Usart<'a> for UsartDriver<'a>
Source§fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>
fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>
Initializes the USART peripheral. Read more
Source§fn transfer(&mut self, data_out: &[u8], data_in: &mut [u8]) -> Result<(), i32>
fn transfer(&mut self, data_out: &[u8], data_in: &mut [u8]) -> Result<(), i32>
Simultaneously sends and receives data.
Source§fn get_tx_count(&self) -> u32
fn get_tx_count(&self) -> u32
Gets the number of bytes transmitted.
Source§fn get_rx_count(&self) -> u32
fn get_rx_count(&self) -> u32
Gets the number of bytes received.
Source§fn get_status(&self) -> Status
fn get_status(&self) -> Status
Gets the current status of the USART peripheral.
Source§fn set_modem_control(&mut self, control: ModemControl) -> Result<(), i32>
fn set_modem_control(&mut self, control: ModemControl) -> Result<(), i32>
Controls the modem lines.
Source§fn get_modem_status(&self) -> ModemStatus
fn get_modem_status(&self) -> ModemStatus
Gets the status of the modem lines.
Auto Trait Implementations§
impl<'a> Freeze for UsartDriver<'a>
impl<'a> !RefUnwindSafe for UsartDriver<'a>
impl<'a> !Send for UsartDriver<'a>
impl<'a> !Sync for UsartDriver<'a>
impl<'a> Unpin for UsartDriver<'a>
impl<'a> !UnwindSafe for UsartDriver<'a>
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