aboutsummaryrefslogtreecommitdiff
path: root/embassy-net-wiznet/src/chip/mod.rs
blob: e1f963d953be19396351e43ce17a943329684052 (plain)
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
//! Wiznet W5100s and W5500 family driver.
mod w5500;
pub use w5500::W5500;
mod w5100s;
use embedded_hal_async::spi::SpiDevice;
pub use w5100s::W5100S;

pub(crate) trait SealedChip {
    type Address;

    const COMMON_MODE: Self::Address;
    const COMMON_MAC: Self::Address;
    const COMMON_SOCKET_INTR: Self::Address;
    const COMMON_PHY_CFG: Self::Address;
    const SOCKET_MODE: Self::Address;
    const SOCKET_COMMAND: Self::Address;
    const SOCKET_RXBUF_SIZE: Self::Address;
    const SOCKET_TXBUF_SIZE: Self::Address;
    const SOCKET_TX_FREE_SIZE: Self::Address;
    const SOCKET_TX_DATA_WRITE_PTR: Self::Address;
    const SOCKET_RECVD_SIZE: Self::Address;
    const SOCKET_RX_DATA_READ_PTR: Self::Address;
    const SOCKET_INTR_MASK: Self::Address;
    const SOCKET_INTR: Self::Address;

    const SOCKET_MODE_VALUE: u8;

    const BUF_SIZE: u16;
    const AUTO_WRAP: bool;

    fn rx_addr(addr: u16) -> Self::Address;
    fn tx_addr(addr: u16) -> Self::Address;

    async fn bus_read<SPI: SpiDevice>(spi: &mut SPI, address: Self::Address, data: &mut [u8])
        -> Result<(), SPI::Error>;
    async fn bus_write<SPI: SpiDevice>(spi: &mut SPI, address: Self::Address, data: &[u8]) -> Result<(), SPI::Error>;
}

/// Trait for Wiznet chips.
#[allow(private_bounds)]
pub trait Chip: SealedChip {}