1 | #![no_std ] |
2 | #![allow (async_fn_in_trait)] |
3 | #![warn (missing_docs)] |
4 | #![doc = include_str!("../README.md" )] |
5 | |
6 | pub mod adapter; |
7 | pub mod flash; |
8 | pub mod shared_bus; |
9 | |
10 | /// Set the configuration of a peripheral driver. |
11 | /// |
12 | /// This trait is intended to be implemented by peripheral drivers such as SPI |
13 | /// and I2C. It allows changing the configuration at runtime. |
14 | /// |
15 | /// The exact type of the "configuration" is defined by each individual driver, since different |
16 | /// drivers support different options. Therefore it is defined as an associated type. |
17 | /// |
18 | /// For example, it is used by [`SpiDeviceWithConfig`](crate::shared_bus::asynch::spi::SpiDeviceWithConfig) and |
19 | /// [`I2cDeviceWithConfig`](crate::shared_bus::asynch::i2c::I2cDeviceWithConfig) to allow different |
20 | /// devices on the same bus to use different communication settings. |
21 | pub trait SetConfig { |
22 | /// The configuration type used by this driver. |
23 | type Config; |
24 | |
25 | /// The error type that can occur if `set_config` fails. |
26 | type ConfigError; |
27 | |
28 | /// Set the configuration of the driver. |
29 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>; |
30 | } |
31 | |
32 | /// Get the configuration of a peripheral driver. |
33 | pub trait GetConfig { |
34 | /// The configuration type used by this driver. |
35 | type Config; |
36 | |
37 | /// Get the configuration of the driver. |
38 | fn get_config(&self) -> Self::Config; |
39 | } |
40 | |