2021-03-02 00:32:23 +01:00
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
2023-10-30 19:06:08 +01:00
|
|
|
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections, try_blocks))]
|
|
|
|
#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))]
|
2022-07-19 07:57:39 +02:00
|
|
|
#![warn(missing_docs)]
|
|
|
|
|
|
|
|
//! Utilities to use `embedded-hal` traits with Embassy.
|
2021-03-02 00:32:23 +01:00
|
|
|
|
2022-07-10 00:05:57 +02:00
|
|
|
#[cfg(feature = "nightly")]
|
2021-12-17 12:50:48 +01:00
|
|
|
pub mod adapter;
|
2022-07-10 00:05:57 +02:00
|
|
|
|
2023-05-24 14:40:34 +02:00
|
|
|
pub mod flash;
|
|
|
|
|
2022-05-26 18:54:58 +02:00
|
|
|
pub mod shared_bus;
|
2022-07-08 15:47:47 +02:00
|
|
|
|
2022-07-19 07:57:39 +02:00
|
|
|
/// Set the configuration of a peripheral driver.
|
|
|
|
///
|
|
|
|
/// This trait is intended to be implemented by peripheral drivers such as SPI
|
|
|
|
/// and I2C. It allows changing the configuration at runtime.
|
|
|
|
///
|
|
|
|
/// The exact type of the "configuration" is defined by each individual driver, since different
|
|
|
|
/// drivers support different options. Therefore it is defined as an associated type.
|
|
|
|
///
|
|
|
|
/// For example, it is used by [`SpiDeviceWithConfig`](crate::shared_bus::asynch::spi::SpiDeviceWithConfig) and
|
|
|
|
/// [`I2cDeviceWithConfig`](crate::shared_bus::asynch::i2c::I2cDeviceWithConfig) to allow different
|
|
|
|
/// devices on the same bus to use different communication settings.
|
2022-07-09 00:00:55 +02:00
|
|
|
pub trait SetConfig {
|
2022-07-19 07:57:39 +02:00
|
|
|
/// The configuration type used by this driver.
|
2022-07-09 00:00:55 +02:00
|
|
|
type Config;
|
2022-07-19 07:57:39 +02:00
|
|
|
|
2023-10-01 16:37:20 +02:00
|
|
|
/// The error type that can occur if `set_config` fails.
|
|
|
|
type ConfigError;
|
|
|
|
|
2022-07-19 07:57:39 +02:00
|
|
|
/// Set the configuration of the driver.
|
2023-10-01 16:37:20 +02:00
|
|
|
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the configuration of a peripheral driver.
|
|
|
|
pub trait GetConfig {
|
|
|
|
/// The configuration type used by this driver.
|
|
|
|
type Config;
|
|
|
|
|
|
|
|
/// Get the configuration of the driver.
|
|
|
|
fn get_config(&self) -> Self::Config;
|
2022-07-08 15:47:47 +02:00
|
|
|
}
|