550: Some API documentation fixes in traits r=Dirbaio a=lulf



Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
This commit is contained in:
bors[bot] 2021-12-19 07:50:33 +00:00 committed by GitHub
commit fcb43caa36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -21,7 +21,7 @@
//! For demonstration purposes the address mode parameter has been omitted in this example. //! 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 ADDR: u8 = 0x15;
//! # const TEMP_REGISTER: u8 = 0x1; //! # const TEMP_REGISTER: u8 = 0x1;
//! pub struct TemperatureSensorDriver<I2C> { //! pub struct TemperatureSensorDriver<I2C> {
@ -30,7 +30,7 @@
//! //!
//! impl<I2C, E> TemperatureSensorDriver<I2C> //! impl<I2C, E> TemperatureSensorDriver<I2C>
//! where //! where
//! I2C: WriteRead<Error = E>, //! I2C: I2c<Error = E>,
//! { //! {
//! pub fn read_temperature(&mut self) -> Result<u8, E> { //! pub fn read_temperature(&mut self) -> Result<u8, E> {
//! let mut temp = [0]; //! let mut temp = [0];
@ -45,7 +45,7 @@
//! ### Device driver compatible only with 10-bit addresses //! ### 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 ADDR: u16 = 0x158;
//! # const TEMP_REGISTER: u8 = 0x1; //! # const TEMP_REGISTER: u8 = 0x1;
//! pub struct TemperatureSensorDriver<I2C> { //! pub struct TemperatureSensorDriver<I2C> {
@ -54,7 +54,7 @@
//! //!
//! impl<I2C, E> TemperatureSensorDriver<I2C> //! impl<I2C, E> TemperatureSensorDriver<I2C>
//! where //! where
//! I2C: WriteRead<TenBitAddress, Error = E>, //! I2C: I2c<TenBitAddress, Error = E>,
//! { //! {
//! pub fn read_temperature(&mut self) -> Result<u8, E> { //! pub fn read_temperature(&mut self) -> Result<u8, E> {
//! let mut temp = [0]; //! let mut temp = [0];

View File

@ -46,6 +46,7 @@ pub trait Write<Word>: Spi<Word> {
Self: 'a, Self: 'a,
Word: '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>; fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>;
} }
@ -55,5 +56,6 @@ pub trait Read<Word>: Write<Word> {
Self: 'a, Self: 'a,
Word: 'a; Word: 'a;
/// Reads words into `data` from the peripheral.
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>; fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
} }

View File

@ -12,6 +12,7 @@ pub trait Read {
where where
Self: 'a; Self: 'a;
/// Receive into the buffer until the buffer is full.
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a>; fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a>;
} }
@ -30,5 +31,6 @@ pub trait Write {
where where
Self: 'a; Self: 'a;
/// Write all bytes in `buf`.
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>; fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>;
} }