Merge branch 'master' into update-hal
This commit is contained in:
commit
e51336dc90
|
@ -203,7 +203,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_miniconf"
|
name = "derive_miniconf"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa"
|
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#314fa5587d1aa28e1ad70106f19e30db646e9f28"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -343,7 +343,6 @@ dependencies = [
|
||||||
"as-slice",
|
"as-slice",
|
||||||
"generic-array 0.13.3",
|
"generic-array 0.13.3",
|
||||||
"hash32",
|
"hash32",
|
||||||
"serde",
|
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -356,6 +355,7 @@ dependencies = [
|
||||||
"as-slice",
|
"as-slice",
|
||||||
"generic-array 0.14.4",
|
"generic-array 0.14.4",
|
||||||
"hash32",
|
"hash32",
|
||||||
|
"serde",
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -392,9 +392,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "managed"
|
name = "managed"
|
||||||
version = "0.7.2"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c75de51135344a4f8ed3cfe2720dc27736f7711989703a0b43aadf3753c55577"
|
checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matrixmultiply"
|
name = "matrixmultiply"
|
||||||
|
@ -416,10 +416,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniconf"
|
name = "miniconf"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa"
|
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#314fa5587d1aa28e1ad70106f19e30db646e9f28"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_miniconf",
|
"derive_miniconf",
|
||||||
"heapless 0.5.6",
|
"heapless 0.6.1",
|
||||||
"minimq",
|
"minimq",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-json-core",
|
"serde-json-core",
|
||||||
|
@ -428,13 +428,13 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minimq"
|
name = "minimq"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/quartiq/minimq.git?branch=master#a89a6f11d0d1f63114fb15f676022eb4fe904f56"
|
source = "git+https://github.com/quartiq/minimq.git#933687c2e4bc8a4d972de9a4d1508b0b554a8b38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"embedded-nal",
|
"embedded-nal",
|
||||||
"enum-iterator",
|
"enum-iterator",
|
||||||
"generic-array 0.14.4",
|
"generic-array 0.14.4",
|
||||||
"heapless 0.5.6",
|
"heapless 0.6.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -459,7 +459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c0d5c9540a691d153064dc47a4db2504587a75eae07bf1d73f7a596ebc73c04"
|
checksum = "6c0d5c9540a691d153064dc47a4db2504587a75eae07bf1d73f7a596ebc73c04"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"matrixmultiply",
|
"matrixmultiply",
|
||||||
"num-complex",
|
"num-complex 0.3.1",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rawpointer",
|
"rawpointer",
|
||||||
|
@ -473,11 +473,11 @@ checksum = "2178127478ae4ee9be7180bc9c3bffb6354dd7238400db567102f98c413a9f35"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num"
|
name = "num"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f"
|
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-complex",
|
"num-complex 0.4.0",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-iter",
|
"num-iter",
|
||||||
"num-rational",
|
"num-rational",
|
||||||
|
@ -493,6 +493,15 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-complex"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.44"
|
version = "0.1.44"
|
||||||
|
@ -516,9 +525,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-rational"
|
name = "num-rational"
|
||||||
version = "0.3.2"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
|
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
|
@ -546,9 +555,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paste"
|
name = "paste"
|
||||||
version = "1.0.4"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1"
|
checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
|
@ -669,9 +678,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.123"
|
version = "1.0.124"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
|
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
@ -687,9 +696,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.123"
|
version = "1.0.124"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
|
checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -699,8 +708,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smoltcp"
|
name = "smoltcp"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/smoltcp-rs/smoltcp.git#43567b9743cb9f422de83fad9ff42a6d13f6e5ee"
|
||||||
checksum = "ab527c390c7e107f687bd92a886a083fde61b8cdc700b37f3d7e4346ffd8fae1"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -710,11 +718,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smoltcp-nal"
|
name = "smoltcp-nal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=main#56519012d7c6a382eaa0d7ecb26f2701771d9ce8"
|
||||||
checksum = "e4e5aeb4818706fd74c35917692008d29a5314483c8180300a582253718ce57a"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"embedded-nal",
|
"embedded-nal",
|
||||||
"heapless 0.5.6",
|
"heapless 0.6.1",
|
||||||
"smoltcp",
|
"smoltcp",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -732,7 +739,7 @@ dependencies = [
|
||||||
"embedded-hal",
|
"embedded-hal",
|
||||||
"enum-iterator",
|
"enum-iterator",
|
||||||
"generic-array 0.14.4",
|
"generic-array 0.14.4",
|
||||||
"heapless 0.5.6",
|
"heapless 0.6.1",
|
||||||
"log",
|
"log",
|
||||||
"mcp23017",
|
"mcp23017",
|
||||||
"miniconf",
|
"miniconf",
|
||||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -34,7 +34,7 @@ cortex-m-log = { version = "0.7", features = ["log-integration"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
panic-semihosting = { version = "0.5", optional = true }
|
panic-semihosting = { version = "0.5", optional = true }
|
||||||
serde = { version = "1.0", features = ["derive"], default-features = false }
|
serde = { version = "1.0", features = ["derive"], default-features = false }
|
||||||
heapless = { version = "0.5", features = ["serde"] }
|
heapless = { version = "0.6", features = ["serde"] }
|
||||||
cortex-m-rtic = "0.5.6"
|
cortex-m-rtic = "0.5.6"
|
||||||
embedded-hal = "0.2.4"
|
embedded-hal = "0.2.4"
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
|
@ -53,12 +53,20 @@ branch = "develop"
|
||||||
|
|
||||||
[patch.crates-io.minimq]
|
[patch.crates-io.minimq]
|
||||||
git = "https://github.com/quartiq/minimq.git"
|
git = "https://github.com/quartiq/minimq.git"
|
||||||
branch = "master"
|
|
||||||
|
[patch.crates-io.smoltcp-nal]
|
||||||
|
git = "https://github.com/quartiq/smoltcp-nal.git"
|
||||||
|
branch = "main"
|
||||||
|
|
||||||
[patch.crates-io.serde-json-core]
|
[patch.crates-io.serde-json-core]
|
||||||
git = "https://github.com/rust-embedded-community/serde-json-core.git"
|
git = "https://github.com/rust-embedded-community/serde-json-core.git"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
||||||
|
[patch.crates-io.smoltcp]
|
||||||
|
# We manually patch smoltcp so that we can get access to unreleased updates to the DHCP server. When
|
||||||
|
# a new release of smoltcp is made, we can remove this patch.
|
||||||
|
git = "https://github.com/smoltcp-rs/smoltcp.git"
|
||||||
|
|
||||||
[dependencies.mcp23017]
|
[dependencies.mcp23017]
|
||||||
git = "https://github.com/mrd0ll4r/mcp23017.git"
|
git = "https://github.com/mrd0ll4r/mcp23017.git"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
[![QUARTIQ Matrix Chat](https://img.shields.io/matrix/quartiq:matrix.org)](https://matrix.to/#/#quartiq:matrix.org)
|
[![QUARTIQ Matrix Chat](https://img.shields.io/matrix/quartiq:matrix.org)](https://matrix.to/#/#quartiq:matrix.org)
|
||||||
|
[![Continuous Integration](https://github.com/quartiq/stabilizer/actions/workflows/ci.yml/badge.svg)](https://github.com/quartiq/stabilizer/actions/workflows/ci.yml)
|
||||||
[![HITL (private)](https://github.com/quartiq/hitl/workflows/Stabilizer/badge.svg)](https://github.com/quartiq/hitl/actions?query=workflow%3AStabilizer)
|
[![HITL (private)](https://github.com/quartiq/hitl/workflows/Stabilizer/badge.svg)](https://github.com/quartiq/hitl/actions?query=workflow%3AStabilizer)
|
||||||
|
|
||||||
# Stabilizer Firmware
|
# Stabilizer Firmware
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
"138kpxzxs73zhmd4xi5kw3fddb05gac4mpngizm01831n1ycyhl0"
|
"06qsl59bljr637xcrplbij7ma8l7waryi4lkbd4fxjac0gqpn55s"
|
||||||
|
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
||||||
libm = "0.2.1"
|
libm = "0.2.1"
|
||||||
serde = { version = "1.0", features = ["derive"], default-features = false }
|
serde = { version = "1.0", features = ["derive"], default-features = false }
|
||||||
generic-array = "0.14"
|
generic-array = "0.14"
|
||||||
num = { version = "0.3.1", default-features = false }
|
num = { version = "0.4.0", default-features = false }
|
||||||
miniconf = "0.1"
|
miniconf = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -144,16 +144,31 @@ const APP: () = {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let sleep = c.resources.mqtt_interface.lock(|interface| {
|
let sleep = c.resources.mqtt_interface.lock(|interface| {
|
||||||
!interface.network_stack().poll(clock.current_ms())
|
match interface.network_stack().poll(clock.current_ms()) {
|
||||||
|
Ok(updated) => !updated,
|
||||||
|
Err(err) => {
|
||||||
|
log::info!("Network error: {:?}", err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if c.resources
|
match c
|
||||||
|
.resources
|
||||||
.mqtt_interface
|
.mqtt_interface
|
||||||
.lock(|interface| interface.update().unwrap())
|
.lock(|interface| interface.update())
|
||||||
{
|
{
|
||||||
c.spawn.settings_update().unwrap()
|
Ok(update) => {
|
||||||
} else if sleep {
|
if update {
|
||||||
cortex_m::asm::wfi();
|
c.spawn.settings_update().unwrap();
|
||||||
|
} else if sleep {
|
||||||
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(miniconf::MqttError::Network(
|
||||||
|
smoltcp_nal::NetworkError::NoIpAddress,
|
||||||
|
)) => {}
|
||||||
|
Err(error) => log::info!("Unexpected error: {:?}", error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,16 +208,31 @@ const APP: () = {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let sleep = c.resources.mqtt_interface.lock(|interface| {
|
let sleep = c.resources.mqtt_interface.lock(|interface| {
|
||||||
!interface.network_stack().poll(clock.current_ms())
|
match interface.network_stack().poll(clock.current_ms()) {
|
||||||
|
Ok(updated) => !updated,
|
||||||
|
Err(err) => {
|
||||||
|
log::info!("Network error: {:?}", err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if c.resources
|
match c
|
||||||
|
.resources
|
||||||
.mqtt_interface
|
.mqtt_interface
|
||||||
.lock(|interface| interface.update().unwrap())
|
.lock(|interface| interface.update())
|
||||||
{
|
{
|
||||||
c.spawn.settings_update().unwrap()
|
Ok(update) => {
|
||||||
} else if sleep {
|
if update {
|
||||||
cortex_m::asm::wfi();
|
c.spawn.settings_update().unwrap();
|
||||||
|
} else if sleep {
|
||||||
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(miniconf::MqttError::Network(
|
||||||
|
smoltcp_nal::NetworkError::NoIpAddress,
|
||||||
|
)) => {}
|
||||||
|
Err(error) => log::info!("Unexpected error: {:?}", error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,38 @@ use super::{
|
||||||
|
|
||||||
pub struct NetStorage {
|
pub struct NetStorage {
|
||||||
pub ip_addrs: [smoltcp::wire::IpCidr; 1],
|
pub ip_addrs: [smoltcp::wire::IpCidr; 1],
|
||||||
pub sockets: [Option<smoltcp::socket::SocketSetItem<'static>>; 1],
|
pub sockets: [Option<smoltcp::socket::SocketSetItem<'static>>; 2],
|
||||||
pub neighbor_cache:
|
pub neighbor_cache:
|
||||||
[Option<(smoltcp::wire::IpAddress, smoltcp::iface::Neighbor)>; 8],
|
[Option<(smoltcp::wire::IpAddress, smoltcp::iface::Neighbor)>; 8],
|
||||||
pub routes_cache:
|
pub routes_cache:
|
||||||
[Option<(smoltcp::wire::IpCidr, smoltcp::iface::Route)>; 8],
|
[Option<(smoltcp::wire::IpCidr, smoltcp::iface::Route)>; 8],
|
||||||
pub tx_storage: [u8; 4096],
|
pub tx_storage: [u8; 4096],
|
||||||
pub rx_storage: [u8; 4096],
|
pub rx_storage: [u8; 4096],
|
||||||
|
|
||||||
|
pub dhcp_rx_metadata: [smoltcp::socket::RawPacketMetadata; 1],
|
||||||
|
pub dhcp_tx_metadata: [smoltcp::socket::RawPacketMetadata; 1],
|
||||||
|
pub dhcp_tx_storage: [u8; 600],
|
||||||
|
pub dhcp_rx_storage: [u8; 600],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NetStorage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
NetStorage {
|
||||||
|
// Placeholder for the real IP address, which is initialized at runtime.
|
||||||
|
ip_addrs: [smoltcp::wire::IpCidr::Ipv6(
|
||||||
|
smoltcp::wire::Ipv6Cidr::SOLICITED_NODE_PREFIX,
|
||||||
|
)],
|
||||||
|
neighbor_cache: [None; 8],
|
||||||
|
routes_cache: [None; 8],
|
||||||
|
sockets: [None, None],
|
||||||
|
tx_storage: [0; 4096],
|
||||||
|
rx_storage: [0; 4096],
|
||||||
|
dhcp_tx_storage: [0; 600],
|
||||||
|
dhcp_rx_storage: [0; 600],
|
||||||
|
dhcp_rx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1],
|
||||||
|
dhcp_tx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1],
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The available networking devices on Stabilizer.
|
/// The available networking devices on Stabilizer.
|
||||||
|
@ -59,22 +84,6 @@ pub struct PounderDevices {
|
||||||
/// Static storage for the ethernet DMA descriptor ring.
|
/// Static storage for the ethernet DMA descriptor ring.
|
||||||
static mut DES_RING: ethernet::DesRing = ethernet::DesRing::new();
|
static mut DES_RING: ethernet::DesRing = ethernet::DesRing::new();
|
||||||
|
|
||||||
/// Static, global-scope network storage for the ethernet interface.
|
|
||||||
///
|
|
||||||
/// This is a static singleton so that the network storage can be referenced from all contexts.
|
|
||||||
static mut NET_STORE: NetStorage = NetStorage {
|
|
||||||
// Placeholder for the real IP address, which is initialized at runtime.
|
|
||||||
ip_addrs: [smoltcp::wire::IpCidr::Ipv6(
|
|
||||||
smoltcp::wire::Ipv6Cidr::SOLICITED_NODE_PREFIX,
|
|
||||||
)],
|
|
||||||
neighbor_cache: [None; 8],
|
|
||||||
routes_cache: [None; 8],
|
|
||||||
sockets: [None; 1],
|
|
||||||
|
|
||||||
tx_storage: [0; 4096],
|
|
||||||
rx_storage: [0; 4096],
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Configure the stabilizer hardware for operation.
|
/// Configure the stabilizer hardware for operation.
|
||||||
///
|
///
|
||||||
/// # Args
|
/// # Args
|
||||||
|
@ -516,17 +525,23 @@ pub fn setup(
|
||||||
|
|
||||||
unsafe { ethernet::enable_interrupt() };
|
unsafe { ethernet::enable_interrupt() };
|
||||||
|
|
||||||
let store = unsafe { &mut NET_STORE };
|
// Note(unwrap): The hardware configuration function is only allowed to be called once.
|
||||||
|
// Unwrapping is intended to panic if called again to prevent re-use of global memory.
|
||||||
|
let store =
|
||||||
|
cortex_m::singleton!(: NetStorage = NetStorage::new()).unwrap();
|
||||||
|
|
||||||
store.ip_addrs[0] = smoltcp::wire::IpCidr::new(
|
store.ip_addrs[0] = smoltcp::wire::IpCidr::new(
|
||||||
smoltcp::wire::IpAddress::v4(10, 34, 16, 103),
|
smoltcp::wire::IpAddress::Ipv4(
|
||||||
24,
|
smoltcp::wire::Ipv4Address::UNSPECIFIED,
|
||||||
|
),
|
||||||
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
let default_v4_gw = smoltcp::wire::Ipv4Address::new(10, 34, 16, 1);
|
|
||||||
let mut routes =
|
let mut routes =
|
||||||
smoltcp::iface::Routes::new(&mut store.routes_cache[..]);
|
smoltcp::iface::Routes::new(&mut store.routes_cache[..]);
|
||||||
routes.add_default_ipv4_route(default_v4_gw).unwrap();
|
routes
|
||||||
|
.add_default_ipv4_route(smoltcp::wire::Ipv4Address::UNSPECIFIED)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let neighbor_cache =
|
let neighbor_cache =
|
||||||
smoltcp::iface::NeighborCache::new(&mut store.neighbor_cache[..]);
|
smoltcp::iface::NeighborCache::new(&mut store.neighbor_cache[..]);
|
||||||
|
@ -538,36 +553,54 @@ pub fn setup(
|
||||||
.routes(routes)
|
.routes(routes)
|
||||||
.finalize();
|
.finalize();
|
||||||
|
|
||||||
let sockets = {
|
let (mut sockets, handles) = {
|
||||||
// Note(unsafe): Configuration is only called once, so we only access the global
|
let mut sockets =
|
||||||
// storage a single time.
|
smoltcp::socket::SocketSet::new(&mut store.sockets[..]);
|
||||||
let socket_storage = unsafe { &mut NET_STORE.sockets[..] };
|
|
||||||
let mut sockets = smoltcp::socket::SocketSet::new(socket_storage);
|
|
||||||
|
|
||||||
let tcp_socket = {
|
let tcp_socket = {
|
||||||
let rx_buffer = {
|
let rx_buffer = smoltcp::socket::TcpSocketBuffer::new(
|
||||||
// Note(unsafe): Configuration is only called once, so we only access the global
|
&mut store.rx_storage[..],
|
||||||
// storage a single time.
|
);
|
||||||
let storage = unsafe { &mut NET_STORE.rx_storage[..] };
|
let tx_buffer = smoltcp::socket::TcpSocketBuffer::new(
|
||||||
smoltcp::socket::TcpSocketBuffer::new(storage)
|
&mut store.tx_storage[..],
|
||||||
};
|
);
|
||||||
|
|
||||||
let tx_buffer = {
|
|
||||||
// Note(unsafe): Configuration is only called once, so we only access the global
|
|
||||||
// storage a single time.
|
|
||||||
let storage = unsafe { &mut NET_STORE.tx_storage[..] };
|
|
||||||
smoltcp::socket::TcpSocketBuffer::new(storage)
|
|
||||||
};
|
|
||||||
|
|
||||||
smoltcp::socket::TcpSocket::new(rx_buffer, tx_buffer)
|
smoltcp::socket::TcpSocket::new(rx_buffer, tx_buffer)
|
||||||
};
|
};
|
||||||
|
|
||||||
sockets.add(tcp_socket);
|
let handle = sockets.add(tcp_socket);
|
||||||
sockets
|
(sockets, [handle])
|
||||||
|
};
|
||||||
|
|
||||||
|
let dhcp_client = {
|
||||||
|
let dhcp_rx_buffer = smoltcp::socket::RawSocketBuffer::new(
|
||||||
|
&mut store.dhcp_rx_metadata[..],
|
||||||
|
&mut store.dhcp_rx_storage[..],
|
||||||
|
);
|
||||||
|
|
||||||
|
let dhcp_tx_buffer = smoltcp::socket::RawSocketBuffer::new(
|
||||||
|
&mut store.dhcp_tx_metadata[..],
|
||||||
|
&mut store.dhcp_tx_storage[..],
|
||||||
|
);
|
||||||
|
|
||||||
|
smoltcp::dhcp::Dhcpv4Client::new(
|
||||||
|
&mut sockets,
|
||||||
|
dhcp_rx_buffer,
|
||||||
|
dhcp_tx_buffer,
|
||||||
|
// Smoltcp indicates that an instant with a negative time is indicative that time is
|
||||||
|
// not yet available. We can't get the current instant yet, so indicate an invalid
|
||||||
|
// time value.
|
||||||
|
smoltcp::time::Instant::from_millis(-1),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
NetworkDevices {
|
NetworkDevices {
|
||||||
stack: smoltcp_nal::NetworkStack::new(interface, sockets),
|
stack: smoltcp_nal::NetworkStack::new(
|
||||||
|
interface,
|
||||||
|
sockets,
|
||||||
|
&handles,
|
||||||
|
Some(dhcp_client),
|
||||||
|
),
|
||||||
phy: lan8742a,
|
phy: lan8742a,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -825,6 +858,14 @@ pub fn setup(
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let cycle_counter = {
|
||||||
|
// Set TRCENA bit, which is required for DWT counter to tick. (This is also
|
||||||
|
// set automatically when running in the debugger, and only cleared on power
|
||||||
|
// reset, not on soft reset.)
|
||||||
|
core.DCB.enable_trace();
|
||||||
|
CycleCounter::new(core.DWT, ccdr.clocks.c_ck())
|
||||||
|
};
|
||||||
|
|
||||||
let stabilizer = StabilizerDevices {
|
let stabilizer = StabilizerDevices {
|
||||||
afes,
|
afes,
|
||||||
adcs,
|
adcs,
|
||||||
|
@ -833,7 +874,7 @@ pub fn setup(
|
||||||
net: network_devices,
|
net: network_devices,
|
||||||
adc_dac_timer: sampling_timer,
|
adc_dac_timer: sampling_timer,
|
||||||
timestamp_timer,
|
timestamp_timer,
|
||||||
cycle_counter: CycleCounter::new(core.DWT, ccdr.clocks.c_ck()),
|
cycle_counter,
|
||||||
};
|
};
|
||||||
|
|
||||||
// info!("Version {} {}", build_info::PKG_VERSION, build_info::GIT_VERSION.unwrap());
|
// info!("Version {} {}", build_info::PKG_VERSION, build_info::GIT_VERSION.unwrap());
|
||||||
|
|
Loading…
Reference in New Issue