forked from renet/ENC424J600
Replace stm32f4xx_hal with embedded_hal in the library
This commit is contained in:
parent
8e8d14b901
commit
7b313292ca
|
@ -11,6 +11,7 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
volatile-register = "0.2"
|
volatile-register = "0.2"
|
||||||
aligned = "0.3"
|
aligned = "0.3"
|
||||||
|
embedded-hal = "0.2"
|
||||||
stm32f4xx-hal = { version = "0.8" , optional = true }
|
stm32f4xx-hal = { version = "0.8" , optional = true }
|
||||||
smoltcp = { version = "0.6.0", default-features = false, features = ["proto-ipv4", "proto-ipv6", "socket-icmp", "socket-udp", "socket-tcp", "log", "verbose", "ethernet"], optional = true }
|
smoltcp = { version = "0.6.0", default-features = false, features = ["proto-ipv4", "proto-ipv6", "socket-icmp", "socket-udp", "socket-tcp", "log", "verbose", "ethernet"], optional = true }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
@ -21,13 +22,13 @@ smoltcp-phy-all = [
|
||||||
"smoltcp/socket-raw", "smoltcp/socket-udp", "smoltcp/socket-tcp",
|
"smoltcp/socket-raw", "smoltcp/socket-udp", "smoltcp/socket-tcp",
|
||||||
"smoltcp/proto-ipv4", "smoltcp/proto-ipv6"
|
"smoltcp/proto-ipv4", "smoltcp/proto-ipv6"
|
||||||
]
|
]
|
||||||
|
stm32f4 = ["stm32f4xx-hal"]
|
||||||
stm32f407 = ["stm32f4xx-hal/stm32f407"]
|
stm32f407 = ["stm32f4xx-hal/stm32f407"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
cortex-m = "0.5"
|
cortex-m = "0.5"
|
||||||
cortex-m-rt = "0.6"
|
cortex-m-rt = "0.6"
|
||||||
embedded-hal = "0.2"
|
|
||||||
panic-itm = "0.4"
|
panic-itm = "0.4"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
|
|
@ -13,7 +13,8 @@ use stm32f4xx_hal::{
|
||||||
gpio::GpioExt,
|
gpio::GpioExt,
|
||||||
time::U32Ext,
|
time::U32Ext,
|
||||||
stm32::{CorePeripherals, Peripherals},
|
stm32::{CorePeripherals, Peripherals},
|
||||||
spi::Spi
|
spi::Spi,
|
||||||
|
time::Hertz
|
||||||
};
|
};
|
||||||
use enc424j600;
|
use enc424j600;
|
||||||
use enc424j600::EthController;
|
use enc424j600::EthController;
|
||||||
|
@ -129,7 +130,7 @@ fn main() -> ! {
|
||||||
let spi_eth_port = Spi::spi1(
|
let spi_eth_port = Spi::spi1(
|
||||||
spi1, (spi1_sck, spi1_miso, spi1_mosi),
|
spi1, (spi1_sck, spi1_miso, spi1_mosi),
|
||||||
enc424j600::spi::interfaces::SPI_MODE,
|
enc424j600::spi::interfaces::SPI_MODE,
|
||||||
enc424j600::spi::interfaces::SPI_CLOCK.into(),
|
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
||||||
clocks);
|
clocks);
|
||||||
let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss);
|
let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss);
|
||||||
// Init
|
// Init
|
||||||
|
|
|
@ -13,7 +13,8 @@ use stm32f4xx_hal::{
|
||||||
time::U32Ext,
|
time::U32Ext,
|
||||||
stm32::{CorePeripherals, Peripherals},
|
stm32::{CorePeripherals, Peripherals},
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
spi::Spi
|
spi::Spi,
|
||||||
|
time::Hertz
|
||||||
};
|
};
|
||||||
use enc424j600;
|
use enc424j600;
|
||||||
use enc424j600::EthController;
|
use enc424j600::EthController;
|
||||||
|
@ -58,7 +59,7 @@ fn main() -> ! {
|
||||||
let spi_eth_port = Spi::spi1(
|
let spi_eth_port = Spi::spi1(
|
||||||
spi1, (spi1_sck, spi1_miso, spi1_mosi),
|
spi1, (spi1_sck, spi1_miso, spi1_mosi),
|
||||||
enc424j600::spi::interfaces::SPI_MODE,
|
enc424j600::spi::interfaces::SPI_MODE,
|
||||||
enc424j600::spi::interfaces::SPI_CLOCK.into(),
|
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
||||||
clocks);
|
clocks);
|
||||||
let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss);
|
let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss);
|
||||||
// Init
|
// Init
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
/// STM32F4xx-HAL specific implementations
|
|
||||||
pub mod spi;
|
pub mod spi;
|
||||||
use stm32f4xx_hal::{
|
use embedded_hal::{
|
||||||
hal::{
|
|
||||||
blocking::spi::Transfer,
|
blocking::spi::Transfer,
|
||||||
digital::v2::OutputPin,
|
digital::v2::OutputPin,
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod rx;
|
pub mod rx;
|
||||||
|
|
11
src/spi.rs
11
src/spi.rs
|
@ -1,25 +1,20 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use stm32f4xx_hal::{
|
use embedded_hal::{
|
||||||
hal::{
|
|
||||||
blocking::spi::Transfer,
|
blocking::spi::Transfer,
|
||||||
digital::v2::OutputPin,
|
digital::v2::OutputPin,
|
||||||
},
|
|
||||||
spi,
|
spi,
|
||||||
};
|
};
|
||||||
use crate::rx;
|
use crate::rx;
|
||||||
|
|
||||||
pub mod interfaces {
|
pub mod interfaces {
|
||||||
use stm32f4xx_hal::{
|
use embedded_hal::spi;
|
||||||
spi,
|
|
||||||
time::MegaHertz
|
|
||||||
};
|
|
||||||
/// Must use SPI mode cpol=0, cpha=0
|
/// Must use SPI mode cpol=0, cpha=0
|
||||||
pub const SPI_MODE: spi::Mode = spi::Mode {
|
pub const SPI_MODE: spi::Mode = spi::Mode {
|
||||||
polarity: spi::Polarity::IdleLow,
|
polarity: spi::Polarity::IdleLow,
|
||||||
phase: spi::Phase::CaptureOnFirstTransition,
|
phase: spi::Phase::CaptureOnFirstTransition,
|
||||||
};
|
};
|
||||||
/// Max freq = 14 MHz
|
/// Max freq = 14 MHz
|
||||||
pub const SPI_CLOCK: MegaHertz = MegaHertz(14);
|
pub const SPI_CLOCK_FREQ: u32 = 14_000_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod opcodes {
|
pub mod opcodes {
|
||||||
|
|
Loading…
Reference in New Issue