[−][src]Struct ruspiro_uart::Uart1
Uart1 (miniUART) peripheral representation
Methods
impl Uart1
[src]
pub const fn new() -> Self
[src]
Get a new Uart1 instance, that needs to be initialized before it can be used.
Example
let _miniUart = Uart1::new();
pub fn initialize(
&mut self,
clock_rate: u32,
baud_rate: u32
) -> Result<(), &'static str>
[src]
&mut self,
clock_rate: u32,
baud_rate: u32
) -> Result<(), &'static str>
Initialize the Uart1 peripheral for usage. It takes the core clock rate and the baud rate to configure correct communication speed.
Example
let mut uart = Uart1::new(); assert_eq!(uart.initialize(250_000_000, 115_200), Ok(()));
pub fn send_char(&self, c: char)
[src]
pub fn send_string(&self, s: &str)
[src]
pub fn send_data(&self, d: &[u8])
[src]
pub fn send_hex(&self, value: u64)
[src]
pub fn try_receive_data(&self, buffer: &mut [u8]) -> Result<usize, &'static str>
[src]
Try to recieve data from the Uart of the given size
If the requested size could be read it returns a Ok(data: Vec<u8>)
containing the data
otherwise an Err(msg: &str)
.
Example
let mut buffer: [u8; 8] = [0; 8]; let rx_size = uart.try_receive_data(&mut buffer).expect("unable to receive data");
pub fn receive_data(&self, buffer: &mut [u8]) -> Result<usize, &'static str>
[src]
Recieve data from the Uart of the given size, blocking the current execution until the
requested amount if data has been received.
If the requested size could be read it returns a Ok(size: usize)
containing the data
otherwise an Err(msg: &str)
.
Example
let mut buffer: [u8; 8] = [0; 8]; let rx_size = uart.receive_data(&mut buffer).expect("unable to receive data");
pub fn enable_interrupts(&self, i_type: InterruptType)
[src]
Enable Interrupts to be triggered by the miniUart. The i_type
specifies the interrupts
that shall be triggered. To receive/handle the interrupts a corresponding interrupt handler need to be
implemented, for example by using the ruspiro-interrupt
crate.
Example
// enable the interrupt to be triggered when data is recieved by the miniUart uart.enable_interrupts(InterruptType::Receive);
pub fn disable_interrupts(&self, i_type: InterruptType)
[src]
Disable Interrupts from beeing triggered by the miniUart. The i_type
specifies the interrupts
that shall disbabled.
Example
// disable the interrupt to be triggered when data is recieved by the miniUart uart.disable_interrupts(InterruptType::Receive);
pub fn get_interrupt_status(&self) -> u32
[src]
Read the current interrupt status. Bit 0 -> is set to 0 if an interrupt is pending Bit [1:2] -> 01 = transmit register is empty 10 = recieve register holds valid data
Example
let irq_status = uart.get_interrupt_status(); if (irq_status & 0b010) != 0 { println!("transmit register empty raised"); }
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,