rsiot/components/cmp_esp_spi_master/
component.rs1use async_trait::async_trait;
2use esp_idf_svc::hal::{
3 peripheral::Peripheral,
4 spi::{Spi, SpiAnyPins},
5};
6
7use crate::{
8 executor::{CmpInOut, CmpResult, Component, IComponentProcess},
9 message::{AuthPermissions, MsgDataBound},
10};
11
12use super::{config::Config, fn_process::fn_process};
13
14#[cfg_attr(not(feature = "single-thread"), async_trait)]
15#[cfg_attr(feature = "single-thread", async_trait(?Send))]
16impl<TMsg, TSpi, TPeripheral> IComponentProcess<Config<TMsg, TSpi, TPeripheral>, TMsg>
17 for Component<Config<TMsg, TSpi, TPeripheral>, TMsg>
18where
19 TMsg: MsgDataBound + 'static,
20 TSpi: Peripheral<P = TPeripheral> + 'static,
21 TPeripheral: Spi + SpiAnyPins + 'static,
22{
23 async fn process(
24 &self,
25 config: Config<TMsg, TSpi, TPeripheral>,
26 msg_bus: CmpInOut<TMsg>,
27 ) -> CmpResult {
28 let in_out = msg_bus.clone_with_new_id("cmp_esp_spi_master", AuthPermissions::FullAccess);
29 fn_process(config, in_out).await?;
30 Ok(())
31 }
32}
33
34pub type Cmp<TMsg, TSpi, TPeripheral, const MESSAGE_LEN: usize> =
36 Component<Config<TMsg, TSpi, TPeripheral>, TMsg>;