Struct nrf52811_hal::Uarte
source · [−]pub struct Uarte<T>(_);
Expand description
Interface to a UARTE instance.
This is a very basic interface that comes with the following limitations:
- The UARTE instances share the same address space with instances of UART.
You need to make sure that conflicting instances
are disabled before using
Uarte
. See product specification:- nrf52832: Section 15.2
- nrf52840: Section 6.1.2
Implementations
sourceimpl<T> Uarte<T> where
T: Instance,
impl<T> Uarte<T> where
T: Instance,
pub fn new(
uarte: T,
pins: Pins,
parity: PARITY_A,
baudrate: BAUDRATE_A
) -> Uarte<T>
sourcepub fn write(&mut self, tx_buffer: &[u8]) -> Result<(), Error>
pub fn write(&mut self, tx_buffer: &[u8]) -> Result<(), Error>
Write via UARTE.
This method uses transmits all bytes in tx_buffer
.
The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840.
sourcepub fn read(&mut self, rx_buffer: &mut [u8]) -> Result<(), Error>
pub fn read(&mut self, rx_buffer: &mut [u8]) -> Result<(), Error>
Read via UARTE.
This method fills all bytes in rx_buffer
, and blocks
until the buffer is full.
The buffer must have a length of at most 255 bytes.
sourcepub fn read_timeout<I>(
&mut self,
rx_buffer: &mut [u8],
timer: &mut Timer<I, OneShot>,
cycles: u32
) -> Result<(), Error> where
I: Instance,
pub fn read_timeout<I>(
&mut self,
rx_buffer: &mut [u8],
timer: &mut Timer<I, OneShot>,
cycles: u32
) -> Result<(), Error> where
I: Instance,
Read via UARTE.
This method fills all bytes in rx_buffer
, and blocks
until the buffer is full or the timeout expires, whichever
comes first.
If the timeout occurs, an Error::Timeout(n)
will be returned,
where n
is the number of bytes read successfully.
This method assumes the interrupt for the given timer is NOT enabled, and in cases where a timeout does NOT occur, the timer will be left running until completion.
The buffer must have a length of at most 255 bytes.
sourcepub fn split(
self,
tx_buf: &'static mut [u8],
rx_buf: &'static mut [u8; 1]
) -> Result<(UarteTx<T>, UarteRx<T>), Error>
pub fn split(
self,
tx_buf: &'static mut [u8],
rx_buf: &'static mut [u8; 1]
) -> Result<(UarteTx<T>, UarteRx<T>), Error>
Split into implementations of embedded_hal::serial traits.
The size of the tx_buf
slice passed to this method will determine
the size of the DMA transfers performed.
The rx_buf
slice is an array of size 1 since the embedded_hal
traits only allow reading one byte at a time.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Uarte<T> where
T: RefUnwindSafe,
impl<T> Send for Uarte<T> where
T: Send,
impl<T> Sync for Uarte<T> where
T: Sync,
impl<T> Unpin for Uarte<T> where
T: Unpin,
impl<T> UnwindSafe for Uarte<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcepub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcepub fn checked_cast_from(src: Src) -> Option<Dst>
pub fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
sourcepub fn lossless_try_into(self) -> Option<Dst>
pub fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
sourceimpl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
sourcepub fn lossy_into(self) -> Dst
pub fn lossy_into(self) -> Dst
Performs the conversion.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcepub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcepub fn overflowing_cast_from(src: Src) -> (Dst, bool)
pub fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcepub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcepub fn saturating_cast_from(src: Src) -> Dst
pub fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcepub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcepub fn unwrapped_cast_from(src: Src) -> Dst
pub fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcepub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcepub fn wrapping_cast_from(src: Src) -> Dst
pub fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.