Skip to content

Commit 738519b

Browse files
Merge pull request #75 from stm32-rs/async-await
Async await
2 parents 9987cbe + e2bfbe3 commit 738519b

27 files changed

+1953
-1253
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
env:
1111
CARGO_TERM_COLOR: always
12+
RUSTFLAGS: "-D warnings"
1213

1314
jobs:
1415
style:
@@ -90,16 +91,21 @@ jobs:
9091
run: |
9192
cargo build --release --target=${{ matrix.target }} --features ${{ matrix.features }}
9293
93-
build-no-ptp:
94-
name: build-no-ptp
94+
build-feature-mixer:
95+
name: build-feature-mixer
9596
runs-on: ubuntu-20.04
9697
strategy:
9798
matrix:
9899
target:
99100
- x86_64-unknown-linux-gnu
101+
features:
102+
- "ptp,async-await"
103+
- "ptp"
104+
- "async-await"
105+
- ""
100106
toolchain:
101107
- stable
102-
features:
108+
mcu:
103109
- stm32f107
104110
- stm32f407
105111
- stm32f745
@@ -115,7 +121,7 @@ jobs:
115121
116122
- name: cargo build
117123
run: |
118-
cargo build --release --target=${{ matrix.target }} --features ${{ matrix.features }} --no-default-features
124+
cargo build --release --target=${{ matrix.target }} --features "${{ matrix.mcu }}" --features "${{ matrix.features }}" --no-default-features
119125
120126
# Test that all of the examples compile
121127
# for stm32f429
@@ -204,7 +210,7 @@ jobs:
204210
- test
205211
- examples
206212
- examples-common
207-
- build-no-ptp
213+
- build-feature-mixer
208214
runs-on: ubuntu-20.04
209215
steps:
210216
- name: Mark the job as a success

