From e1545066e57fb072a59b1a93bf4c9bcbc3854cc2 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Sun, 19 Dec 2021 08:49:19 +0100 Subject: [PATCH] Some API documentation fixes in traits --- embassy-traits/src/i2c.rs | 8 ++++---- embassy-traits/src/spi.rs | 2 ++ embassy-traits/src/uart.rs | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/embassy-traits/src/i2c.rs b/embassy-traits/src/i2c.rs index 0fdf50a1..4e2e8e2f 100644 --- a/embassy-traits/src/i2c.rs +++ b/embassy-traits/src/i2c.rs @@ -21,7 +21,7 @@ //! For demonstration purposes the address mode parameter has been omitted in this example. //! //! ``` -//! # use embedded_hal::blocking::i2c::WriteRead; +//! # use embassy_traits::i2c::I2c; //! const ADDR: u8 = 0x15; //! # const TEMP_REGISTER: u8 = 0x1; //! pub struct TemperatureSensorDriver { @@ -30,7 +30,7 @@ //! //! impl TemperatureSensorDriver //! where -//! I2C: WriteRead, +//! I2C: I2c, //! { //! pub fn read_temperature(&mut self) -> Result { //! let mut temp = [0]; @@ -45,7 +45,7 @@ //! ### Device driver compatible only with 10-bit addresses //! //! ``` -//! # use embedded_hal::blocking::i2c::{TenBitAddress, WriteRead}; +//! # use embassy_traits::i2c::{TenBitAddress, I2c}; //! const ADDR: u16 = 0x158; //! # const TEMP_REGISTER: u8 = 0x1; //! pub struct TemperatureSensorDriver { @@ -54,7 +54,7 @@ //! //! impl TemperatureSensorDriver //! where -//! I2C: WriteRead, +//! I2C: I2c, //! { //! pub fn read_temperature(&mut self) -> Result { //! let mut temp = [0]; diff --git a/embassy-traits/src/spi.rs b/embassy-traits/src/spi.rs index 14f79b05..6beb442b 100644 --- a/embassy-traits/src/spi.rs +++ b/embassy-traits/src/spi.rs @@ -46,6 +46,7 @@ pub trait Write: Spi { Self: 'a, Word: 'a; + /// Writes `data` to the peripheral, ignoring all the incoming words. fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>; } @@ -55,5 +56,6 @@ pub trait Read: Write { Self: 'a, Word: 'a; + /// Reads words into `data` from the peripheral. fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>; } diff --git a/embassy-traits/src/uart.rs b/embassy-traits/src/uart.rs index 755aee6d..4984bc89 100644 --- a/embassy-traits/src/uart.rs +++ b/embassy-traits/src/uart.rs @@ -12,6 +12,7 @@ pub trait Read { where Self: 'a; + /// Receive into the buffer until the buffer is full. fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a>; } @@ -30,5 +31,6 @@ pub trait Write { where Self: 'a; + /// Write all bytes in `buf`. fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>; }