Replace stm32f4xx_hal with embedded_hal in the library

This commit is contained in:
Harry Ho 2020-08-24 12:07:45 +08:00
parent 8e8d14b901
commit 7b313292ca
5 changed files with 16 additions and 21 deletions

View File

@ -11,6 +11,7 @@ edition = "2018"
[dependencies]
volatile-register = "0.2"
aligned = "0.3"
embedded-hal = "0.2"
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 }
log = "0.4"
@ -21,13 +22,13 @@ smoltcp-phy-all = [
"smoltcp/socket-raw", "smoltcp/socket-udp", "smoltcp/socket-tcp",
"smoltcp/proto-ipv4", "smoltcp/proto-ipv6"
]
stm32f4 = ["stm32f4xx-hal"]
stm32f407 = ["stm32f4xx-hal/stm32f407"]
default = []
[dev-dependencies]
cortex-m = "0.5"
cortex-m-rt = "0.6"
embedded-hal = "0.2"
panic-itm = "0.4"
[[example]]

View File

@ -13,7 +13,8 @@ use stm32f4xx_hal::{
gpio::GpioExt,
time::U32Ext,
stm32::{CorePeripherals, Peripherals},
spi::Spi
spi::Spi,
time::Hertz
};
use enc424j600;
use enc424j600::EthController;
@ -129,7 +130,7 @@ fn main() -> ! {
let spi_eth_port = Spi::spi1(
spi1, (spi1_sck, spi1_miso, spi1_mosi),
enc424j600::spi::interfaces::SPI_MODE,
enc424j600::spi::interfaces::SPI_CLOCK.into(),
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
clocks);
let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss);
// Init

View File

@ -13,7 +13,8 @@ use stm32f4xx_hal::{
time::U32Ext,
stm32::{CorePeripherals, Peripherals},
delay::Delay,
spi::Spi
spi::Spi,
time::Hertz
};
use enc424j600;
use enc424j600::EthController;
@ -58,7 +59,7 @@ fn main() -> ! {
let spi_eth_port = Spi::spi1(
spi1, (spi1_sck, spi1_miso, spi1_mosi),
enc424j600::spi::interfaces::SPI_MODE,
enc424j600::spi::interfaces::SPI_CLOCK.into(),
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
clocks);
let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss);
// Init

View File

@ -1,12 +1,9 @@
#![no_std]
/// STM32F4xx-HAL specific implementations
pub mod spi;
use stm32f4xx_hal::{
hal::{
blocking::spi::Transfer,
digital::v2::OutputPin,
}
use embedded_hal::{
blocking::spi::Transfer,
digital::v2::OutputPin,
};
pub mod rx;

View File

@ -1,25 +1,20 @@
use core::fmt;
use stm32f4xx_hal::{
hal::{
blocking::spi::Transfer,
digital::v2::OutputPin,
},
use embedded_hal::{
blocking::spi::Transfer,
digital::v2::OutputPin,
spi,
};
use crate::rx;
pub mod interfaces {
use stm32f4xx_hal::{
spi,
time::MegaHertz
};
use embedded_hal::spi;
/// Must use SPI mode cpol=0, cpha=0
pub const SPI_MODE: spi::Mode = spi::Mode {
polarity: spi::Polarity::IdleLow,
phase: spi::Phase::CaptureOnFirstTransition,
};
/// Max freq = 14 MHz
pub const SPI_CLOCK: MegaHertz = MegaHertz(14);
pub const SPI_CLOCK_FREQ: u32 = 14_000_000;
}
pub mod opcodes {