Skip to main content

rsiot/components/cmp_esp_i2c_master/
config.rs

1use std::time::Duration;
2
3use esp_idf_svc::hal::{gpio::AnyIOPin, i2c::I2c};
4
5use crate::{
6    components_config::{
7        i2c_master::{FieldbusRequest, FieldbusResponse},
8        master_device::DeviceTrait,
9    },
10    message::MsgDataBound,
11};
12
13// ANCHOR: Config
14/// Конфигурация cmp_esp_i2c_master
15pub struct Config<TMsg, TI2c>
16where
17    TMsg: MsgDataBound,
18    TI2c: I2c + 'static,
19{
20    /// Ссылка на аппаратный интерфейс I2C
21    pub i2c: TI2c,
22
23    /// Пин сигнала SDA
24    pub sda: AnyIOPin<'static>,
25
26    /// Пин сигнала SCL
27    pub scl: AnyIOPin<'static>,
28
29    /// Скорость
30    pub baudrate: ConfigBaudrate,
31
32    /// true - подключить подтяжку встроенными резисторами
33    pub pullup_enable: bool,
34
35    /// Таймаут запроса
36    pub timeout: Duration,
37
38    /// Драйвера устройств
39    pub devices: Vec<Box<dyn DeviceTrait<TMsg, FieldbusRequest, FieldbusResponse>>>,
40}
41// ANCHOR: Config
42
43/// Скорость шины
44#[derive(Clone)]
45pub enum ConfigBaudrate {
46    /// 100 kHz
47    Standard,
48
49    /// 400 kHz
50    Fast,
51}