Skip to content

Commit

Permalink
Merge pull request #99 from tlevora/smoltcp-0.12.0-upgrade
Browse files Browse the repository at this point in the history
Upgrade smoltcp to 0.12.0 & release v0.8.0
  • Loading branch information
datdenkikniet authored Dec 17, 2024
2 parents af986ea + 4b1cb72 commit f9811ec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Unreleased

## [0.8.0](https://github.com/stm32-rs/stm32-eth/tree/v0.8.0)
* Update version of `smoltcp` to `v0.12.0` ([#99])

[#99]: https://github.com/stm32-rs/stm32-eth/pull/99

## [0.7.0](https://github.com/stm32-rs/stm32-eth/tree/v0.7.0)
* Update hals ([#97])
* `stm32f4xx-hal` from `0.20` to `0.21`
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "stm32-eth"
description = "Embedded Rust Ethernet driver for the STM32 MCU series"
license = "Apache-2.0"
authors = ["Astro <[email protected]>", "Johannes Draaijer <[email protected]>"]
version = "0.7.0"
version = "0.8.0"
keywords = ["ethernet", "eth", "stm32", "stm32f4", "stm32f7"]
repository = "https://github.com/stm32-rs/stm32-eth"
documentation = "https://docs.rs/stm32-eth/"
Expand Down Expand Up @@ -32,7 +32,7 @@ defmt = { version = "0.3", optional = true }
futures = { version = "0.3", default-features = false, features = ["async-await"], optional = true }

[dependencies.smoltcp]
version = "0.11"
version = "0.12"
default-features = false
optional = true

Expand Down Expand Up @@ -73,7 +73,7 @@ fugit = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = [ "print-defmt" ] }
systick-monotonic = "1.0"
smoltcp = { version = "0.11", features = [ "medium-ethernet", "proto-ipv4", "socket-udp", "socket-tcp", "defmt" ], default-features = false }
smoltcp = { version = "0.12", features = [ "medium-ethernet", "proto-ipv4", "socket-udp", "socket-tcp", "defmt" ], default-features = false }

[dev-dependencies.rtic]
package = "cortex-m-rtic"
Expand Down
2 changes: 1 addition & 1 deletion examples/smoltcp-timesync/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ mod app {
let packet_id = dma.lock(|dma| dma.next_packet_id()).into();

let mut meta: udp::UdpMetadata = IpEndpoint {
addr: IpAddress::Ipv4(Ipv4Address([10, 0, 0, 1])),
addr: IpAddress::Ipv4(Ipv4Address::new(10, 0, 0, 1)),
port: 1337,
}
.into();
Expand Down
2 changes: 1 addition & 1 deletion examples/smoltcp-timesync/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ mod app {
let packet_id = dma.lock(|dma| dma.next_packet_id()).into();

let mut meta: udp::UdpMetadata = IpEndpoint {
addr: IpAddress::Ipv4(Ipv4Address([10, 0, 0, 2])),
addr: IpAddress::Ipv4(Ipv4Address::new(10, 0, 0, 2)),
port: 1337,
}
.into();
Expand Down
16 changes: 11 additions & 5 deletions src/dma/smoltcp_phy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ use smoltcp::time::Instant;

/// Use this Ethernet driver with [smoltcp](https://github.com/smoltcp-rs/smoltcp)
impl<'a, 'rx, 'tx> Device for &'a mut EthernetDMA<'rx, 'tx> {
type RxToken<'token> = EthRxToken<'token, 'rx> where Self: 'token;
type TxToken<'token> = EthTxToken<'token, 'tx> where Self: 'token;
type RxToken<'token>
= EthRxToken<'token, 'rx>
where
Self: 'token;
type TxToken<'token>
= EthTxToken<'token, 'tx>
where
Self: 'token;

fn capabilities(&self) -> DeviceCapabilities {
let mut caps = DeviceCapabilities::default();
Expand Down Expand Up @@ -72,7 +78,7 @@ pub struct EthRxToken<'a, 'rx> {
impl<'dma, 'rx> RxToken for EthRxToken<'dma, 'rx> {
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
F: FnOnce(&[u8]) -> R,
{
#[cfg(feature = "ptp")]
let meta = Some(self.meta.into());
Expand All @@ -81,8 +87,8 @@ impl<'dma, 'rx> RxToken for EthRxToken<'dma, 'rx> {
let meta = None;

// NOTE(unwrap): an `EthRxToken` is only created when `eth.rx_available()`
let mut packet = self.rx_ring.recv_next(meta).ok().unwrap();
let result = f(&mut packet);
let packet = self.rx_ring.recv_next(meta).ok().unwrap();
let result = f(&packet);
packet.free();
result
}
Expand Down

0 comments on commit f9811ec

Please sign in to comment.