1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! Adapter from [`embedded_hal_async::spi::SpiDevice`] to this crate's [`Spi`] trait.
//!
//! Use this when your SPI peripheral is a **device** (with its own CS and possibly a shared bus)
//! rather than a raw bus. For example, with [embassy-embedded-hal] you can share one SPI bus
//! across multiple devices; each device gets a `SpiDevice` (bus + CS). Wrap that `SpiDevice` in
//! [`SpiDeviceAdapter`] to use it with [`Cat25040`].
//!
//! [embassy-embedded-hal]: https://crates.io/crates/embassy-embedded-hal
//!
//! # Example (embassy-embedded-hal shared SPI)
//!
//! ```ignore
//! use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice;
//! use embassy_sync::mutex::Mutex;
//! use cat25040::{spi_device::SpiDeviceAdapter, Cat25040, ...};
//!
//! static SPI_BUS: StaticCell<Mutex<NoopRawMutex, embassy_stm32::spi::Spi<...>>> = StaticCell::new();
//! let spi_bus = SPI_BUS.init(Mutex::new(spi));
//! let eeprom_cs = Output::new(p.PA12, Level::High, Speed::VeryHigh);
//! let eeprom_device = SpiDevice::new(spi_bus, eeprom_cs);
//! let adapter = SpiDeviceAdapter::new(eeprom_device);
//! let mut eeprom = Cat25040::new(adapter, EmbassyDelay);
//! ```
use crate::;
use ;
/// Wraps an [`embedded_hal_async::spi::SpiDevice`] and implements this crate's [`Spi`] trait.
///
/// Use with [embassy-embedded-hal]'s shared `SpiDevice` when multiple devices share one SPI bus.