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