CHANGELOG.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
## Unreleased
2-
* Update to `smoltcp` v0.9 ([#71](https://github.com/stm32-rs/stm32-eth/pull/71))
3-
* Add `timesync-server` and `timesync-client` examples ([#72](https://github.com/stm32-rs/stm32-eth/pull/72))
2+
* Update to `smoltcp` v0.9 ([#71])
3+
* Add `timesync-server` and `timesync-client` examples ([#72])
4+
* Remove argument from `eth_interrupt_handler` ([#75], fixes [#44])
5+
* [#75]
6+
* Make EthernetDMA drop safe
7+
* Add `EthernetDMA::split`: support for using RX and TX independently
8+
* Make the interrupt handler methods and `EthernetPTP::get_time` static FNs
9+
* Add feature `async-await`, used for accessing RX and/or TX asynchronously, as well as the ethernet PTP timestamp interrupt
10+
* Add `async-rtic-timestamp` exmaple (nightly only)
11+
12+
[#44]: https://github.com/stm32-rs/stm32-eth/issues/44
13+
[#71]: https://github.com/stm32-rs/stm32-eth/pull/71
14+
[#72]: https://github.com/stm32-rs/stm32-eth/pull/72
15+
[#75]: https://github.com/stm32-rs/stm32-eth/pull/75
416

517
## [0.4.1](https://github.com/stm32-rs/stm32-eth/tree/v0.4.1)
6-
* Fix a bug when caching timestamps in the TX path ([#73](https://github.com/stm32-rs/stm32-eth/pull/73))
18+
* Fix a bug when caching timestamps in the TX path ([#73])
19+
20+
[#73]: https://github.com/stm32-rs/stm32-eth/pull/73
721

822
## [0.4.0](https://github.com/stm32-rs/stm32-eth/tree/v0.4.0)
9-
* Remove the `smi` feature and always enable miim/smi. Use `ieee802_3_miim` for SMI access [#45](https://github.com/stm32-rs/stm32-eth/pull/45)
23+
* Remove the `smi` feature and always enable miim/smi. Use `ieee802_3_miim` for SMI access ([#45])
1024
* Update stm32f1xx-hal and stm32f4xx-hal to their latests version as of 15-12-2022.
11-
* Allow for configuration of MAC speed. ([#53](https://github.com/stm32-rs/stm32-eth/pull/53), fixes [#24](https://github.com/stm32-rs/stm32-eth/pull/24))
12-
* Fix [#57](https://github.com/stm32-rs/stm32-eth/issues/57). ([#58](https://github.com/stm32-rs/stm32-eth/pull/58))
13-
* Move all DMA related files into modules under `dma` ([#66](https://github.com/stm32-rs/stm32-eth/pull/66))
14-
* Add support for the PTP peripheral ([#66](https://github.com/stm32-rs/stm32-eth/pull/66))
15-
* Use `PartsIn` and `Parts` as structs for initalization & configuration ([#66](https://github.com/stm32-rs/stm32-eth/pull/66))
25+
* Allow for configuration of MAC speed. ([#53], fixes [#24])
26+
* Fix [#57](https://github.com/stm32-rs/stm32-eth/issues/57). ([#58])
27+
* Move all DMA related files into modules under `dma` ([#66])
28+
* Add support for the PTP peripheral ([#66])
29+
* Use `PartsIn` and `Parts` as structs for initalization & configuration ([#66])
1630
* CI
1731
* Test compilability of examples more extensively
1832
* Move away from actions-rs
@@ -26,10 +40,22 @@
2640
* Use a more simple `memory.x` that works for all supported MCUs
2741
* Add `rtic-timestamp` example
2842

43+
[#45]: https://github.com/stm32-rs/stm32-eth/pull/45
44+
[#24]: https://github.com/stm32-rs/stm32-eth/pull/24
45+
[#53]: https://github.com/stm32-rs/stm32-eth/pull/53
46+
[#58]: https://github.com/stm32-rs/stm32-eth/pull/58
47+
[#66]: https://github.com/stm32-rs/stm32-eth/pull/66
48+
2949
## [0.3.0](https://github.com/stm32-rs/stm32-eth/tree/v0.3.0)
3050

31-
* Enable ICMP, TCP, and UDP checksum offloading for IPv4 and IPv6. ([#48](https://github.com/stm32-rs/stm32-eth/pull/48))
32-
* Separate MAC and DMA into separate structs for separate access. ([#39](https://github.com/stm32-rs/stm32-eth/pull/39))
33-
* Add support for `stm32f107` and fix an MMC interrupt bug. ([#43](https://github.com/stm32-rs/stm32-eth/pull/43), [#42](https://github.com/stm32-rs/stm32-eth/pull/42), [#41](https://github.com/stm32-rs/stm32-eth/pull/41))
51+
* Enable ICMP, TCP, and UDP checksum offloading for IPv4 and IPv6. ([#48])
52+
* Separate MAC and DMA into separate structs for separate access. ([#39])
53+
* Add support for `stm32f107` and fix an MMC interrupt bug. ([#43], [#42], [#41])
3454
* Update the HALs and dependencies to their latest versions as of 12-07-2022.
3555
* Add more examples
56+
57+
[#48]: https://github.com/stm32-rs/stm32-eth/pull/48
58+
[#39]: https://github.com/stm32-rs/stm32-eth/pull/39
59+
[#43]: https://github.com/stm32-rs/stm32-eth/pull/43
60+
[#42]: https://github.com/stm32-rs/stm32-eth/pull/42
61+
[#41]: https://github.com/stm32-rs/stm32-eth/pull/41

Cargo.toml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ travis-ci = { repository = "astro/stm32-eth", branch = "master" }
1616
maintenance = { status = "experimental" }
1717

1818
[package.metadata.docs.rs]
19-
features = ["smoltcp-phy", "smoltcp/socket-raw", "stm32f429"]
19+
features = ["smoltcp-phy", "stm32f429", "async-await"]
2020

2121
[dependencies]
2222
volatile-register = "0.2"
@@ -29,6 +29,7 @@ ieee802_3_miim = "0.8"
2929
cortex-m = "0.7"
3030
log = { version = "0.4", optional = true }
3131
defmt = { version = "0.3", optional = true }
32+
futures = { version = "0.3", default-features = false, features = ["async-await"], optional = true }
3233

3334
[dependencies.smoltcp]
3435
version = "0.9"
@@ -40,6 +41,7 @@ default = [ "defmt", "ptp" ]
4041
device-selected = []
4142
fence = []
4243
ptp = [ ]
44+
async-await = ["dep:futures"]
4345

4446
stm32f107 = ["stm32f1xx-hal/stm32f107", "device-selected"]
4547

@@ -68,12 +70,30 @@ smoltcp-phy = ["smoltcp"]
6870
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
6971
cortex-m-rt = "0.7"
7072
fugit = "0.3"
71-
cortex-m-rtic = "1.0"
7273
defmt-rtt = "0.4"
7374
panic-probe = { version = "0.3", features = [ "print-defmt" ] }
7475
systick-monotonic = "1.0"
7576
smoltcp = { version = "0.9", features = [ "medium-ethernet", "proto-ipv4", "socket-udp", "socket-tcp", "defmt" ], default-features = false }
7677

78+
[dev-dependencies.rtic]
79+
package = "cortex-m-rtic"
80+
version = "1.0"
81+
82+
[dev-dependencies.async-rtic]
83+
package = "rtic"
84+
git = "https://github.com/rtic-rs/cortex-m-rtic.git"
85+
rev = "364edb707ebf7baa2e7bdd1b1e6b02156d7b5569"
86+
87+
[dev-dependencies.rtic-arbiter]
88+
package = "rtic-arbiter"
89+
git = "https://github.com/rtic-rs/cortex-m-rtic.git"
90+
rev = "364edb707ebf7baa2e7bdd1b1e6b02156d7b5569"
91+
92+
[dev-dependencies.rtic-channel]
93+
package = "rtic-channel"
94+
git = "https://github.com/rtic-rs/cortex-m-rtic.git"
95+
rev = "364edb707ebf7baa2e7bdd1b1e6b02156d7b5569"
96+
7797
# This isn't an actual example. It just exists so we can easily
7898
# test the common items :)
7999
[[example]]
@@ -110,6 +130,10 @@ name = "timesync-server"
110130
path = "./examples/timesync/server.rs"
111131
required-features = [ "defmt", "ptp" ]
112132

133+
[[example]]
134+
name = "async-rtic-timestamp"
135+
required-features = [ "defmt", "ptp", "async-await" ]
136+
113137
[profile.release]
114138
debug = 2
115139
lto = true

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,22 @@ fn main() {
7676
.unwrap();
7777
eth_dma.enable_interrupt();
7878
79-
if let Ok(pkt) = eth_dma.recv_next(None) {
80-
// handle received pkt
79+
loop {
80+
if let Ok(pkt) = eth_dma.recv_next(None) {
81+
// handle received pkt
82+
}
83+
84+
let size = 42;
85+
eth_dma.send(size, None, |buf| {
86+
// write up to `size` bytes into buf before it is being sent
87+
}).expect("send");
8188
}
89+
}
8290
83-
let size = 42;
84-
eth_dma.send(size, None, |buf| {
85-
// write up to `size` bytes into buf before it is being sent
86-
}).expect("send");
91+
use stm32_eth::stm32::interrupt;
92+
#[interrupt]
93+
fn ETH() {
94+
stm32_eth::eth_interrupt_handler();
8795
}
8896
```
8997

examples/arp.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,5 @@ fn ETH() {
147147
*eth_pending = true;
148148
});
149149

150-
// Clear interrupt flags
151-
let p = unsafe { Peripherals::steal() };
152-
stm32_eth::eth_interrupt_handler(&p.ETHERNET_DMA);
150+
stm32_eth::eth_interrupt_handler();
153151
}

0 commit comments

Comments
 (0)