Use upstream stm32f4xx-hal #67
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aligned"
|
name = "aligned"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
|
@ -68,12 +70,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cast"
|
name = "cast"
|
||||||
version = "0.2.3"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
|
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||||
dependencies = [
|
|
||||||
"rustc_version",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
|
@ -82,14 +81,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cortex-m"
|
name = "chrono"
|
||||||
version = "0.6.4"
|
version = "0.4.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88cdafeafba636c00c467ded7f1587210725a1adfab0c24028a7844b87738263"
|
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
|
||||||
|
dependencies = [
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m"
|
||||||
|
version = "0.6.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aligned",
|
"aligned",
|
||||||
"bare-metal 0.2.5",
|
"bare-metal 0.2.5",
|
||||||
"bitfield",
|
"bitfield",
|
||||||
|
"cortex-m 0.7.4",
|
||||||
|
"volatile-register",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37ff967e867ca14eba0c34ac25cd71ea98c678e741e3915d923999bb2fe7c826"
|
||||||
|
dependencies = [
|
||||||
|
"bare-metal 0.2.5",
|
||||||
|
"bitfield",
|
||||||
|
"embedded-hal",
|
||||||
"volatile-register",
|
"volatile-register",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -99,7 +121,7 @@ version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d63959cb1e003dd97233fee6762351540253237eadf06fcdcb98cbfa3f9be4a"
|
checksum = "1d63959cb1e003dd97233fee6762351540253237eadf06fcdcb98cbfa3f9be4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cortex-m",
|
"cortex-m 0.6.7",
|
||||||
"cortex-m-semihosting",
|
"cortex-m-semihosting",
|
||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
@ -110,10 +132,19 @@ version = "0.6.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb"
|
checksum = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cortex-m-rt-macros",
|
"cortex-m-rt-macros 0.1.8",
|
||||||
"r0",
|
"r0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m-rt"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3c433da385b720d5bb9f52362fa2782420798e68d40d67bfe4b0d992aba5dfe7"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m-rt-macros 0.7.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cortex-m-rt-macros"
|
name = "cortex-m-rt-macros"
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
|
@ -125,13 +156,24 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cortex-m-rt-macros"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cortex-m-semihosting"
|
name = "cortex-m-semihosting"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc"
|
checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cortex-m",
|
"cortex-m 0.7.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -154,9 +196,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embedded-hal"
|
name = "embedded-hal"
|
||||||
version = "0.2.4"
|
version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb"
|
checksum = "e36cfb62ff156596c892272f3015ef952fe1525e85261fa3a7f327bd6b384ab9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nb 0.1.3",
|
"nb 0.1.3",
|
||||||
"void",
|
"void",
|
||||||
|
@ -264,6 +306,16 @@ dependencies = [
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
@ -286,7 +338,7 @@ version = "0.5.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec"
|
checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cortex-m",
|
"cortex-m 0.7.4",
|
||||||
"cortex-m-semihosting",
|
"cortex-m-semihosting",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -333,9 +385,18 @@ checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_core"
|
name = "rand_core"
|
||||||
version = "0.5.1"
|
version = "0.6.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rtcc"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef35f9dcbf434a34dcc99b3ebba1c1945d49c70832958e932e83dc63a5273994"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
|
@ -404,9 +465,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smoltcp"
|
name = "smoltcp"
|
||||||
version = "0.6.0"
|
version = "0.7.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fe46639fd2ec79eadf8fe719f237a7a0bd4dac5d957f1ca5bbdbc1c3c39e53a"
|
checksum = "3e4a069bef843d170df47e7c0a8bf8d037f217d9f5b325865acc3e466ffe40d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -423,10 +484,10 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stm32-eth"
|
name = "stm32-eth"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/stm32-rs/stm32-eth.git#4d6b29bf1ecdd1f68e5bc304a3d4f170049896c8"
|
source = "git+https://github.com/stm32-rs/stm32-eth.git?rev=3759c5c9#3759c5c99c0ab69bb71759030766bc0fba0b6cde"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aligned",
|
"aligned",
|
||||||
"cortex-m",
|
"cortex-m 0.7.4",
|
||||||
"smoltcp",
|
"smoltcp",
|
||||||
"stm32f4xx-hal",
|
"stm32f4xx-hal",
|
||||||
"volatile-register",
|
"volatile-register",
|
||||||
|
@ -434,29 +495,31 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stm32f4"
|
name = "stm32f4"
|
||||||
version = "0.11.0"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11460b4de3a84f072e2cf6e76306c64d27f405a0e83bace0a726f555ddf4bf33"
|
checksum = "da3d56009c8f32e4f208dbea17df72484154d1040a8969b75d8c73eb7b18fe8f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bare-metal 0.2.5",
|
"bare-metal 0.2.5",
|
||||||
"cortex-m",
|
"cortex-m 0.7.4",
|
||||||
"cortex-m-rt",
|
"cortex-m-rt 0.6.13",
|
||||||
"vcell",
|
"vcell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stm32f4xx-hal"
|
name = "stm32f4xx-hal"
|
||||||
version = "0.8.3"
|
version = "0.10.1"
|
||||||
source = "git+https://github.com/astro/stm32f4xx-hal.git?branch=flash#9171ef176a90b1177f350fe2bc1eac625769a041"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3a06fde2dd27c0ba934c9e69b62af66eb1c20dbb6d741b187a763912e9892d13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bare-metal 0.2.5",
|
"bare-metal 1.0.0",
|
||||||
"cast",
|
"cast",
|
||||||
"cortex-m",
|
"cortex-m 0.7.4",
|
||||||
"cortex-m-rt",
|
"cortex-m-rt 0.7.1",
|
||||||
"embedded-dma",
|
"embedded-dma",
|
||||||
"embedded-hal",
|
"embedded-hal",
|
||||||
"nb 0.1.3",
|
"nb 1.0.0",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
|
"rtcc",
|
||||||
"stm32f4",
|
"stm32f4",
|
||||||
"synopsys-usb-otg",
|
"synopsys-usb-otg",
|
||||||
"void",
|
"void",
|
||||||
|
@ -479,7 +542,7 @@ version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "461676dcf123675b3d3b02e2390e6a690cd186aacf2f439af7673c79e2561d53"
|
checksum = "461676dcf123675b3d3b02e2390e6a690cd186aacf2f439af7673c79e2561d53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cortex-m",
|
"cortex-m 0.6.7",
|
||||||
"usb-device",
|
"usb-device",
|
||||||
"vcell",
|
"vcell",
|
||||||
]
|
]
|
||||||
|
@ -491,9 +554,9 @@ dependencies = [
|
||||||
"bare-metal 1.0.0",
|
"bare-metal 1.0.0",
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cortex-m",
|
"cortex-m 0.6.7",
|
||||||
"cortex-m-log",
|
"cortex-m-log",
|
||||||
"cortex-m-rt",
|
"cortex-m-rt 0.6.13",
|
||||||
"eeprom24x",
|
"eeprom24x",
|
||||||
"heapless",
|
"heapless",
|
||||||
"log",
|
"log",
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -21,9 +21,9 @@ bare-metal = "1"
|
||||||
cortex-m = "0.6"
|
cortex-m = "0.6"
|
||||||
cortex-m-rt = { version = "0.6", features = ["device"] }
|
cortex-m-rt = { version = "0.6", features = ["device"] }
|
||||||
cortex-m-log = { version = "0.6", features = ["log-integration"] }
|
cortex-m-log = { version = "0.6", features = ["log-integration"] }
|
||||||
stm32f4xx-hal = { version = "0.8", features = ["rt", "stm32f427", "usb_fs"] }
|
stm32f4xx-hal = { version = "=0.10.1", features = ["rt", "stm32f427", "usb_fs"] }
|
||||||
stm32-eth = { version = "0.2", features = ["stm32f427", "smoltcp-phy"], git = "https://github.com/stm32-rs/stm32-eth.git" }
|
stm32-eth = { rev = "3759c5c9", features = ["stm32f427", "smoltcp-phy"], git = "https://github.com/stm32-rs/stm32-eth.git" }
|
||||||
smoltcp = { version = "0.6.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "log"] }
|
smoltcp = { version = "0.7.5", default-features = false, features = ["proto-ipv4", "socket-tcp", "log"] }
|
||||||
bit_field = "0.10"
|
bit_field = "0.10"
|
||||||
byteorder = { version = "1", default-features = false }
|
byteorder = { version = "1", default-features = false }
|
||||||
nom = { version = "5", default-features = false }
|
nom = { version = "5", default-features = false }
|
||||||
|
@ -38,10 +38,6 @@ heapless = "0.5"
|
||||||
serde-json-core = "0.1"
|
serde-json-core = "0.1"
|
||||||
sfkv = "0.1"
|
sfkv = "0.1"
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
# TODO: pending https://github.com/stm32-rs/stm32f4xx-hal/pull/239
|
|
||||||
stm32f4xx-hal = { git = "https://github.com/astro/stm32f4xx-hal.git", branch = "flash" }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
|
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; };
|
||||||
rustManifest = pkgs.fetchurl {
|
rustManifest = pkgs.fetchurl {
|
||||||
url = "https://static.rust-lang.org/dist/2020-10-30/channel-rust-nightly.toml";
|
url = "https://static.rust-lang.org/dist/2021-10-26/channel-rust-nightly.toml";
|
||||||
sha256 = "sha256-4NFISQPmGjbz534No4/ZbXaHT5xbjU25WXgj1MTH0TA=";
|
sha256 = "sha256-1hLbypXA+nuH7o3AHCokzSBZAvQxvef4x9+XxO3aBao=";
|
||||||
};
|
};
|
||||||
|
|
||||||
targets = [
|
targets = [
|
||||||
|
@ -35,8 +35,7 @@
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
outputHashes = {
|
outputHashes = {
|
||||||
"stm32-eth-0.2.0" = "sha256-HXRr/NDhdIKqyjdA4D8ZmcO1dDpDawdlYPUOwcEbPQk=";
|
"stm32-eth-0.2.0" = "sha256-48RpZgagUqgVeKm7GXdk3Oo0v19ScF9Uby0nTFlve2o=";
|
||||||
"stm32f4xx-hal-0.8.3" = "sha256-MOv7tVtVMxr3IYMaN0Q8EQWxv3rubmCxjXMXuw/ZKAw=";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl StoreBackend for FlashBackend {
|
||||||
|
|
||||||
fn program(&mut self, offset: usize, payload: &[u8]) -> Result<(), Self::Error> {
|
fn program(&mut self, offset: usize, payload: &[u8]) -> Result<(), Self::Error> {
|
||||||
self.flash.unlocked()
|
self.flash.unlocked()
|
||||||
.program(get_offset() + offset, payload.iter().cloned())
|
.program(get_offset() + offset, payload.iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backup_space(&self) -> &'static mut [u8] {
|
fn backup_space(&self) -> &'static mut [u8] {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![cfg_attr(not(test), no_std)]
|
#![cfg_attr(not(test), no_std)]
|
||||||
#![cfg_attr(not(test), no_main)]
|
#![cfg_attr(not(test), no_main)]
|
||||||
#![feature(maybe_uninit_extra, maybe_uninit_ref, asm)]
|
#![feature(maybe_uninit_extra, asm)]
|
||||||
#![cfg_attr(test, allow(unused))]
|
#![cfg_attr(test, allow(unused))]
|
||||||
// TODO: #![deny(warnings, unused)]
|
// TODO: #![deny(warnings, unused)]
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,14 @@ use core::cell::RefCell;
|
||||||
use cortex_m::interrupt::{CriticalSection, Mutex};
|
use cortex_m::interrupt::{CriticalSection, Mutex};
|
||||||
use stm32f4xx_hal::{
|
use stm32f4xx_hal::{
|
||||||
rcc::Clocks,
|
rcc::Clocks,
|
||||||
stm32::{interrupt, Peripherals, ETHERNET_MAC, ETHERNET_DMA},
|
pac::{interrupt, Peripherals, ETHERNET_MAC, ETHERNET_DMA},
|
||||||
};
|
};
|
||||||
use smoltcp::wire::{EthernetAddress, Ipv4Address, Ipv4Cidr};
|
use smoltcp::wire::{EthernetAddress, Ipv4Address, Ipv4Cidr};
|
||||||
use smoltcp::iface::{
|
use smoltcp::iface::{
|
||||||
EthernetInterfaceBuilder, EthernetInterface,
|
EthernetInterfaceBuilder, EthernetInterface,
|
||||||
NeighborCache, Routes,
|
NeighborCache, Routes,
|
||||||
};
|
};
|
||||||
use stm32_eth::{Eth, RingEntry, PhyAddress, RxDescriptor, TxDescriptor};
|
use stm32_eth::{Eth, RingEntry, RxDescriptor, TxDescriptor};
|
||||||
use crate::command_parser::Ipv4Config;
|
use crate::command_parser::Ipv4Config;
|
||||||
use crate::pins::EthernetPins;
|
use crate::pins::EthernetPins;
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ pub fn run<F>(
|
||||||
let mut eth_dev = Eth::new(
|
let mut eth_dev = Eth::new(
|
||||||
ethernet_mac, ethernet_dma,
|
ethernet_mac, ethernet_dma,
|
||||||
&mut rx_ring[..], &mut tx_ring[..],
|
&mut rx_ring[..], &mut tx_ring[..],
|
||||||
PhyAddress::_0,
|
|
||||||
clocks,
|
clocks,
|
||||||
eth_pins,
|
eth_pins,
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
76
src/pins.rs
76
src/pins.rs
|
@ -16,8 +16,8 @@ use stm32f4xx_hal::{
|
||||||
otg_fs::USB,
|
otg_fs::USB,
|
||||||
rcc::Clocks,
|
rcc::Clocks,
|
||||||
pwm::{self, PwmChannels},
|
pwm::{self, PwmChannels},
|
||||||
spi::{Spi, NoMiso},
|
spi::{Spi, NoMiso, TransferModeNormal},
|
||||||
stm32::{
|
pac::{
|
||||||
ADC1,
|
ADC1,
|
||||||
GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG,
|
GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG,
|
||||||
I2C1,
|
I2C1,
|
||||||
|
@ -25,6 +25,7 @@ use stm32f4xx_hal::{
|
||||||
SPI2, SPI4, SPI5,
|
SPI2, SPI4, SPI5,
|
||||||
TIM1, TIM3,
|
TIM1, TIM3,
|
||||||
},
|
},
|
||||||
|
timer::Timer,
|
||||||
time::U32Ext,
|
time::U32Ext,
|
||||||
};
|
};
|
||||||
use eeprom24x::{self, Eeprom24x};
|
use eeprom24x::{self, Eeprom24x};
|
||||||
|
@ -36,8 +37,8 @@ use crate::{
|
||||||
|
|
||||||
pub type Eeprom = Eeprom24x<
|
pub type Eeprom = Eeprom24x<
|
||||||
I2c<I2C1, (
|
I2c<I2C1, (
|
||||||
PB8<AlternateOD<stm32f4xx_hal::gpio::AF4>>,
|
PB8<AlternateOD<{ stm32f4xx_hal::gpio::AF4 }>>,
|
||||||
PB9<AlternateOD<stm32f4xx_hal::gpio::AF4>>
|
PB9<AlternateOD<{ stm32f4xx_hal::gpio::AF4 }>>
|
||||||
)>,
|
)>,
|
||||||
eeprom24x::page_size::B8,
|
eeprom24x::page_size::B8,
|
||||||
eeprom24x::addr_size::OneByte
|
eeprom24x::addr_size::OneByte
|
||||||
|
@ -45,8 +46,6 @@ pub type Eeprom = Eeprom24x<
|
||||||
|
|
||||||
pub type EthernetPins = EthPins<
|
pub type EthernetPins = EthPins<
|
||||||
PA1<Input<Floating>>,
|
PA1<Input<Floating>>,
|
||||||
PA2<Input<Floating>>,
|
|
||||||
PC1<Input<Floating>>,
|
|
||||||
PA7<Input<Floating>>,
|
PA7<Input<Floating>>,
|
||||||
PB11<Input<Floating>>,
|
PB11<Input<Floating>>,
|
||||||
PG13<Input<Floating>>,
|
PG13<Input<Floating>>,
|
||||||
|
@ -86,10 +85,10 @@ impl ChannelPins for Channel1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SPI peripheral used for communication with the ADC
|
/// SPI peripheral used for communication with the ADC
|
||||||
pub type AdcSpi = Spi<SPI2, (PB10<Alternate<AF5>>, PB14<Alternate<AF5>>, PB15<Alternate<AF5>>)>;
|
pub type AdcSpi = Spi<SPI2, (PB10<Alternate<AF5>>, PB14<Alternate<AF5>>, PB15<Alternate<AF5>>), TransferModeNormal>;
|
||||||
pub type AdcNss = PB12<Output<PushPull>>;
|
pub type AdcNss = PB12<Output<PushPull>>;
|
||||||
type Dac0Spi = Spi<SPI4, (PE2<Alternate<AF5>>, NoMiso, PE6<Alternate<AF5>>)>;
|
type Dac0Spi = Spi<SPI4, (PE2<Alternate<AF5>>, NoMiso, PE6<Alternate<AF5>>), TransferModeNormal>;
|
||||||
type Dac1Spi = Spi<SPI5, (PF7<Alternate<AF5>>, NoMiso, PF9<Alternate<AF5>>)>;
|
type Dac1Spi = Spi<SPI5, (PF7<Alternate<AF5>>, NoMiso, PF9<Alternate<AF5>>), TransferModeNormal>;
|
||||||
pub type PinsAdc = Adc<ADC1>;
|
pub type PinsAdc = Adc<ADC1>;
|
||||||
|
|
||||||
pub struct ChannelPinSet<C: ChannelPins> {
|
pub struct ChannelPinSet<C: ChannelPins> {
|
||||||
|
@ -192,15 +191,13 @@ impl Pins {
|
||||||
|
|
||||||
let leds = Leds::new(gpiod.pd9, gpiod.pd10.into_push_pull_output(), gpiod.pd11.into_push_pull_output());
|
let leds = Leds::new(gpiod.pd9, gpiod.pd10.into_push_pull_output(), gpiod.pd11.into_push_pull_output());
|
||||||
|
|
||||||
let eeprom_scl = gpiob.pb8.into_alternate_af4().set_open_drain();
|
let eeprom_scl = gpiob.pb8.into_alternate().set_open_drain();
|
||||||
let eeprom_sda = gpiob.pb9.into_alternate_af4().set_open_drain();
|
let eeprom_sda = gpiob.pb9.into_alternate().set_open_drain();
|
||||||
let eeprom_i2c = I2c::i2c1(i2c1, (eeprom_scl, eeprom_sda), 400.khz(), clocks);
|
let eeprom_i2c = I2c::new(i2c1, (eeprom_scl, eeprom_sda), 400.khz(), clocks);
|
||||||
let eeprom = Eeprom24x::new_24x02(eeprom_i2c, eeprom24x::SlaveAddr::default());
|
let eeprom = Eeprom24x::new_24x02(eeprom_i2c, eeprom24x::SlaveAddr::default());
|
||||||
|
|
||||||
let eth_pins = EthPins {
|
let eth_pins = EthPins {
|
||||||
ref_clk: gpioa.pa1,
|
ref_clk: gpioa.pa1,
|
||||||
md_io: gpioa.pa2,
|
|
||||||
md_clk: gpioc.pc1,
|
|
||||||
crs: gpioa.pa7,
|
crs: gpioa.pa7,
|
||||||
tx_en: gpiob.pb11,
|
tx_en: gpiob.pb11,
|
||||||
tx_d0: gpiog.pg13,
|
tx_d0: gpiog.pg13,
|
||||||
|
@ -213,8 +210,8 @@ impl Pins {
|
||||||
usb_global: otg_fs_global,
|
usb_global: otg_fs_global,
|
||||||
usb_device: otg_fs_device,
|
usb_device: otg_fs_device,
|
||||||
usb_pwrclk: otg_fs_pwrclk,
|
usb_pwrclk: otg_fs_pwrclk,
|
||||||
pin_dm: gpioa.pa11.into_alternate_af10(),
|
pin_dm: gpioa.pa11.into_alternate(),
|
||||||
pin_dp: gpioa.pa12.into_alternate_af10(),
|
pin_dp: gpioa.pa12.into_alternate(),
|
||||||
hclk: clocks.hclk(),
|
hclk: clocks.hclk(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,14 +227,14 @@ impl Pins {
|
||||||
mosi: PB15<M3>,
|
mosi: PB15<M3>,
|
||||||
) -> AdcSpi
|
) -> AdcSpi
|
||||||
{
|
{
|
||||||
let sck = sck.into_alternate_af5();
|
let sck = sck.into_alternate();
|
||||||
let miso = miso.into_alternate_af5();
|
let miso = miso.into_alternate();
|
||||||
let mosi = mosi.into_alternate_af5();
|
let mosi = mosi.into_alternate();
|
||||||
Spi::spi2(
|
Spi::new(
|
||||||
spi2,
|
spi2,
|
||||||
(sck, miso, mosi),
|
(sck, miso, mosi),
|
||||||
crate::ad7172::SPI_MODE,
|
crate::ad7172::SPI_MODE,
|
||||||
crate::ad7172::SPI_CLOCK.into(),
|
crate::ad7172::SPI_CLOCK,
|
||||||
clocks
|
clocks
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -246,13 +243,13 @@ impl Pins {
|
||||||
clocks: Clocks, spi4: SPI4,
|
clocks: Clocks, spi4: SPI4,
|
||||||
sclk: PE2<M1>, sync: PE4<M2>, sdin: PE6<M3>
|
sclk: PE2<M1>, sync: PE4<M2>, sdin: PE6<M3>
|
||||||
) -> (Dac0Spi, <Channel0 as ChannelPins>::DacSync) {
|
) -> (Dac0Spi, <Channel0 as ChannelPins>::DacSync) {
|
||||||
let sclk = sclk.into_alternate_af5();
|
let sclk = sclk.into_alternate();
|
||||||
let sdin = sdin.into_alternate_af5();
|
let sdin = sdin.into_alternate();
|
||||||
let spi = Spi::spi4(
|
let spi = Spi::new(
|
||||||
spi4,
|
spi4,
|
||||||
(sclk, NoMiso, sdin),
|
(sclk, NoMiso {}, sdin),
|
||||||
crate::ad5680::SPI_MODE,
|
crate::ad5680::SPI_MODE,
|
||||||
crate::ad5680::SPI_CLOCK.into(),
|
crate::ad5680::SPI_CLOCK,
|
||||||
clocks
|
clocks
|
||||||
);
|
);
|
||||||
let sync = sync.into_push_pull_output();
|
let sync = sync.into_push_pull_output();
|
||||||
|
@ -264,13 +261,13 @@ impl Pins {
|
||||||
clocks: Clocks, spi5: SPI5,
|
clocks: Clocks, spi5: SPI5,
|
||||||
sclk: PF7<M1>, sync: PF6<M2>, sdin: PF9<M3>
|
sclk: PF7<M1>, sync: PF6<M2>, sdin: PF9<M3>
|
||||||
) -> (Dac1Spi, <Channel1 as ChannelPins>::DacSync) {
|
) -> (Dac1Spi, <Channel1 as ChannelPins>::DacSync) {
|
||||||
let sclk = sclk.into_alternate_af5();
|
let sclk = sclk.into_alternate();
|
||||||
let sdin = sdin.into_alternate_af5();
|
let sdin = sdin.into_alternate();
|
||||||
let spi = Spi::spi5(
|
let spi = Spi::new(
|
||||||
spi5,
|
spi5,
|
||||||
(sclk, NoMiso, sdin),
|
(sclk, NoMiso {}, sdin),
|
||||||
crate::ad5680::SPI_MODE,
|
crate::ad5680::SPI_MODE,
|
||||||
crate::ad5680::SPI_CLOCK.into(),
|
crate::ad5680::SPI_CLOCK,
|
||||||
clocks
|
clocks
|
||||||
);
|
);
|
||||||
let sync = sync.into_push_pull_output();
|
let sync = sync.into_push_pull_output();
|
||||||
|
@ -307,21 +304,22 @@ impl PwmPins {
|
||||||
pin.enable();
|
pin.enable();
|
||||||
}
|
}
|
||||||
let channels = (
|
let channels = (
|
||||||
max_v0.into_alternate_af2(),
|
max_v0.into_alternate(),
|
||||||
max_v1.into_alternate_af2(),
|
max_v1.into_alternate(),
|
||||||
);
|
);
|
||||||
let (mut max_v0, mut max_v1) = pwm::tim3(tim3, channels, clocks, freq);
|
//let (mut max_v0, mut max_v1) = pwm::tim3(tim3, channels, clocks, freq);
|
||||||
|
let (mut max_v0, mut max_v1) = Timer::new(tim3, &clocks).pwm(channels, freq);
|
||||||
init_pwm_pin(&mut max_v0);
|
init_pwm_pin(&mut max_v0);
|
||||||
init_pwm_pin(&mut max_v1);
|
init_pwm_pin(&mut max_v1);
|
||||||
|
|
||||||
let channels = (
|
let channels = (
|
||||||
max_i_pos0.into_alternate_af1(),
|
max_i_pos0.into_alternate(),
|
||||||
max_i_pos1.into_alternate_af1(),
|
max_i_pos1.into_alternate(),
|
||||||
max_i_neg0.into_alternate_af1(),
|
max_i_neg0.into_alternate(),
|
||||||
max_i_neg1.into_alternate_af1(),
|
max_i_neg1.into_alternate(),
|
||||||
);
|
);
|
||||||
let (mut max_i_pos0, mut max_i_pos1, mut max_i_neg0, mut max_i_neg1) =
|
let (mut max_i_pos0, mut max_i_pos1, mut max_i_neg0, mut max_i_neg1) =
|
||||||
pwm::tim1(tim1, channels, clocks, freq);
|
Timer::new(tim1, &clocks).pwm(channels, freq);
|
||||||
init_pwm_pin(&mut max_i_pos0);
|
init_pwm_pin(&mut max_i_pos0);
|
||||||
init_pwm_pin(&mut max_i_neg0);
|
init_pwm_pin(&mut max_i_neg0);
|
||||||
init_pwm_pin(&mut max_i_pos1);
|
init_pwm_pin(&mut max_i_pos1);
|
||||||
|
|
|
@ -24,14 +24,14 @@ const TCP_TX_BUFFER_SIZE: usize = 2048;
|
||||||
/// Contains a number of server sockets that get all sent the same
|
/// Contains a number of server sockets that get all sent the same
|
||||||
/// data (through `fmt::Write`).
|
/// data (through `fmt::Write`).
|
||||||
pub struct Server<'a, 'b, S> {
|
pub struct Server<'a, 'b, S> {
|
||||||
net: EthernetInterface<'a, 'a, 'a, &'a mut stm32_eth::Eth<'static, 'static>>,
|
net: EthernetInterface<'a, &'a mut stm32_eth::Eth<'static, 'static>>,
|
||||||
sockets: SocketSet<'b, 'b, 'b>,
|
sockets: SocketSet<'b>,
|
||||||
states: [SocketState<S>; SOCKET_COUNT],
|
states: [SocketState<S>; SOCKET_COUNT],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, S: Default> Server<'a, 'b, S> {
|
impl<'a, 'b, S: Default> Server<'a, 'b, S> {
|
||||||
/// Run a server with stack-allocated sockets
|
/// Run a server with stack-allocated sockets
|
||||||
pub fn run<F>(net: EthernetInterface<'a, 'a, 'a, &'a mut stm32_eth::Eth<'static, 'static>>, f: F)
|
pub fn run<F>(net: EthernetInterface<'a, &'a mut stm32_eth::Eth<'static, 'static>>, f: F)
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Server<'a, '_, S>),
|
F: FnOnce(&mut Server<'a, '_, S>),
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,10 @@ static TIMER_MS: Mutex<RefCell<u32>> = Mutex::new(RefCell::new(0));
|
||||||
|
|
||||||
/// Setup SysTick exception
|
/// Setup SysTick exception
|
||||||
pub fn setup(syst: SYST, clocks: Clocks) {
|
pub fn setup(syst: SYST, clocks: Clocks) {
|
||||||
let mut timer = Timer::syst(syst, TIMER_RATE.hz(), clocks);
|
|
||||||
timer.listen(TimerEvent::TimeOut);
|
let timer = Timer::syst(syst, &clocks);
|
||||||
|
let mut countdown = timer.start_count_down(TIMER_RATE.hz());
|
||||||
|
countdown.listen(TimerEvent::TimeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SysTick exception (Timer)
|
/// SysTick exception (Timer)
|
||||||
|
|
Loading…
Reference in New Issue