Compare commits

...

810 Commits

Author SHA1 Message Date
ca3891bb8c executor: remove arch-xtensa.
It's been broken for months and nobody has noticed. The `esp*-hal` crates have
much better support.

Fixes #2234
Closes  #1912
2023-12-03 22:33:27 +01:00
9ba3aeada4 Merge pull request #2243 from peter9477/nrf52-approtect-fix
minimum build code for new APPROTECT is chip type-specific
2023-12-03 20:27:02 +00:00
dd62bb16e5 minimum build code for new APPROTECT is chip type-specific 2023-12-03 13:47:26 -05:00
a31ae52d1a Merge pull request #2240 from GrantM11235/fix-freq-off-by-one
stm32/timer: Fix frequency off-by-one
2023-12-02 08:13:50 +00:00
8c0e2748db stm32/timer: Fix frequency off-by-one 2023-12-01 22:09:15 -06:00
ce4dd67f3b Merge pull request #2236 from tshepang/patch-2
no_std and no_main can be used on stable
2023-12-01 18:10:27 +01:00
929fd551de Merge pull request #2235 from tshepang/patch-1
runtime.adoc: typo
2023-12-01 18:10:15 +01:00
33cfef871d no_std and no_main can be used on stable 2023-12-01 11:56:35 +02:00
270504d87d runtime.adoc: typo 2023-12-01 08:45:20 +02:00
fe8c46bce3 Merge pull request #2218 from embassy-rs/stable2
Remove nightly and unstable-traits features in preparation for 1.75.
2023-11-29 17:50:09 +01:00
c6989dfbca Remove nightly and unstable-traits features in preparation for 1.75. 2023-11-29 17:26:33 +01:00
384bad7bfa Merge pull request #2231 from embassy-rs/stable3
Update embedded-(hal,io,nal).
2023-11-29 17:12:30 +01:00
4634316749 Update embedded-(hal,io,nal). 2023-11-29 17:01:36 +01:00
1b9925e3da Move embassy-lora, lora examples to lora-phy repo. 2023-11-29 16:26:31 +01:00
b4bc9ac028 Merge pull request #2225 from bugadani/faq
(FAQ): How to fix issues with multiple crate versions
2023-11-28 11:41:49 +00:00
a3c99f0324 Add multiple dependency error faq 2023-11-28 08:12:23 +01:00
76f3a11f43 Merge pull request #2229 from jamesmunns/patch-3
(FAQ): Add time driver note
2023-11-28 06:31:35 +00:00
d63c052f0e Merge pull request #2228 from MaxiluxSystems/fix/shared-spi-no-time
embassy-embedded-hal: shared_bus/blocking/spi: fix build and behaviour when "time" feature disabled
2023-11-27 23:15:43 +00:00
2c9f4bce01 shared_bus/blocking/spi: fix build and behaviour when "time" disabled
new behaviour: check for DelayUs presence in operations instead of
shortcircuiting
2023-11-27 23:05:19 +00:00
74a6855f01 Update docs/modules/ROOT/pages/faq.adoc 2023-11-27 21:43:05 +01:00
f88aa9ce48 (FAQ): Add time driver note 2023-11-27 21:42:10 +01:00
3a8a950bb8 Merge pull request #2226 from AdinAck/faq-update-1
FAQ Update (1)
2023-11-27 18:59:53 +00:00
02305451b1 need be -> needed
Co-authored-by: Dániel Buga <bugadani@gmail.com>
2023-11-27 10:51:20 -08:00
a42aef7759 it's -> its
Co-authored-by: Dániel Buga <bugadani@gmail.com>
2023-11-27 10:51:05 -08:00
142f42fe90 ... 2023-11-27 10:44:47 -08:00
5844f5ce2d Update faq.adoc 2023-11-27 10:23:42 -08:00
e5fdd35bd6 Merge pull request #2223 from embassy-rs/use-executor-arena
tests: use executor task arena instead of TAIT.
2023-11-27 01:27:13 +00:00
0bd47c779b tests: use executor task arena instead of TAIT. 2023-11-27 01:23:49 +01:00
4481631326 Merge pull request #2222 from embassy-rs/f446-hil
f446 hil
2023-11-26 23:42:03 +00:00
cf13f70ea9 stm32/test: add stm32f446 (board not in HIL rig yet) 2023-11-27 00:38:57 +01:00
6bdacb4f69 stm32/sdmmc: use unwrap to ensure panics get printed to defmt. 2023-11-27 00:35:41 +01:00
ff3baf1e90 Merge pull request #2220 from jamesmunns/patch-2
Minor readme typo
2023-11-25 22:13:34 +00:00
d5dcbadbbe Minor readme typo 2023-11-25 22:31:03 +01:00
0ad0d27150 Merge pull request #2219 from embassy-rs/no-concat-bytes
cyw43: remove feature(concat_bytes).
2023-11-25 00:09:02 +00:00
03d500f548 cyw43: remove feature(concat_bytes). 2023-11-25 01:06:43 +01:00
8b46343b34 Merge pull request #2199 from adamgreig/stm32-dac
STM32 DAC: update to new PAC, combine ch1/ch2, fix trigger selection
2023-11-24 23:51:07 +00:00
a3ea01473a stm32: fix dac trait 2023-11-25 00:30:30 +01:00
cf84c8bfd1 WIP: use generated metapac from corresponding PR for CI 2023-11-25 00:30:29 +01:00
09d7950313 STM32 DAC: Rework DAC driver, support all families. 2023-11-25 00:29:45 +01:00
267cbaebe6 STM32 DAC: Disable circular writes with GPDMA as it doesn't yet support circular transfers 2023-11-25 00:29:45 +01:00
31fc337e2f STM32 DAC: Swap to new TSEL enum entirely in-HAL 2023-11-25 00:29:45 +01:00
135f350020 STM32 DAC: Use new Mode enum for setting channel mode 2023-11-25 00:29:45 +01:00
897663e023 STM32: Add cfg to differentiate L4 and L4+ families 2023-11-25 00:29:45 +01:00
2218d30c80 STM32: Remove vestigal build.rs cfgs, add new flashsize_X and package_X cfgs, use in F3 RCC 2023-11-25 00:29:45 +01:00
f5c9e3baa6 Merge pull request #2200 from barnabywalters/asynci2cv1
Implemented async I2C for v1
2023-11-24 23:08:47 +00:00
47bac9df70 Merge pull request #2216 from embassy-rs/stable
executor: add support for main/task macros in stable Rust
2023-11-24 22:57:46 +00:00
3efc3eee57 stm32/i2c: implement async i2c v1. 2023-11-24 23:55:46 +01:00
bc65b8f7ec stm32/i2c: add async, dual interrupt scaffolding. 2023-11-24 23:55:45 +01:00
78f8e6112a Merge pull request #2217 from embassy-rs/no-try
embassy-embedded-hal: don't use feature(try_blocks).
2023-11-24 22:55:02 +00:00
996c3c1f7e executor: make task arena size configurable. 2023-11-24 23:52:09 +01:00
171cdb94c7 executor: add support for main/task macros in stable (allocates tasks in an arena) 2023-11-24 23:52:09 +01:00
1fbc150fd6 executor: add some tests. 2023-11-24 23:52:09 +01:00
259cf6192b executor: Remove non-functional rtos-trace-interrupt. 2023-11-24 23:52:09 +01:00
5528c33649 embassy-embedded-hal: don't use feature(try_blocks). 2023-11-24 18:44:55 +01:00
e8ff5a2baf Merge pull request #2215 from andresv/stm32-allow-eha-without-time
stm32 i2c: allow EHA traits without time feature
2023-11-24 15:34:44 +00:00
4f8c79c911 stm32 i2c: allow EHA traits without time feature 2023-11-24 15:56:19 +02:00
738971938a Merge pull request #2214 from aspizu/patch-1
add faq for deploying to RP2040 using elf2uf2-rs
2023-11-24 12:01:38 +00:00
jan
dec7c1a28b add faq for deploying to RP2040 using elf2uf2-rs 2023-11-24 04:10:13 +05:30
e0727fe1f6 Merge pull request #2211 from embassy-rs/cache-lockfiles
ci: cache lockfiles
2023-11-21 16:37:47 +00:00
ba9cc102e2 ci: cache lockfiles
- Removes the slow "updating crates.io index, updating git" at start of the job.
- Avoids CI being randomly slower if a widely-used dep (like serde) gets bumped causing rebuilding everything.
2023-11-21 17:33:07 +01:00
32b59148a8 Merge pull request #2210 from embassy-rs/lulf-patch-1
fix: faq.adoc syntax
2023-11-21 15:04:43 +00:00
bd2e6b0422 Update faq.adoc 2023-11-21 16:01:46 +01:00
85059f693b Merge pull request #2209 from bugadani/faq
Direct the ESP32 users towards esp-hal
2023-11-21 15:54:04 +01:00
c211d51c06 Add note for Xtensa 2023-11-21 15:53:30 +01:00
7f1fd199bb Merge pull request #2207 from mickvangelderen/split-can-bus-2
Split can bus 2
2023-11-21 14:45:10 +00:00
5ddd2cf9a6 Merge pull request #2208 from jamesmunns/add-faq
Add FAQ with one question from chat
2023-11-21 14:42:28 +00:00
88f893da45 Format 2023-11-21 15:40:07 +01:00
aedd41eac4 Add FAQ with one question from chat 2023-11-21 15:38:33 +01:00
19ba7da3fd Rename _flush* methods 2023-11-21 15:37:38 +01:00
06a83c0f89 Refactor bxcan split. 2023-11-21 15:34:34 +01:00
766ec77ec5 Merge pull request #2198 from adamgreig/stm32-opamp
STM32: Don't enable opamps in new(), wait until configured
2023-11-20 22:47:19 +00:00
d1af696605 STM32 opamp: use impl Peripheral instead of directly taking pins 2023-11-20 21:35:05 +00:00
2386619f1f STM32: Disable opamp when OpAmpOutput is dropped, not when the parent OpAmp is dropped 2023-11-20 21:17:09 +00:00
382949e1ff Merge pull request #2197 from MabezDev/priority-channel
Priority channel
2023-11-20 11:34:33 +00:00
454828accb revert module changes, reexport heapless relevant items 2023-11-20 11:28:31 +00:00
cf82fa687c Merge pull request #2192 from RobertTDowling/stm32h7-adc-clock
stm32h7 ADC: Fix stalled clock in default h7 config
2023-11-20 00:00:25 +00:00
7f258cd3c4 PR feedback 2023-11-19 15:56:34 -08:00
3a939fb511 Merge pull request #2204 from Slowki/fix/igmp-compile-error
populate `medium` in DriverAdapter struct in IGMP code
2023-11-19 22:43:55 +00:00
b8e9e00b44 add build with igmp enabled to ci.sh 2023-11-19 17:26:16 -05:00
ff2f1049b1 Merge pull request #2139 from jamesmunns/patch-1
Update RP2040 memory.x
2023-11-19 22:17:27 +00:00
be17e1b363 populate medium in DriverAdapter struct in IGMP code 2023-11-19 17:11:56 -05:00
f3c77e59c4 Add docs, touch all linker fragments 2023-11-19 23:10:11 +01:00
30424d83ff Update RP2040 memory.x
The RP2040 has 264KiB of memory, not 256KiB.
2023-11-19 23:10:11 +01:00
e3be0b957a Merge pull request #2203 from embassy-rs/h7-sai4only-fix
stm32/sai: fix build on chips with only SAI4 (like stm32h725re), improve sync config.
2023-11-19 21:13:01 +00:00
5221705495 stm32/sai: fix build on chips with only SAI4 (like stm32h725re), improve sync config. 2023-11-19 22:06:05 +01:00
814e096d22 STM32: Don't enable opamps in new(), wait until configured. 2023-11-18 19:37:56 +00:00
5a60024af7 docs 2023-11-18 15:09:41 +00:00
f482a105b8 more clean up, refactor channel into module to share code 2023-11-18 15:01:12 +00:00
7589b5e13e reduce duplication further by sharing Dynamic sender/receiver 2023-11-18 14:56:29 +00:00
2efa73f431 docs and simple test for priority 2023-11-18 14:37:15 +00:00
270ec324b0 Reduce duplication, fix tests 2023-11-18 14:31:09 +00:00
ca0d02933b Priority channel using binary heap 2023-11-18 14:21:43 +00:00
5bc7557826 Merge pull request #2173 from andresv/expose-i2c-async-api-without-time
STM32 I2C: expose async API without needing "time" feature.
2023-11-17 23:47:46 +00:00
4947b13615 stm32h7 ADC: Fix stalled clock in default h7 config 2023-11-15 17:11:16 -08:00
006260fedd Merge pull request #2184 from sammko/cyw43-multicast-macs
cyw43: Add Control method to add multicast HW address
2023-11-16 00:09:15 +00:00
e3ee24017d cyw43: Add Control method to add multicast HW address 2023-11-16 00:05:13 +00:00
467b53076c Merge pull request #2189 from embassy-rs/executor-hax
executor: add faster ARM-specific impl.
2023-11-15 18:16:40 +00:00
27e6634c9d executor: add faster ARM-specific impl.
Does a wake+poll in 79 cycles in nrf52840.
2023-11-15 18:47:11 +01:00
1f9b649f80 executor: release v0.3.3 2023-11-15 18:44:01 +01:00
bef9b7a853 executor: remove atomic-polyfill. 2023-11-15 18:43:27 +01:00
50a983fd9b executor: add missing main macro reexport on xtensa. 2023-11-14 18:45:23 +01:00
7e5deae589 Merge pull request #2170 from korken89/fix/embassy-net-dns
Fix for embassy net dns entries not being extensible
2023-11-14 07:56:08 +00:00
a2c440ef8c Update changelog 2023-11-14 08:50:51 +01:00
fd670a9ae5 Use smoltcp constant in results from DNS 2023-11-14 08:50:51 +01:00
ef69f386ab Update smoltcp and fix errors from that 2023-11-14 08:50:51 +01:00
872f1ec4c2 Merge pull request #2183 from embassy-rs/buffereduarte-fix
nrf/buffered_uarte: fix missing hwfc enable.
2023-11-13 23:26:19 +00:00
6ccd8c051e nrf/buffered_uarte: add test for recovering from buffer full. 2023-11-14 00:22:30 +01:00
c46418f123 nrf/buffered_uarte: fix hang when buffer full due to PPI missing the endrx event.
Fixes #2181
2023-11-14 00:22:17 +01:00
19ff043acd nrf/buffered_uarte: fix missing hwfc enable. 2023-11-13 22:37:13 +01:00
ea99671729 Merge pull request #2180 from MaxiluxSystems/gpdma-drop-fix
stm32/gpdma: fix drop() to use documented method for aborting transfer
2023-11-13 16:53:50 +00:00
8eff749823 stm32/gpdma: fix drop() to use RM's method for aborting transfer
see e.g. STM32H503 RM section 15.4.4...

1. Write 1 into GPDMA_CxCR.SUSP
2. Poll GPDMA_CxSR.SUSPF until it is 1
3. Write 1 into GPDMA_CxCR.RESET (occurs upon next init, in new_inner())
2023-11-13 16:41:09 +00:00
cdcd3e26dd Merge pull request #2179 from t-moe/features/embassy-futures-bump
Bump embassy-futures 0.1.0 -> 0.1.1
2023-11-13 11:40:09 +00:00
18c1f9dd56 Bump embassy-futures 0.1.0 -> 0.1.1 2023-11-13 11:25:11 +01:00
ac7134ed0d Merge pull request #2178 from embassy-rs/rcc-no-spaghetti
stm32/rcc: unify f2 into f4/f7.
2023-11-13 01:08:27 +00:00
ace5221080 stm32/rcc: unify f2 into f4/f7. 2023-11-13 01:59:33 +01:00
2376b3bdfa stm32/rcc: fix pll enum naming on f4, f7. 2023-11-13 01:56:50 +01:00
f00e97a5f1 Merge pull request #2177 from embassy-rs/rcc-no-spaghetti
stm32/rcc: unify l0l1 and l4l5.
2023-11-13 00:46:43 +00:00
066dc297ed stm32/rcc: unify l0l1 and l4l5. 2023-11-13 01:05:07 +01:00
4fe344ebc0 stm32/rcc: consistent casing and naming for PLL enums. 2023-11-13 00:52:01 +01:00
0f2208c0af stm32 i2c: remove mod dummy_time 2023-11-11 14:29:24 +02:00
6c42885d4a stm32 i2c: remove pub _timeout api 2023-11-11 14:05:58 +02:00
39c7371621 Merge pull request #2163 from embassy-rs/update-heapless
Update heapless to v0.8
2023-11-10 15:51:33 +00:00
4647df14b1 Update heapless to v0.8, embedded-nal-async to v0.7 2023-11-10 16:43:53 +01:00
3b33cc4691 i2c: expose async api without needing time
This exposes I2C async API without needing "time" feature. With "time" feature additional async API with timeouts is exposed.
2023-11-10 16:04:25 +02:00
b3367be9c8 Merge pull request #2161 from xoviat/low-power
add low power for g4
2023-11-09 01:16:02 +00:00
da4feb3693 Merge branch 'main' of github.com:embassy-rs/embassy into low-power 2023-11-08 19:13:12 -06:00
05a4bb3a4a rustfmt 2023-11-08 19:06:29 -06:00
4b4c28d875 stm32: add low power for g4 2023-11-08 19:04:20 -06:00
1977acdb11 Merge pull request #2164 from embassy-rs/msos-descriptor
usb: remove msos-descriptor feature.
2023-11-08 22:23:37 +00:00
0b015bd727 usb: remove msos-descriptor feature. 2023-11-08 23:21:52 +01:00
79acb560ec Pin noproto git rev. 2023-11-08 23:05:00 +01:00
94586576a0 Merge pull request #2160 from Nigecat/main
Fix typo in embassy-net docs
2023-11-07 23:56:03 +00:00
a3e200d011 Fix typo in embassy-net docs 2023-11-08 09:28:33 +11:00
3bccb67231 Merge pull request #2155 from xoviat/eth
stm32: resolve eth/v2 security bug
2023-11-07 21:42:55 +00:00
553f0158c0 stm32: resolve eth/v2 security bug
fixes #2129
2023-11-07 15:39:06 -06:00
b44a5fcaf6 Merge pull request #2159 from kalkyl/usb-bulk-cleanup
rp: Remove control handler from USB raw bulk example
2023-11-07 19:52:11 +00:00
8effff3383 rp: Remove control handler from USB raw bulk example 2023-11-07 20:45:01 +01:00
05f983c607 Merge pull request #2158 from kalkyl/usb-bulk
rp: Add USB raw bulk example
2023-11-07 19:22:55 +00:00
d44383e9a7 fmt 2023-11-07 20:19:56 +01:00
37a773c037 Use driver reexport 2023-11-07 20:17:19 +01:00
d1adc93614 rp: Add USB raw bulk example 2023-11-07 19:57:05 +01:00
78a7ee7ec4 Merge pull request #2157 from kalkyl/usb-raw
rp: Add USB raw example + msos-descriptor to examples and usb-logger
2023-11-07 10:30:52 +00:00
e3fe13e905 Add docs 2023-11-07 10:58:35 +01:00
38bfa6916f Update pio-uart example 2023-11-07 09:15:21 +01:00
50139752bc Add comments 2023-11-07 09:10:18 +01:00
db4cd73894 rp: Add USB raw example + msos descriptor to examples and usb-logger 2023-11-07 09:05:10 +01:00
8369f7614a Merge pull request #2156 from adamgreig/usb-raw-example
Update stm32 usb_raw example to use MSOS descriptors for WinUSB
2023-11-07 02:35:59 +00:00
326bc98bd2 Update stm32 usb_raw example to use MSOS descriptors for WinUSB 2023-11-07 02:34:27 +00:00
584fc358fd Merge pull request #2154 from bugadani/executor
Prepare embassy-executor 0.3.2
2023-11-06 20:53:19 +00:00
b8f9341edc Prepare embassy-executor 0.3.2 2023-11-06 21:50:40 +01:00
7ca557b917 Merge pull request #2152 from bugadani/atomic
Executor: Yeet core::sync::atomic from risc-v
2023-11-06 18:46:50 +00:00
8d8d50cc7a Yeet core::sync::atomic, remove futures-util dep 2023-11-06 17:35:02 +01:00
5948d934d3 Merge pull request #2150 from bugadani/block
Ensure TcpIo not blocking when reading into empty slice
2023-11-06 12:44:15 +00:00
746936f8cd Merge pull request #2151 from eZioPan/rcc-init-set-vos
check PLL settings before set VOS
2023-11-06 12:43:29 +00:00
8f543062aa check PLL settings before set VOS 2023-11-06 18:30:59 +08:00
15660cfc68 Ensure TcpIo not blocking when reading into empty slice 2023-11-06 09:12:16 +01:00
74f70dc7b4 Merge pull request #2149 from embassy-rs/usb-fixes3
stm32/otg: fix enumeration on non-f4 chips.
2023-11-06 03:19:50 +00:00
7084570478 stm32/otg: fix enumeration on non-f4 chips.
Fixes regression from #2148
2023-11-06 04:13:06 +01:00
58719dcb58 Merge pull request #2148 from embassy-rs/usb-fixes3
stm32/otg: fix CONTROL OUT transfers on F4.
2023-11-06 02:46:38 +00:00
b4eef6b1ee stm32/otg: fix CONTROL OUT transfers on F4. 2023-11-06 03:38:42 +01:00
70a700e430 stm32/otg: log TRDT 2023-11-06 03:38:13 +01:00
b8679c0cc8 stm32/rcc: set highest VOS on some F4s with no overdrive. 2023-11-06 03:37:39 +01:00
ad861179cc Merge pull request #2147 from xoviat/low-power
stm32: update metapac and use stop data
2023-11-06 02:35:57 +00:00
d9b00c01e0 usb: reject instead of panic on CONTROL OUT longer than the buf. 2023-11-06 03:26:00 +01:00
239ad5ebea stm32: update metapac and use stop data 2023-11-05 20:09:33 -06:00
46cffcc8d4 Merge pull request #2119 from JuliDi/fmc-sram-adc
STM32: Add raw access to FMC peripheral and fix typo in build.rs
2023-11-06 01:31:56 +00:00
e6462f1e88 Merge pull request #2146 from adamgreig/stm32g4-opamp
Remove accidentally leftover println
2023-11-06 01:15:55 +00:00
d464d1a841 Remove accidentally leftover println 2023-11-06 01:11:57 +00:00
980c3cf42b Merge pull request #2142 from adamgreig/stm32g4-opamp
stm32: support internal output on g4 opamps
2023-11-06 00:01:34 +00:00
28eb4cd817 stm32: support internal output on g4 opamps 2023-11-05 23:57:15 +00:00
3de01bc223 Merge pull request #2145 from embassy-rs/rcc-no-spaghetti
stm32/rcc: add shared code for hsi48 with crs support.
2023-11-05 22:58:18 +00:00
0272deb158 stm32/rcc: add shared code for hsi48 with crs support. 2023-11-05 23:52:54 +01:00
c4a8b79dbc Merge pull request #2143 from adamgreig/raw-usb-example
Add raw USB example using control transfers
2023-11-05 17:34:58 +00:00
fa45dcd034 Add raw USB example using control transfers 2023-11-05 16:46:45 +00:00
6ff91851b1 Merge pull request #2141 from embassy-rs/l0l1-modernize
stm32/rcc: switch to modern api for l0, l1.
2023-11-05 02:09:48 +00:00
8911a4d855 stm32/rcc: switch to modern api for l0, l1. 2023-11-05 03:06:13 +01:00
056c409443 Merge pull request #2140 from xoviat/low-power
stm32: compute stop mode and workaround rtt test bug
2023-11-04 18:57:44 +00:00
3f2abd4fd5 Merge branch 'main' of github.com:embassy-rs/embassy into low-power 2023-11-04 13:51:11 -05:00
dc467e89a0 stm32: compute stop mode and workaround rtt test bug 2023-11-04 13:49:54 -05:00
655ed3aa88 Merge pull request #2122 from bgamari/wip/low-power-docs
stm32: Add some documentation to `low_power`
2023-11-04 16:26:41 +00:00
14ec0d27bf Merge pull request #2138 from kalkyl/pwm-input
rp: Add PWM input example
2023-11-02 23:42:31 +00:00
649f1a122a Cleanup 2023-11-03 00:41:16 +01:00
413b394d31 rp: Add PWM input example 2023-11-03 00:37:58 +01:00
7ea2c3508a Merge pull request #2137 from kalkyl/pio-rotary-encoder
rp: Add PIO rotary encoder example
2023-11-02 21:52:01 +00:00
ec744558b2 Cleanup 2023-11-02 22:37:03 +01:00
1b9292dbcd Merge pull request #2136 from embassy-rs/static-cell-v2
Upgrade static-cell to v2.0
2023-11-02 21:00:21 +00:00
44486c5b39 rp: Add PIO rotary encoder example 2023-11-02 21:54:20 +01:00
1f51367eb9 Upgrade static-cell to v2.0 2023-11-02 21:52:07 +01:00
d6f42eafad Merge pull request #2135 from newAM/update-ehm
embedded-hal-mock: git -> 0.10.0-rc.1
2023-11-02 01:05:56 +00:00
dcce8945af embedded-hal-mock: git -> 0.10.0-rc.1 2023-11-01 16:46:15 -07:00
d98c064bfe Merge pull request #2134 from xoviat/revert-rcc
stm32/rcc: revert part of #2106
2023-11-01 22:31:43 +00:00
a904538555 stm32/rcc: revert part of #2106 2023-11-01 17:27:33 -05:00
4ef3dc5b90 Merge pull request #2099 from xoviat/rtc
stm32/rtc: misc and low-power cleanup
2023-11-01 22:19:03 +00:00
bab61f9665 stm32/rtc: misc. cleanup and move to bps by default 2023-11-01 17:17:14 -05:00
2765f0978f Merge pull request #2133 from Radiator-Labs/main
Reinstate rcc::Config adc_clock_source field
2023-11-01 20:35:03 +00:00
bc07539133 Fix missed field in cfg'd code 2023-11-01 13:30:04 -07:00
b4a82b7ed4 Correct adc_clock_source for all µprocs in l4l5.rs 2023-11-01 13:22:50 -07:00
e2688dda22 Eliminates redefinition of AdcClockSource 2023-11-01 12:06:19 -07:00
d0d8585e4c Reinstate rcc::Config adc_clock_source field 2023-11-01 11:46:17 -07:00
729d69246a Merge pull request #2131 from adamgreig/stm32-exti-high-channels
stm32: Don't try handle EXTI inputs above 16
2023-11-01 04:35:31 +00:00
e78a6db151 stm32: Don't try handle EXTI inputs above 16 2023-11-01 05:23:34 +01:00
f8721c3786 Merge pull request #2132 from embassy-rs/update-nightly
Update Rust nightly.
2023-11-01 04:10:03 +00:00
e519e00265 Update Rust nightly. 2023-11-01 04:56:56 +01:00
35bb20abe7 Merge pull request #2130 from andresovela/time-mock-driver-fix
time: fix MockDriver::now()
2023-10-31 23:36:56 +00:00
dd6a29adb2 Release embassy-executor v0.3.1 2023-11-01 00:17:44 +01:00
5f9602d28b time: fix MockDriver::now() 2023-10-31 22:48:52 +01:00
74683c706b Merge pull request #2127 from bugadani/release
Prepare embassy-net 0.2.1 and embassy-sync 0.4.0
2023-10-31 15:57:51 +00:00
2795e1350d Merge pull request #2128 from bugadani/poll
Drop `futures` dependency in `embassy-nrf`
2023-10-31 15:53:54 +00:00
aed3e5674f Drop futures dependency in embassy-nrf 2023-10-31 10:13:27 +01:00
d941882066 Prepare embassy-net 0.2.1 and embassy-sync 0.4.0 2023-10-31 09:33:27 +01:00
3f74ff7235 Merge pull request #2123 from bugadani/feature
Re-add impl_trait_projections
2023-10-31 02:26:51 +01:00
9cead47212 Merge pull request #2124 from kalkyl/pio-stepper
rp: Add PIO stepper motor driver example
2023-10-31 02:26:38 +01:00
78739d4aa9 Merge pull request #2120 from andresovela/time-mock-driver
time: add `MockDriver` for testing purposes
2023-10-31 01:10:19 +00:00
e07e790613 Merge pull request #2125 from MabezDev/fix-rtc-dow
stm32: RTC fix DoW range off-by-one error
2023-10-30 23:20:45 +00:00
ca283eed0c Merge pull request #2126 from embassy-rs/disable-stop-test
stm32/tests: disable stop test.
2023-10-30 23:17:53 +00:00
57edf289ea stm32/tests: disable stop test. 2023-10-31 00:04:15 +01:00
3912f5d67b Fix dow range off-by-one error 2023-10-30 20:26:08 +00:00
c9b50e46a5 rp: Add PIO stepper motor driver example 2023-10-30 20:50:37 +01:00
aa97fe7cbd stm32: Add some documentation to low_power
This begins to explain the operation of the low-power executor.
2023-10-30 14:36:08 -04:00
ad07ea0290 Re-add impl_trait_projections 2023-10-30 19:10:45 +01:00
573734008a Fix test 2023-10-29 20:03:11 +01:00
f4a78e00a7 Remove set_current_time API 2023-10-29 19:52:35 +01:00
0d6094c8b1 time: add MockDriver for testing purposes 2023-10-29 19:49:52 +01:00
b1e5b6ffe1 Add raw fmc access implementation 2023-10-28 13:50:02 +02:00
b6fc682117 Merge pull request #2117 from xoviat/rtc-3
stm32/rtc: more rtc cleanup
2023-10-26 00:55:32 +00:00
0beb84768e stm32/rtc: more rtc cleanup 2023-10-25 19:50:30 -05:00
b98a279367 Merge pull request #2116 from xoviat/rtc-2
stm32/low-power: refactor refcount
2023-10-26 00:11:21 +00:00
e8a3cfaed6 stm32/low-power: refactor refcount 2023-10-25 19:07:31 -05:00
0cc3e18db6 Merge pull request #2112 from AzazKamaz/patch-1
Fix #2100 - function address comparison
2023-10-25 11:53:52 +00:00
6b19c0abd1 Fix #2100 - function address comparison 2023-10-25 11:01:35 +03:00
f956d19e6e Merge pull request #2111 from yodaldevoid/more-ticks
time: Add tick rates in multiples of 10 kHz
2023-10-24 19:51:24 +00:00
ceb0d0bf08 time: Add tick rates in multiples of 10 kHz 2023-10-24 15:34:39 -04:00
b3879ec223 Merge pull request #2105 from andresv/fix-stm32-uart-set-config
Fix stm32 uart set_config
2023-10-24 13:13:42 +00:00
bda99e59ec stm32: fix uart parity, add comment why it is so 2023-10-24 15:57:03 +03:00
25c2a9baaa stm32 uart: remove redundant set_fifoen(true) 2023-10-24 10:11:54 +03:00
1e362c750b stm32 uart: use ConfigError instead of () as error 2023-10-24 09:54:17 +03:00
1a51a84313 Merge pull request #2109 from rmja/stm32-remove-unsafe-warning
stm32: Remove unneeded unsafe
2023-10-24 06:32:22 +00:00
7f72dbdaf2 stm32: fix set_config for buffered uart
In reconfigure() cr1 register is initialised with write (not modify) which means rxneie and idleneie are disabled after reconfiguration.
2023-10-24 09:09:33 +03:00
e8c162ac03 stm32: Remove unneeded unsafe 2023-10-24 07:44:04 +02:00
1aaa19748a Merge pull request #2107 from embassy-rs/hil-test
stm32/build: deterministically generate data
2023-10-23 23:42:38 +00:00
9e230b64a4 stm32/build: deterministically generate data 2023-10-23 18:19:42 -05:00
17b4cf8ce7 Merge pull request #2106 from xoviat/fix-stop-2
stm32: fix low-power test
2023-10-23 21:29:36 +00:00
df4aa0fe25 stm32: fix low-power test 2023-10-23 16:26:34 -05:00
188ee59ba6 stm32: fix setting uart databits 2023-10-23 22:40:24 +03:00
591612db7e stm32 uart: return error if rx and tx not enabled 2023-10-23 22:39:24 +03:00
d673f8a865 Merge pull request #2103 from embassy-rs/rcc-no-spaghetti
stm32/rcc: merge wb into l4/l5.
2023-10-23 16:21:17 +00:00
82593bd404 stm32/gpio: make port G work on U5. 2023-10-23 18:12:31 +02:00
a39ae12edc stm32/rcc: misc cleanups. 2023-10-23 17:36:21 +02:00
0ef1cb29f7 stm32/rcc: merge wb into l4/l5. 2023-10-23 17:36:21 +02:00
64ab23d17d Merge pull request #2104 from glaeqen/slow-dhcp
net: Reset DHCP socket when the link up is detected
2023-10-23 09:55:17 +00:00
18c9bcd44a net: Reset DHCP socket when the link up is detected
Previously, because DHCP DISCOVER is sent before the link is
established, socket has to timeout first. Which takes extra 10 s.

Now if the state of the link changed to up, socket is explicitly reset
so the DISCOVER is repeated much earlier and DHCP configuration is
acquired much faster.
2023-10-23 11:07:21 +02:00
e895ea2d8b Merge pull request #2102 from embassy-rs/rcc-no-spaghetti
stm32/rcc: merge wl into l4/l5.
2023-10-22 22:48:57 +00:00
b9e13cb5d1 stm32/rcc: merge wl into l4/l5. 2023-10-23 00:31:36 +02:00
46ff2c82aa Merge pull request #2101 from embassy-rs/rcc-no-spaghetti
stm32/tests: add stm32wba52cg, stm32u5a9zj
2023-10-22 21:05:27 +00:00
a84ad741a4 stm32/tests: add stm32wba52cg, stm32u5a9zj 2023-10-22 22:45:11 +02:00
412bcad2d1 stm32: rename HSI16 -> HSI 2023-10-22 22:39:55 +02:00
e70c531d3d Merge pull request #2098 from xoviat/doc
stm32: fix opamp bug in docs build
2023-10-21 12:33:47 +00:00
7c5f963d1f stm32: fix opamp bug in docs build 2023-10-21 07:32:04 -05:00
62e1e1637c Merge pull request #2097 from embassy-rs/rcc-no-spaghetti
stm32/tests: add stm32h753zi, stm32h7a3zi.
2023-10-21 02:49:12 +00:00
3d03c18d4f stm32/tests: add stm32h753zi, stm32h7a3zi. 2023-10-21 04:46:45 +02:00
2157c5a4e3 Merge pull request #2096 from xoviat/rcc
wip: update metapac
2023-10-21 01:23:09 +00:00
0fb677aad7 stm32: update metapac 2023-10-20 20:21:53 -05:00
b1d0947a18 Merge pull request #1991 from diondokter/center-align
stm32: Add the ability to center-align timers
2023-10-20 16:39:30 +00:00
5b3f75dc72 Merge branch 'master' into center-align 2023-10-20 14:17:55 +02:00
6f2995cd4c Invert assert 2023-10-20 10:41:39 +02:00
88ada52146 Merge pull request #2017 from ilya-epifanov/rp-adc-div
added sampling frequency setting to adc capture methods on rp2040
2023-10-20 01:47:27 +00:00
d622181205 Merge pull request #2093 from embassy-rs/net-wiznet-linkupdwon
net-wiznet: report link up/down on cable plug/unplug.
2023-10-19 23:38:44 +00:00
630443a4d6 net-wiznet: report link up/down on cable plug/unplug. 2023-10-20 01:29:10 +02:00
035800bfbd Merge pull request #2091 from embassy-rs/comment-memory-x
docs: add linker script comments
2023-10-19 08:19:42 +00:00
c7803bb8f4 docs: add linker script comments
Existing comment were outdated. Provide an example configuration
for using the softdevice with the nRF52 examples.
2023-10-19 09:29:20 +02:00
d496a1213c Merge pull request #2090 from eZioPan/rcc-init-bypass-oden
bypass `ODEN` in `rcc::init()` if chip doesn't have it
2023-10-18 12:15:30 +00:00
241488ef1c bypass ODEN if chip doesn't have it 2023-10-18 19:42:31 +08:00
88b2cdd6a0 Merge pull request #2087 from riley-williams/rp2040-pwm-docs
Add docs to RP2040 PWM config
2023-10-18 06:30:08 +00:00
35ffdf2143 Merge pull request #2076 from embassy-rs/net-driver-simplify
net/driver: remove Medium, make HardwareAddress non_exhaustive.
2023-10-18 03:39:41 +00:00
3cbc687424 net/driver: remove Medium, make HardwareAddress non_exhaustive. 2023-10-18 05:28:16 +02:00
4f7b831676 Merge pull request #2088 from embassy-rs/rcc-no-spaghetti
stm32: rcc no spaghetti
2023-10-18 03:23:47 +00:00
f20f170b1f stm32/rcc: refactor and unify f4 into f7. 2023-10-18 05:11:31 +02:00
67010d123c stm32/rcc: refactor f7. 2023-10-18 05:01:11 +02:00
51708c8ed1 Merge pull request #2089 from artisdom/patch-1
Update basic_application.adoc
2023-10-18 02:59:48 +00:00
361fde35cf stm32/rcc: wait for mux switch. 2023-10-18 04:32:18 +02:00
7ce3b19389 stm32/rcc: remove unused enum. 2023-10-18 04:32:18 +02:00
10f08445e4 Update basic_application.adoc
typo: change "embassy::main" to "embassy_executor::main"
2023-10-18 14:53:49 +13:00
f24a1b62bb Merge pull request #2085 from xoviat/rcc
stm32: update metapac
2023-10-18 01:33:00 +00:00
bbd12c9372 stm32: update metapac 2023-10-17 20:31:44 -05:00
6906cc9c25 remove trailing spaces 2023-10-17 19:30:53 -04:00
cb211f88d3 Grammar and formatting 2023-10-17 19:17:29 -04:00
3f262a2603 Add docs to RP2040 PWM 2023-10-17 19:05:35 -04:00
d94b9fe6fb Merge pull request #2082 from embassy-rs/stm32wl-hil
stm32/tests: add stm32wl hil.
2023-10-17 14:58:53 +00:00
b478640463 fix clocks in stm32wl rng example. 2023-10-17 15:57:09 +02:00
846f2fc6e4 stm32/tests: add stm32wl hil. 2023-10-17 15:57:09 +02:00
683d5c3066 Merge pull request #2077 from xoviat/rcc
stm32: update metapac
2023-10-17 01:05:18 +00:00
a3574e519a stm32: update metapac 2023-10-16 20:04:10 -05:00
3e3317e8bd Merge pull request #2078 from GrantM11235/prefetch
stm32f1: Keep flash prefetch enabled
2023-10-17 00:29:30 +00:00
e7aeb9b29f stm32f1: Keep flash prefetch enabled 2023-10-16 19:23:01 -05:00
7fd868ade9 Merge pull request #2068 from barafael/const_usb_config_builder_new
Constify UsbDevice Config::new (and clippy fixes) in embassy-usb
2023-10-16 23:23:10 +00:00
6e6df22979 Merge pull request #2075 from CBJamo/rosc_example
Add example to show useage of rp2040 rosc
2023-10-16 23:22:06 +00:00
f7980885a5 Merge pull request #2066 from bugadani/net
Prepare embassy-net 0.2.0
2023-10-16 21:19:29 +00:00
5a1393aa0b Add example to show useage of rp2040 rosc 2023-10-16 16:17:07 -04:00
40e4ca4751 Prepare embassy-net(/-driver,/-driver-channel) 0.2.0 2023-10-16 20:59:06 +02:00
1d810baa18 Merge pull request #2074 from embassy-rs/rcc-no-spaghetti
time: add `links` key, release v0.1.5.
2023-10-16 18:19:59 +00:00
213b4c9dca time: add links key, release v0.1.5. 2023-10-16 20:11:35 +02:00
889d482d2d Merge pull request #2073 from embassy-rs/rcc-no-spaghetti
nrf/pac: reeport s and ns peripherals always independently of the current mode.
2023-10-16 17:43:13 +00:00
ea0e83a7f9 nrf/pac: reeport s and ns peripherals always independently of the current mode.
You sometimes need this, for example for using nrf91 modem from S mode
you need to acces IPC_NS.
2023-10-16 19:38:53 +02:00
f0497039ed Merge pull request #2071 from embassy-rs/rcc-no-spaghetti
stm32/rng: add test.
2023-10-16 03:37:18 +00:00
aff77d2b65 stm32/rng: add test. 2023-10-16 05:35:29 +02:00
a7c6999670 Merge pull request #2070 from embassy-rs/rcc-no-spaghetti
stm32/rcc: unify L4 and L5.
2023-10-16 02:10:37 +00:00
18e96898ea stm32/rcc: unify L4 and L5. 2023-10-16 04:00:51 +02:00
870dcc5970 Merge pull request #2069 from embassy-rs/rcc-no-spaghetti
stm32/rcc: add better support for L4/L4+ differences.
2023-10-16 01:41:40 +00:00
5c5e681819 stm32/rcc: add better support for L4/L4+ differences. 2023-10-16 03:23:43 +02:00
f54753beaa Merge pull request #2067 from xoviat/rcc
rcc: update pll clock naming
2023-10-16 00:52:47 +00:00
b24520579a rcc: ahb/apb -> hclk/pclk 2023-10-15 19:51:35 -05:00
31d4516516 Apply Pedantic Clippy Lints 2023-10-15 23:52:44 +02:00
66e62e9994 Fix clippy 2023-10-15 22:25:35 +02:00
eeedaf2e76 Constify Config::new 2023-10-15 22:11:30 +02:00
1fc35c753b rcc: update pll clock naming 2023-10-15 15:10:42 -05:00
2aaf4bf96b fix typo in build.rs that caused fmc ClkPin to not be implemented 2023-10-15 19:14:34 +02:00
cd92bc3145 Merge pull request #2060 from xoviat/rcc
stm32: expand rcc mux to g4 and h7
2023-10-15 04:37:36 +00:00
4a156df7a1 stm32: expand rcc mux to g4 and h7 2023-10-14 23:33:57 -05:00
c46e758e2c Merge pull request #2063 from embassy-rs/rcc-no-spaghetti
stm32/rcc: port L4 to the "flattened" API like h5/h7.
2023-10-15 01:12:46 +00:00
8a10948ce9 stm32/rcc: port L4 to the "flattened" API like h5/h7. 2023-10-15 03:08:49 +02:00
7045c53170 Merge pull request #2061 from adamgreig/timer-helpers
Add convenience methods for Timer::after_secs/millis/micros/ticks
2023-10-15 00:34:59 +00:00
0621e957a0 time: Update examples, tests, and other code to use new Timer::after_x convenience methods 2023-10-15 01:30:12 +01:00
a818f33658 Merge pull request #2062 from embassy-rs/rcc-no-spaghetti
stm32/rcc: remove unused lse/lsi fields in h7
2023-10-15 01:49:01 +02:00
3bfbf2697f stm32/rcc: remove unused lse/lsi fields in h7 2023-10-15 01:48:27 +02:00
7559f9e583 time: Update documentation to use new after_x convenience methods 2023-10-15 00:47:56 +01:00
c8fdbe19f9 time: Add convenience methods for Timer::after_secs/millis/micros/ticks 2023-10-15 00:47:55 +01:00
2e50bf667a Merge pull request #2055 from kalkyl/usb-midi
embassy-usb: Add MIDI class
2023-10-14 23:10:25 +00:00
ba62037642 Merge pull request #2058 from xoviat/rcc
rcc: remove mux_prefix from clocks
2023-10-14 17:57:44 +00:00
824556c9c8 rcc: remove mux_prefix from clocks 2023-10-14 12:51:45 -05:00
f7c0ec66d2 Merge pull request #2057 from bugadani/dns
Wake Stack's polling task after queueing a DNS query
2023-10-14 14:17:54 +00:00
69bb455c60 Wake stack's task after queueing a DNS query 2023-10-14 13:35:53 +02:00
575db17264 Merge pull request #2053 from jr-oss/fix_stm32_advanced_timer_enable_output
STM32: Fix regression in advanced timer to enable output of PWM signa…
2023-10-14 04:09:57 +00:00
0aa99e66f7 Merge pull request #2054 from xoviat/rcc-mux
rcc mux: update metapac
2023-10-14 04:07:38 +00:00
3264941c1b rcc mux: update metapac 2023-10-13 23:06:32 -05:00
a57d383b1d embassy-usb: Add MIDI class 2023-10-14 04:20:59 +02:00
9a7fda87b0 STM32: timer enable_output does not take bool, but just enables the output 2023-10-13 18:52:10 +02:00
adc810d24b STM32: Fix regression in advanced timer to enable output of PWM signal by partly reverting commit 74eb519 2023-10-13 17:38:40 +02:00
75baf186f3 Merge pull request #2051 from MabezDev/stm32/set_config-concrete
make set_config concrete methods public again
2023-10-12 22:06:29 +00:00
a6bbb130c5 make set_config concrete methods public again 2023-10-12 23:03:33 +01:00
d1ac6d2824 Merge pull request #2050 from embassy-rs/remove-unused-rb
Remove unused ringbuffer
2023-10-12 19:13:12 +00:00
636958ff70 fix: correct name in readme 2023-10-12 20:54:38 +02:00
7f6fe93f55 fix: remove unused ringbuffer code 2023-10-12 20:54:26 +02:00
e9b1904db8 Merge pull request #2049 from bugadani/time
(Please) Release embassy-time 0.1.4
2023-10-12 16:40:40 +00:00
02d2c06b23 Release embassy-time 0.1.4 2023-10-12 18:14:33 +02:00
debda2f52c Merge pull request #2045 from embassy-rs/stm32-cs-spam
Avoid creating many tiny critical sections in embassy-stm32::init
2023-10-12 14:29:23 +00:00
97ca0e77bf stm32: avoid creating many tiny critical sections in init.
Saves 292 bytes on stm32f0 bilnky with max optimizations (from 3132 to 2840).
2023-10-12 16:20:34 +02:00
66e399b5c6 Merge pull request #2035 from pbert519/stm_reset_and_enable
STM32: combine RccPeripherals reset() and enable() to enable_and_reset()
2023-10-12 14:09:13 +00:00
01eb1a7339 Merge pull request #2033 from andresovela/stm32-add-timeout-to-i2c
stm32: add timeout to I2C driver
2023-10-12 10:44:27 +00:00
f0d6ee69bc Add some builds without time feature to CI 2023-10-12 11:25:44 +02:00
65f81a1f57 Remove critical section for reset 2023-10-12 11:04:45 +02:00
ecdd7c0e2f enable clock first 2023-10-12 11:04:44 +02:00
d7d79f3068 Remove workaround for adc v3 2023-10-12 11:04:20 +02:00
f65a96c541 STM32: combine RccPeripherals reset() and enable() to reset_and_enable() 2023-10-12 11:04:19 +02:00
eb368f77a4 Merge pull request #2023 from xoviat/rcc-mux
stm32: add rcc mux for h5
2023-10-12 02:01:27 +00:00
57ccc1051a stm32: add initial rcc mux for h5 2023-10-11 20:59:47 -05:00
ac84631a2a Merge pull request #2046 from embassy-rs/stm32-remove-polyfill
stm32: remove atomic-polyfill.
2023-10-12 00:14:02 +00:00
70a91945fc stm32: remove atomic-polyfill. 2023-10-12 02:07:26 +02:00
32b89eeba1 net: remove atomic-polyfill. 2023-10-12 02:07:26 +02:00
063e6f96da Remove outdated comment 2023-10-11 23:56:21 +02:00
4cec4b0548 Remove more unused stuff 2023-10-11 23:52:26 +02:00
e6c47c3718 cargo fmt 2023-10-11 23:47:24 +02:00
2f7c2750d1 Feature guarded more unused stuff 2023-10-11 23:45:47 +02:00
032b1f2d59 Fix some issues with unused stuff 2023-10-11 23:42:40 +02:00
f76d50e837 cfg! macro didn't work, had to duplicate functions with different guards 2023-10-11 23:39:24 +02:00
ee5ea7aa06 cargo fmt 2023-10-11 23:34:02 +02:00
251d004708 Try using cfg! macro 2023-10-11 23:32:40 +02:00
cd68f85501 Added guards to individual APIs 2023-10-11 23:25:13 +02:00
b6c0ddb7df Move the feature gates to the i2c module instead of the pub use statement 2023-10-11 23:05:12 +02:00
ee93bbf1d4 Gate pub use _version::* 2023-10-11 22:45:54 +02:00
7b1cd42936 Add time feature to CI 2023-10-11 22:20:27 +02:00
1cd3ae9bd5 Add comment about feature gate on I2C mod 2023-10-11 22:20:17 +02:00
bfcca79c1e Add time feature back and gate i2c on time 2023-10-11 22:12:03 +02:00
c283e2d1b9 Merge pull request #2044 from embassy-rs/stm32-pac-pll-enums
stm32/rcc: LSE xtal is 32768hz, not 32000hz.
2023-10-11 11:42:27 +00:00
4a43cd3982 stm32/rcc: LSE xtal is 32768hz, not 32000hz.
Fixes #2043
2023-10-11 13:39:04 +02:00
0dda888c95 Merge pull request #2041 from embassy-rs/stm32-pac-pll-enums
stm32/rcc: add LSE/LSI to all chips, add RTC to more chips.
2023-10-11 02:18:24 +00:00
b91d1eaca0 stm32/rcc: add LSE/LSI to all chips, add RTC to more chips. 2023-10-11 04:12:38 +02:00
5a19d18b9c Merge pull request #2039 from jcdickinson/rp-i2c-stop-restart
fix (rp i2c): fix restart/stop flags for i2c master methods
2023-10-11 00:40:59 +00:00
ed7b6056a6 Merge pull request #2038 from jcdickinson/rp-i2c-slew
fix (rp i2c): set i2c slew rate to spec value
2023-10-11 00:38:13 +00:00
322f9cb153 fix (rp i2c): fix restart/stop flags for i2c master methods
Update the start and stop flags for all read/write/read_write methods to match
those in the default blocking implementation of these methods (as well as
other RP2040 I2C implementations, and expected I2C behavior).

Also adds a write_read_async method that doesnt require using embedded-hal, as
this is required to use I2C in an idiomatic fashion (see TI Application Report
SLVA704).
2023-10-10 20:24:38 -04:00
3ec4e6320a fix (rp i2c): set i2c slew rate to spec value
The RP2040 datasheet indicates that I2C pins should have a limited
slew rate (Page 440 - 4.3.1.3.). This configures that for both
`I2c` and `I2cSlave`.

In addition, the pin configuration has been centralized to a single
fn.
2023-10-10 20:14:09 -04:00
233aa1b53a Merge pull request #2037 from embassy-rs/stm32-pac-pll-enums
stm32/rcc: rename hse32 to hse, unify L0 and L1
2023-10-10 23:37:10 +00:00
21915a9a3f stm32/rcc: unify L0 and L1. 2023-10-11 01:22:27 +02:00
d0d0ceec6a stm32/rcc: rename HSE32 to HSE 2023-10-11 01:06:44 +02:00
9be61a2967 Merge pull request #2036 from embassy-rs/stm32-pac-pll-enums
stm32/rcc: use more PLL etc enums from PAC.
2023-10-10 22:24:08 +00:00
0cfa8d1bb5 stm32/rcc: use more PLL etc enums from PAC. 2023-10-11 00:12:33 +02:00
cd12c9cbce stm32: add timeout to I2C driver 2023-10-10 18:20:46 +02:00
eff73d6dfa Merge pull request #2032 from andresv/stm32-check-flash-lock-before-unlocking
stm32 flash: check lock bit before unlocking
2023-10-10 10:12:55 +00:00
3616d68aaa stm32 flash: check lock bit before unlocking
It hardfaults if already unlocked flash is unlocked again.
2023-10-10 12:55:43 +03:00
904f1cfc7a Merge pull request #2028 from glaeqen/stm32-eth-station-management
stm32/eth: Move `phy_addr` from `Ethernet` to `PHY`
2023-10-10 01:50:45 +00:00
e62bf6a9fd Patch tests & examples 2023-10-09 13:46:56 +02:00
7526b8edba stm32/eth: Move phy_addr from Ethernet to PHY
Previously, PHY addressing was a concern of the `Ethernet` struct
which limited the `PHY` implementations which very often have to manage
multiple PHYs internally and thus possibly need to address many of them.

This change extends `StationManagement` to allow addressing different
PHY addresses via SMI.
2023-10-09 13:46:56 +02:00
0c97ce2fcc fixed rp adc tests 2023-10-09 11:46:57 +02:00
62d6bb6c8a added sampling frequency setting to adc capture methods on rp2040 2023-10-09 10:53:29 +02:00
c3ef98a73d Merge pull request #2026 from embassy-rs/stm32-pac-pll-enums
stm32/rcc: use PLL enums from PAC.
2023-10-09 00:58:22 +00:00
6186fe0807 stm32/rcc: use PLL enums from PAC. 2023-10-09 02:48:22 +02:00
c4cff0b79b Merge pull request #2025 from xoviat/update-pac
stm32: update metapac
2023-10-08 23:35:14 +00:00
2e5ab7981e stm32: update metapac 2023-10-08 18:27:36 -05:00
9d311121f2 Merge pull request #2022 from HelloWorldTeraByte/impl-pwm-trait
Implemented Pwm trait from embedded_hal for simple and complementary pwm
2023-10-07 00:35:05 +00:00
25c3754cd2 Merge pull request #2019 from embassy-rs/net-hostname
net: add support for dhcp hostname option.
2023-10-07 00:17:35 +00:00
85c6f23dcb Merge pull request #2018 from jamesmunns/add-derives
Add some uncontroversial derives to Error types
2023-10-07 00:03:10 +00:00
9c6a2d9cbd Merge pull request #1880 from phire/rp_bootsel
rp2040: BOOTSEL button support
2023-10-06 23:56:00 +00:00
b67b179933 rp/bootsel: add test. 2023-10-07 01:47:25 +02:00
d4ed8e5779 rp/bootsel: change it to a method on the peripheral. 2023-10-07 01:47:20 +02:00
3e054a6f0d rp2040: implement BOOTSEL button support 2023-10-07 01:39:29 +02:00
c6d53e7bce rp2040: move in_ram helper outside of Flash's impl
Allow it to be called from other modules.
2023-10-07 01:39:29 +02:00
3bf8e4de5f Merge pull request #2015 from willglynn/stm32u5_faster_clocks
stm32: u5: implement >55 MHz clock speeds
2023-10-06 23:38:15 +00:00
9090a78df4 ci: set target dir if not specified. 2023-10-07 01:34:17 +02:00
022d870d61 Add missing derive 2023-10-07 01:33:43 +02:00
534eb960e9 net: add support for dhcp hostname option. 2023-10-07 01:33:21 +02:00
7a2b8481f7 Merge pull request #2021 from embassy-rs/stm32-mco
stm32: add MCO for all chips
2023-10-06 23:31:32 +00:00
710874021a Implemented Pwm trait for complementary pwm from embedded_hal 2023-10-07 12:22:31 +13:00
3a8e0d4a27 stm32: implement MCO for all chips. 2023-10-07 01:15:24 +02:00
b217d147de Implemented Pwm trait from embedded_hal 2023-10-07 11:57:19 +13:00
68c4820dde Add MCO support for stm32wl family 2023-10-06 14:37:36 -07:00
f30fc949ff Merge pull request #2012 from mattico/h7-rtc
H7: support LSE, LSI, LSEBYP, and RTCCLKSEL
2023-10-06 21:27:04 +00:00
75c1a9a3aa disable flaky f2 eth test 2023-10-06 23:25:39 +02:00
4075ac84e1 h7: enable rtc test 2023-10-06 14:12:57 -05:00
f01609036f h7: implement RTC and LSE clock configuration 2023-10-06 13:28:30 -05:00
930b8f3495 Add some uncontroversial derives to Error types 2023-10-06 17:45:35 +02:00
38e7709a24 stm32: u5: implement >55 MHz clock speeds
This commit allows STM32U5 devices to operate at 160 MHz.

On STM32U5, MSIS can run at 48 MHz and HSE can reach 50 MHz. Faster
clocks require using PLL1's R output, though PLL1 can serve other
functions besides using the R output for the system clock. This commit
extracts a public `PllConfig` struct, primarily to place associated
constructors on that type, but also with an eye towards enabling the P
and Q outputs in a later commit.

STM32U5 PLLs have various frequency requirements on each stage: after
the `m` prescaler, after the `n` multiplier, and after the `r` divider.
This commit implements the associated checks as assertions.

This commit fixes clock calculation and PLL register configuration
errors in PLL initialization.

STM32U5 has a PWR peripheral which can be configured to push Vcore into
different voltage ranges. System clocks exceeding 55 MHz require range
2, and system clocks exceeding 110 MHz require range 1. This commit
adds `voltage_range` to `Config` and configures PWR as directed.

The voltage range implies different performance limits on various clock
signals, including inside a PLL. This commit implements voltage range
<-> frequency range checks as assertions, and extracts the
otherwise-repeated MSIS, HSI16, and HSE initialization into private
methods on `Config`.

STM32U5 frequencies above 55 MHz require using the PWR EPOD booster.
The EPOD booster requires configuring a second `m` term for PLL1,
`mboost`, such that it falls in a particular range. (Recall that >50
MHz cannot be reached without PLL1, so there is no scenario where EPOD
is needed but PLL1 is not.) This commit configures and enables the EPOD
booster automatically as required.
2023-10-05 22:13:27 -05:00
65ed19aae2 Merge pull request #2014 from bugadani/udp
Reexport IpListenEndpoint for TCP
2023-10-05 16:13:10 +00:00
be9c05fbc9 Reexport IpListenEndpoint for TCP 2023-10-05 17:02:25 +02:00
42176b1a3a Merge pull request #2013 from xoviat/opamp
stm32: update metapac and fix opamp ch
2023-10-04 21:20:42 +00:00
e1a0635ca3 stm32: update metapac and fix opamp ch 2023-10-04 16:15:08 -05:00
b887b7516e Merge pull request #2011 from glaeqen/input-pin
stm32/gpio: Implement `eh1::digital::InputPin` for `OutputOpenDrain`
2023-10-04 17:36:26 +00:00
c6513f93fe stm32/gpio: Implement eh1::digital::InputPin for OutputOpenDrain
Pins in open-drain mode are outputs and inputs simultaneously.
2023-10-04 18:20:25 +02:00
59f706ee2f Merge pull request #2006 from embassy-rs/update-eio
update embedded-io, embedded-nal-async.
2023-10-03 22:27:06 +00:00
ba7d74ac16 tests/stm32: increase tickrate for better precision. 2023-10-04 00:17:33 +02:00
0324cee0ca update embedded-io, embedded-nal-async. 2023-10-04 00:10:55 +02:00
8ac5c1a963 Merge pull request #1973 from xoviat/opamp
stm32: add opamp
2023-10-03 22:01:46 +00:00
e7ab044935 ci: remove wpan tests again 2023-10-03 16:59:18 -05:00
0c4cddfafb Merge branch 'main' of github.com:embassy-rs/embassy into opamp 2023-10-03 16:44:44 -05:00
e561e673c2 stm32: add opamp mod and update pac 2023-10-03 16:34:13 -05:00
09dfcd6b66 Merge pull request #2008 from xoviat/wpan
wpan: re-enable HIL tests
2023-10-03 21:02:48 +00:00
bb8a1b7f1f wpan: re-enable HIL tests 2023-10-03 15:53:22 -05:00
b012a67df7 Merge pull request #2007 from embassy-rs/unverbose
Remove a few ultra-verbose logs.
2023-10-03 20:28:44 +00:00
40f30fa4cd Remove a few ultra-verbose logs.
They're heavily spamming logs for HIL tests, and I don't believe
they're valuable now that the thing they helped debug in their young
age is now solid and mature.
2023-10-03 22:22:16 +02:00
f197aa9419 Merge pull request #2005 from embassy-rs/minor-doc-improvs
docs: minor doc improvements and cleanup
2023-10-03 19:37:39 +00:00
80a740bc72 docs: minor doc improvements and cleanup 2023-10-03 21:35:31 +02:00
ad524373ed Merge pull request #1926 from m5p3nc3r/async_dtr
Add a signal for when the CDC control state changes
2023-10-03 02:13:12 +00:00
9badf740d8 Merge pull request #2001 from embassy-rs/stm32-more-hil
stm32/hil: add f2, f3, f7, l49
2023-10-03 02:07:00 +00:00
6e901846df Merge pull request #1995 from JuliDi/quadspi
[STM32] QUADSPI support bank 2
2023-10-03 01:55:27 +00:00
c0a6c78a14 stm32/hil: add f2, f3, f7, l49 2023-10-03 02:11:58 +02:00
58280048e3 Merge pull request #2002 from embassy-rs/fix-stop
stm32: fix stop
2023-10-02 23:56:33 +00:00
00824af82b ci: remove wpan tests 2023-10-02 18:55:31 -05:00
adf9ffb109 tests/stm32: use default clock config 2023-10-02 18:51:59 -05:00
bc203ebe4b Merge branch 'main' of github.com:embassy-rs/embassy into fix-stop 2023-10-02 18:30:41 -05:00
e042b3056d stm32: fix stop 2023-10-02 18:11:03 -05:00
9dc927250c Merge pull request #1959 from embassy-rs/test-eth
stm32: add eth tests
2023-10-02 20:41:31 +00:00
b856d760f4 stm32/rcc: reset backup domain before enabling LSE. 2023-10-02 22:12:50 +02:00
a742a80171 Merge pull request #1999 from KingCol13/rp-wifi-examples-fixes
cyw43: Update examples
2023-10-02 20:07:45 +00:00
a9dc887060 Added clarifying comment 2023-10-02 21:41:30 +02:00
137e47f98d Do affect the frequency 2023-10-02 21:14:44 +02:00
90ade1b311 Add wait for DHCP in rp wifi_tcp_server 2023-10-02 20:10:52 +01:00
a931dfd9ad Update firmware size in rp wifi examples 2023-10-02 20:10:45 +01:00
eff61648fe tests/stm32: add eth test. 2023-10-02 20:40:11 +02:00
9228a6334b Merge pull request #1996 from embassy-rs/update-nightly
Update Nightly.
2023-10-02 17:29:21 +00:00
3c9dfbbc9d enable wifi_esp_hosted_perf test, disable stm32f4 stop test. 2023-10-02 19:05:41 +02:00
ce0add61f8 Merge pull request #1997 from dzamlo/main
stm32: avoid useless endian conversion in rng
2023-10-02 15:31:13 +00:00
bf6e06060b stm32: avoid useless endian conversion in rng 2023-10-02 17:20:58 +02:00
eb12114345 Remove impl_trait_projections. 2023-10-02 14:00:49 +02:00
4b252586e5 Update Nightly. 2023-10-02 13:51:13 +02:00
5f6a915a32 Merge pull request #1994 from jcdickinson/pin_params
feat (rp2040): allow schmitt, slew, and drive strength be set from Flex, Input, Output
2023-10-02 10:44:19 +00:00
923f1851ee remove debug logging in build.rs 2023-10-02 09:36:11 +02:00
bd267a6479 move stm32h7 specific import 2023-10-02 09:34:59 +02:00
f3aa0cfe5a remove debug code, add some comments 2023-10-02 09:33:10 +02:00
6ea5aa347d feature-gate errata workaround for h7 2023-10-02 09:30:58 +02:00
8c13126cff make push/pull settings for pins explicit 2023-10-02 09:30:58 +02:00
81da9ca621 Bump stm32-metapac, add flash selection 2023-10-02 09:30:58 +02:00
729338875c support QSPI BK2 2023-10-02 09:30:57 +02:00
f98c8886b2 feat: allow schmitt, slew, and drive strength be set from Flex, Input, Output
Allows the schmitt, slew and drive strength to be set from Flex. Input and Output[OpenDrain] also expose the appropriate setters.
2023-10-01 21:49:14 -04:00
05a9b11316 Fix examples 2023-10-01 23:39:53 +02:00
a1036e111e Merge pull request #1990 from embassy-rs/stm32f4-rcc-fix
stm32f4: fix rcc build on stm32f446
2023-10-01 21:16:09 +00:00
561126b0d6 stm32: Add the ability to center-align timers 2023-10-01 23:09:01 +02:00
2af97e7595 rcc/f4: fix build on stm32f446
fixes #1989
2023-10-01 23:01:58 +02:00
2008030a8b ci: add all stm32f4 2023-10-01 23:01:35 +02:00
480328d07e Merge pull request #1984 from xoviat/set-config
stm32: require use of setconfig to set config
2023-10-01 14:41:52 +00:00
05218a52e6 stm32: update set_config 2023-10-01 09:39:10 -05:00
d2a2734752 nrf, rp: update set_config 2023-10-01 09:37:42 -05:00
5ad34404af eh: update set_config and add get_config 2023-10-01 09:37:20 -05:00
a7b1e51650 Merge pull request #1987 from tyler-gilbert/issue-1986-add-sai-receiver-driver
Issue 1986 add sai receiver driver
2023-10-01 14:06:25 +00:00
70005c3956 Merge pull request #1988 from JuliDi/expose-analog-switch-pins-rebased
[STM32] Handle STM32H7 "_C" pins (rebased)
2023-10-01 12:36:21 +00:00
93adbb9922 update stm32-metapac 2023-10-01 12:41:08 +02:00
e80df91e02 update stm32-metapac revision 2023-10-01 12:34:26 +02:00
5cb58754d4 skip _C pins for pin impls if split_feature not enabled. 2023-10-01 12:32:47 +02:00
5c83179071 change split_features from array to Vec 2023-10-01 12:32:47 +02:00
49608714aa cleanup, fix pushing to pins_table 2023-10-01 12:32:47 +02:00
f116ca83e0 check whether split-feature is valid 2023-10-01 12:32:47 +02:00
6e5f3f9515 update to testing pr #1889 2023-10-01 12:32:46 +02:00
5924cc8b49 handle _C pins 2023-10-01 12:30:34 +02:00
0d49aaf8ca Issue #1986 fix ci build errors 2023-09-30 22:51:23 -05:00
5dd9e9b3b7 issue #1986 separate blocks to prevent unsafe user code 2023-09-30 22:48:49 -05:00
d42cfda2db Issue #1986 add PartialEq to SyncEnable to fix build error on sai_v4 2023-09-30 19:51:00 -05:00
d1f4511cd1 Issue #1986 update the SAI driver with receiver capability 2023-09-30 19:43:44 -05:00
fa8d5da4a5 Merge pull request #5 from embassy-rs/main
Merge latest including SAI driver
2023-09-30 16:06:11 -06:00
7bc57ca3f7 Merge pull request #1975 from tyler-gilbert/issue-1974-add-sai-driver
Issue 1974 add sai driver
2023-09-30 20:04:26 +00:00
7ad102695d Merge pull request #1981 from xoviat/fix-traits
Fix traits
2023-09-30 17:57:22 +00:00
4999de6f82 rustfmt 2023-09-30 12:53:17 -05:00
9b8bdad403 Fix clippy error exposed by moving out of macros 2023-09-30 13:07:11 -04:00
3c3fb0a529 Remove unused imports 2023-09-30 12:20:31 -04:00
dc4c27aead Move one more method out of macros 2023-09-30 12:16:47 -04:00
74eb519810 Move trait impls out of macros 2023-09-30 12:14:20 -04:00
61dc36b1f2 Fix small formatting issue 2023-09-30 11:36:32 -04:00
55a0a15be2 Fix trait inconsistency between sealed traits and implementations 2023-09-30 11:19:09 -04:00
fc8f96fea5 Merge pull request #1976 from elasticdotventures/feature/examples
fix typo / update wasm example
2023-09-30 10:55:08 +00:00
08175f191a bump wasm-pack version 2023-09-30 05:42:59 +00:00
8da987cfbb typo 2023-09-30 05:34:22 +00:00
1be5f193c3 #Issue 1974 more whitespace fixes 2023-09-29 21:53:01 -05:00
4a632e08b7 #Issue 1974 fix extra whitespace 2023-09-29 21:46:19 -05:00
6cdee93934 #Issue 1974 fix more warnings treated as errors 2023-09-29 21:27:15 -05:00
5c8c1b2146 #Issue 1974 fix warnings 2023-09-29 21:16:20 -05:00
2addfc4b86 Merge branch 'issue-1974-add-sai-driver' of https://github.com/tyler-gilbert/embassy into issue-1974-add-sai-driver 2023-09-29 21:08:21 -05:00
92df87781d Issue 1974 add sai/mod file 2023-09-29 21:08:07 -05:00
a35d149cb1 Revert metapac change in Cargo.toml 2023-09-29 21:07:09 -05:00
c52320f467 Merge pull request #4 from embassy-rs/main
Pull latest from embassy main
2023-09-29 20:03:31 -06:00
2f9b59c5cf Merge branch 'main' into issue-1974-add-sai-driver 2023-09-29 20:02:24 -06:00
ce91fb2bfc Issue #1974 add SAI driver 2023-09-29 20:57:59 -05:00
95b3d9eb3b Merge pull request #1972 from embassy-rs/rtc-lse-fix
stm32/rtc: enable lse in examples.
2023-09-29 22:23:42 +00:00
f1e7205055 stm32/rtc: enable lse in examples. 2023-09-30 00:18:30 +02:00
6627824c02 Merge pull request #1970 from dberlin/revert-1969-main
Revert "Forgot set_count_direction and set_clock_division in 32 bit instance"
2023-09-29 17:32:37 +00:00
d62533879c Merge pull request #1971 from oro-os/enc28j60-mac-addr
enc28j60: expose a the MAC address via `address()` getter
2023-09-29 15:49:07 +00:00
e1a8caffa4 enc28j60: expose a the MAC address via address() getter 2023-09-29 17:23:39 +02:00
dffdb9268b Revert "Forgot set_count_direction and set_clock_division in 32 bit instance" 2023-09-28 21:56:18 -04:00
22e820b743 Merge pull request #1969 from dberlin/main
Forgot set_count_direction and set_clock_division in 32 bit instance
2023-09-29 00:38:45 +00:00
aa14f18d3f Merge pull request #1968 from xoviat/sbs
update metapac and rename sbs
2023-09-29 00:25:55 +00:00
39f1b26a39 stm32: update metapac and remove sbs 2023-09-28 19:21:02 -05:00
e70143ef8f Forgot set_count_direction and set_clock_division in 32 bit instance 2023-09-28 20:01:04 -04:00
d6654bf8b5 Merge pull request #1966 from xoviat/hrtim
stm32/hrtim: move traits out of macro def'n
2023-09-28 20:53:55 +00:00
322a4a8401 stm32/hrtim: move traits out of macro def'n 2023-09-28 15:48:46 -05:00
ee5591017b Merge pull request #1964 from dberlin/main
Add support for STM32 input capture filter
2023-09-28 20:37:48 +00:00
b1b32f079b Merge pull request #1962 from bugadani/esp32s2
Add 80MHz tick rate
2023-09-28 17:07:26 +00:00
e8a462768e Add more tick rates 2023-09-28 19:06:38 +02:00
ce0d787781 Merge pull request #1965 from oro-os/return-len-receive-enc28j60
enc28j60: return packet length from receive() instead of mut slice
2023-09-28 16:32:22 +00:00
fa2e63f74b enc28j60: return packet length from receive() instead of mut slice 2023-09-28 18:28:46 +02:00
23f3889167 Add support for STM32 input capture filter 2023-09-28 09:35:43 -04:00
a72a91ab06 Merge pull request #1963 from Mirror0/restore-f7-rtc
Restore RTC configuration for `STM32F7` boards
2023-09-28 11:32:50 +00:00
b9ef831ff7 Add 80MHz tick rate 2023-09-28 09:41:35 +02:00
e538aeacc8 Merge pull request #1960 from embassy-rs/test-eth-2
Net fixes
2023-09-28 03:39:10 +00:00
6b3745fc47 temporarily disable wifi_esp_hosted_perf test. 2023-09-28 05:34:19 +02:00
6200d22438 stm32/eth: fix receiving large frames on v2. 2023-09-28 05:12:35 +02:00
901d31e8f8 Merge pull request #1933 from xoviat/adc
stm32: more adc cleanup
2023-09-28 01:59:51 +00:00
79146c4bd5 stm32/adc: cleanup f1, f3, v1, and v2 2023-09-27 20:58:46 -05:00
d9eae79f3e test: deduplicate net perf test code. 2023-09-28 03:47:14 +02:00
3d1b4116ec test: set DEFMT_LOG not too verbose so net perf tests pass with cargo run. 2023-09-28 03:47:14 +02:00
901f0257bd net: allow non-'static drivers. 2023-09-28 03:47:14 +02:00
fec4194ae6 Merge pull request #1958 from dberlin/main
Add support for input capture function
2023-09-28 01:00:36 +00:00
f866735802 Add support for input capture function 2023-09-27 20:15:57 -04:00
20ea76c19c Merge pull request #1953 from embassy-rs/stm32l-tests
tests/stm32: add L0, L1, L4, L4+, L5
2023-09-27 19:37:04 +00:00
e1951f3ddf feat(stm32f7): restore rtc configuration for stm32f7 series 2023-09-27 16:08:05 +02:00
8b5fb254c0 tests/stm32: add L0, L1, L4, L4+, L5 2023-09-26 05:30:50 +02:00
624f786203 Merge pull request #1952 from embassy-rs/stm32-test-cleanup
stm32 rcc fixes.
2023-09-26 03:24:53 +00:00
a57e48459e stm32/rcc: remove bad limits on l5. 2023-09-26 05:15:09 +02:00
c604d8a8f1 stm32/rcc: add voltage_scale, flash waitstates. 2023-09-26 05:15:09 +02:00
be0c52bf5e Merge pull request #1951 from embassy-rs/stm32-test-cleanup
stm32/usart: enable fifo mode on usartv4.
2023-09-26 02:42:11 +00:00
44bb405683 stm32/usart: enable fifo mode on usartv4. 2023-09-26 04:38:53 +02:00
e8587e2fba Merge pull request #1950 from embassy-rs/stm32-test-cleanup
stm32/usart: return error instead of panicking on bad baudrate.
2023-09-25 22:21:29 +00:00
5d8817d109 stm32/usart: return error instead of panicking on bad baudrate. 2023-09-26 00:19:27 +02:00
c79a84a98a Merge pull request #1949 from xoviat/rtc
stm32/rtc: cleanup and fixes
2023-09-25 21:40:05 +00:00
96edbd84fb rtc: use enable on known working chips only 2023-09-25 16:38:30 -05:00
dc400a0539 stm32/rtc: always set wakeup alarm 2023-09-25 16:27:08 -05:00
04b09a2acb stm32/rtc: use rccperi enable 2023-09-25 16:26:29 -05:00
481d2998ef Merge pull request #1948 from embassy-rs/stm32-test-cleanup
tests/stm32: centralize pin configuration.
2023-09-25 20:44:57 +00:00
4b695120fc tests/stm32: centralize pin configuration. 2023-09-25 22:41:22 +02:00
bd9021ca1d Make irq token Copy+Clone 2023-09-25 22:35:31 +02:00
6e63c8d4bf Merge pull request #1947 from ceekdee/rust-lorawan-lora-phy-v2
Update rust-lorawan and embassy to use lora-phy version 2
2023-09-25 16:20:50 +00:00
70acc093dd Update rust-lorawan crate versions. 2023-09-25 10:45:53 -05:00
f7c2db245f Merge branch 'embassy-rs:main' into rust-lorawan-lora-phy-v2 2023-09-24 19:09:04 -05:00
2543bcafaf Merge pull request #1945 from xoviat/bd-2
stm32: fix bd lsi
2023-09-24 23:41:04 +00:00
9f2fc04caa stm32: fix bd lsi 2023-09-24 18:37:09 -05:00
f32bfafa61 Merge pull request #1943 from embassy-rs/centralize-pwr-syscfg
stm32: centralize enabling pwr, syscfg, flash.
2023-09-24 23:15:25 +00:00
e03239e88d stm32: centralize enabling pwr, syscfg, flash. 2023-09-25 01:07:55 +02:00
7d5e62d4a7 Update for rust-lorawan and lora-phy version 2. 2023-09-24 10:33:03 -05:00
65d36f9f99 Merge pull request #1940 from luveti/patch-1
stm32: fix rtc example
2023-09-24 09:30:08 +00:00
347ff18644 stm32: fix rtc example
lsi must be enabled otherwise a assertion fails
2023-09-24 01:11:58 -04:00
1e80fd81f7 Merge pull request #1939 from nilfit/spim-anomaly-109
spim: Fix nRF52832 SPIM with polling executors
2023-09-23 11:14:16 +00:00
52e269edbb Merge pull request #1938 from xoviat/low-power
stm32/lp: clamp requested_duration
2023-09-22 20:39:54 +00:00
c849620cd6 stm32/lp: clamp requested_duration to avoid overflow 2023-09-22 15:35:20 -05:00
6f83acc010 Add separate work-around specific flag for DMA errata on NRF52832 2023-09-22 17:02:21 +02:00
2b7b7a917d spim: Fix SPIM with polling executors
Co-authored-by: Priit Laes <plaes@plaes.org>
2023-09-22 17:02:21 +02:00
f1488864eb Merge pull request #1937 from xoviat/low-power
stm32/low-power: create one critical-section for all time ops
2023-09-22 00:36:21 +00:00
7cf327130e stm32/low-power: create one critical-section for all time ops 2023-09-21 19:32:48 -05:00
02b0523199 Merge pull request #1935 from embassy-rs/stm32-update-metapacgc
stm32: update metapac.
2023-09-21 22:26:53 +00:00
47175198c0 stm32: update metapac. 2023-09-22 00:13:57 +02:00
4b20e6c258 Merge pull request #1927 from embassy-rs/stm32-rcc-unify-h
stm32/rcc: unify h5 and h7.
2023-09-21 22:05:01 +00:00
83b4c01273 stm32/rcc: unify h5 and h7. 2023-09-21 23:47:56 +02:00
e313ca4ae8 Merge pull request #1934 from chrenderle/low-power-l0
fix low-power: APB1 needed for LSE
2023-09-21 17:40:11 +00:00
ad64d7b20b fix low-power: APB1 needed for LSE 2023-09-21 17:17:58 +02:00
5626a28af2 Merge pull request #1930 from xoviat/adc
stm32/adc: make v1 async
2023-09-20 22:45:51 +00:00
766ae724cb Merge pull request #1932 from embassy-rs/h7fix
stm32/h7: fix bad PWR reg versions.
2023-09-20 22:28:09 +00:00
00b9f9acef stm32/h7: fix bad PWR reg versions. 2023-09-21 00:23:56 +02:00
d46920dce6 stm32/adc: make v1 async and leave en 2023-09-20 16:07:35 -05:00
e1ed492577 Merge pull request #1929 from sgoll/exti-level
stm32/exti: Add get_level() to ExtiInput
2023-09-19 22:44:19 +00:00
2405aff11f Add get_level() to ExtiInput 2023-09-20 00:03:39 +02:00
a402aed3d1 Add async interface for CDC control changes
Signed-off-by: Matt Spencer <matthew@thespencers.me.uk>
2023-09-19 15:42:26 +01:00
c573959a95 Merge pull request #1928 from sgoll/fix-r2-voltage-range
stm32/f2: Fix typo in RCC voltage range docs
2023-09-19 12:03:40 +00:00
561696dfad Fix typo in F2 RCC voltage ranges 2023-09-19 10:20:25 +02:00
b1abaa380f Merge pull request #1919 from xoviat/adc
adc/f3: add async conversion
2023-09-18 21:32:59 +00:00
e640933e2f stm32/adc: add async conversion 2023-09-18 16:31:20 -05:00
183824fbdd Merge pull request #1924 from embassy-rs/rp-remove-paste
rp: remove paste macro.
2023-09-18 01:33:55 +00:00
5d0c40f61d rp: remove paste macro. 2023-09-18 03:30:17 +02:00
fdfe12fe1c Merge pull request #1923 from embassy-rs/pac-vos
stm32: use PAC enums for VOS.
2023-09-18 01:23:40 +00:00
4bfbcd6c72 stm32: use PAC enums for VOS. 2023-09-18 03:15:15 +02:00
0da793e5de Merge pull request #1921 from xoviat/rtc
stm32: update configure_ls and misc cleanup
2023-09-18 00:04:32 +00:00
0dcb34fc7d ci: fix tests 2023-09-17 19:03:45 -05:00
feaeee1e83 stm32: misc. cleanup 2023-09-17 18:47:22 -05:00
a6ef314be1 stm32: update configure_ls as agreed 2023-09-17 18:41:45 -05:00
daeb497045 Merge pull request #1917 from MabezDev/set-config-uart
stm32: Implement `set_config` for Uart structs
2023-09-17 21:33:18 +00:00
88eb5cca71 stm32: Implement set_config for Uart structs 2023-09-17 18:38:03 +01:00
cd128c20fa Merge pull request #1920 from MabezDev/rtc-time-provider
stm32: Add RtcTimeProvider struct to Rtc module
2023-09-17 17:32:56 +00:00
087ef918bf stm32: Add RtcTimeProvider struct to Rtc module
This struct allows users to acquire the current time without putting `Rtc`
in a mutex and passing that around. This is allowed because reading from the
rtc registers is atomic.
2023-09-17 18:04:05 +01:00
75cae09e79 Merge pull request #1918 from embassy-rs/stm32wba
stm32/rcc: use AHBPrescaler div impls in stm32wba
2023-09-17 00:39:26 +00:00
bbe1d96045 stm32/rcc: use AHBPrescaler div impls in stm32wba 2023-09-17 02:30:50 +02:00
3ddc9cd110 Merge pull request #1915 from xoviat/rcc
stm32/rcc: convert bus prescalers to pac enums
2023-09-16 22:59:26 +00:00
de2773afdd stm32/rcc: convert bus prescalers to pac enums 2023-09-16 17:41:11 -05:00
2930be5e17 Merge pull request #1916 from wkf/main
Update stm32wb examples to use ble/mac firmware.
2023-09-16 20:43:02 +00:00
09f087e53e Update stm32wb examples to use ble/mac firmware. 2023-09-16 16:32:25 -04:00
044b837caa Merge pull request #1914 from xoviat/fix-wpan
stm32: fix  wpan_ble test
2023-09-16 15:20:55 +00:00
ad0a306ea5 stm32: fix wpan_ble test 2023-09-16 10:19:09 -05:00
b5fffbf66f Merge pull request #1913 from xoviat/doc
update docs
2023-09-16 13:20:39 +00:00
537e2f3b44 update docs 2023-09-16 08:19:49 -05:00
80d7193b5b Merge pull request #1911 from embassy-rs/stm32wba
stm32: add stm32wba support.
2023-09-16 02:06:22 +00:00
8315cf064e stm32: add stm32wba support. 2023-09-16 04:04:45 +02:00
a2a26f489b ci: set net.git-fetch-with-cli=true 2023-09-16 02:16:33 +02:00
f27620cc0b Merge pull request #1909 from xoviat/adc
stm32: generate adc_common and misc.
2023-09-15 23:49:41 +00:00
2911774849 Merge pull request #1910 from xoviat/rtc
stm32: rtc/low-power cleanup
2023-09-15 23:49:36 +00:00
6da75ea285 stm32: rtc/low-power cleanup 2023-09-15 18:41:33 -05:00
aa2fa29b89 stm32: fix adc f3 startup time
closes #1888.
2023-09-15 17:36:21 -05:00
c28a6bdd0b stm32: generate adc_common 2023-09-15 17:35:53 -05:00
5a158b94bd Merge pull request #1896 from haileys/inline-never-for-rvo
Write to TaskStorage::future via never-inlined fn to encourage RVO
2023-09-15 18:45:21 +00:00
c091ed2f63 Merge pull request #1908 from chrenderle/low-power-l0
Fix low-power feature for STM32L0
2023-09-15 14:50:19 +00:00
45e9e51bdc Fix low-power feature for STM32L0 2023-09-15 16:36:51 +02:00
7c77d2bd94 ci: reenable stm32 docs. 2023-09-15 03:43:46 +02:00
f76d94098d Merge pull request #1906 from xoviat/pwr-l0
update metapac and add low-power for l0
2023-09-15 00:21:24 +00:00
07233ca5b4 ci: build low-power on l0 2023-09-14 19:09:35 -05:00
9fb14379c3 stm32: add lp to l0 2023-09-14 18:53:27 -05:00
309c3d6b47 update metapac 2023-09-14 18:36:03 -05:00
f1f4943ca5 Merge pull request #1903 from embassy-rs/bump-embassy-sync
feat: bump embassy-sync version to 0.3.0
2023-09-14 16:36:59 +00:00
1b20ba27b1 feat: bump embassy-sync version to 0.3.0
Update changelog in preparation for release
2023-09-14 18:26:00 +02:00
f5e96a9d60 Merge pull request #1902 from diondokter/gpiote-fix
Fix gpiote when waking up from systemoff
2023-09-14 16:02:14 +00:00
e8b961232b Fix gpiote when waking up from systemoff 2023-09-14 17:24:28 +02:00
85a9f5816f Merge pull request #1901 from FuzzyLitchi/patch-1
Fix doc typo
2023-09-14 14:10:21 +00:00
7bcc7e8962 Fix doc typo 2023-09-14 16:08:37 +02:00
b118c4cc1b Merge pull request #1899 from tarfu/bump-fmc
stm32: bump fmc version
2023-09-14 12:34:19 +00:00
f090a38dde Merge pull request #1898 from MathiasKoch/embassy-stm32/uart-blocking-embedded-io
feature(embassy-stm32): implement blocking embedded-io::Write for Uart & UartTx
2023-09-14 12:33:51 +00:00
dcd1a91966 stm32: bump fmc version 2023-09-14 14:07:15 +02:00
49847ff432 Implement blocking embedded-io::Write for Uart & UartTx 2023-09-14 10:09:09 +02:00
b9d4b18f14 update UninitCell::write call in arch::wasm too 2023-09-14 13:59:24 +10:00
3a1ed823f8 write to TaskStorage::future via inline(never) fn to encourage RVO 2023-09-14 13:42:11 +10:00
9c647dd0e8 Merge pull request #1892 from cumthugo/usart-not-wakeup
stm32/usart: fix read_until_idle not wake up issue
2023-09-13 17:29:13 +00:00
582ef90994 stm32/usart: fix usart not wake up issue 2023-09-13 23:47:46 +08:00
5e381d49da Merge pull request #1893 from ceekdee/main
Wait for high for DIO1 for rp2040-based LoRa boards
2023-09-12 23:00:25 +00:00
af59fa0a7e Wait for high for DIO1 for rp2040-based LoRa boards. 2023-09-12 17:53:27 -05:00
4907ccaa4d Merge pull request #1839 from Frostie314159/embassy-time-next
embassy-time: Introduce reset function for Ticker.
2023-09-12 22:11:21 +00:00
2c38dd17b9 Merge pull request #1887 from xoviat/adc
adc/f3: fix delay calculation
2023-09-11 23:54:26 +00:00
d36e7abb71 adc/f3: fix delay calculation 2023-09-11 18:52:52 -05:00
e11db9fa59 ci: disable stm32 docs build temporarily because it's bringing CI down for some reason. 2023-09-12 01:43:57 +02:00
f877a5889d ci: fix colliding files warning. 2023-09-12 01:43:19 +02:00
db54edf56c Merge pull request #1886 from xoviat/adc
add g4 adc345, adc etc.
2023-09-11 22:50:53 +00:00
4072a16af6 ci: remove wpan_ble for hil 2023-09-11 17:50:08 -05:00
44a5c32ea4 adc/f3: fix startup bug 2023-09-11 17:27:47 -05:00
b9889ad3b5 stm32: add g4 adc345 and misc. 2023-09-11 17:12:54 -05:00
527bdc57b9 Fixed formating. 2023-09-11 08:04:06 +02:00
1133cbf90e Merge pull request #1834 from dave-andersen/main
Fix timing on RP2040 pio_ws2812.rs example
2023-09-10 21:21:06 +00:00
77c357e744 Merge pull request #1870 from plaes/nrf-setconfig-trait-internally
nrf: Use SetConfig trait internally where possible
2023-09-10 21:19:15 +00:00
521970535e nrf: twim: Use SetConfig trait to reduce code duplication 2023-09-10 23:17:30 +02:00
93d4cfe7c1 nrf: spis: Use SetConfig trait internally to reduce duplication 2023-09-10 23:17:30 +02:00
8413a89752 nrf: spim: Use SetConfig trait internally to reduce duplication 2023-09-10 23:17:30 +02:00
db717d9c81 nrf: Remove unneeded include from Temp's example
Fixes doctest when `time` feature is not enabled.
2023-09-10 23:17:30 +02:00
808fa9dce6 Merge pull request #1871 from plaes/dma-anomaly-109-spim-workaround
nrf: spim: Anomaly 109 workaround for SPIM peripheral (#460)
2023-09-10 21:12:02 +00:00
ceb13def19 Merge pull request #1850 from CBJamo/i2cdev
rp2040: I2cDevice
2023-09-10 21:02:32 +00:00
5cf494113f tests/rp: add teleprobe meta. 2023-09-10 23:01:15 +02:00
8edb7bb012 Test cleanup 2023-09-10 23:01:15 +02:00
8900f5f52b Fixing my git-based mistakes 2023-09-10 23:01:15 +02:00
8201979d71 Add example, fix small bug in respond_and_fill 2023-09-10 23:01:15 +02:00
2d9f50addc I2c slave take 2
refactored to split modules
renamed to match upstream docs
slight improvement to slave error handling
2023-09-10 23:01:15 +02:00
18da91e252 Rename to match upstream docs 2023-09-10 23:01:15 +02:00
28e2570533 Remove debug prints 2023-09-10 23:01:15 +02:00
26e0823c35 rp2040 I2cDevice
Move i2c to mod, split device and controller

Remove mode generic:
I don't think it's reasonable to use the i2c in device mode while
blocking, so I'm cutting the generic.
2023-09-10 23:01:15 +02:00
ceca8b4336 Merge pull request #1883 from JuliDi/net-socket-bind-error
embassy-net: Improve error when socket is not bound
2023-09-10 20:33:29 +00:00
e308286f3c Merge pull request #1881 from MabezDev/sdmmc-stbiterr
Handle stbiterr in 4bit wide mode for sdmmc_v1
2023-09-10 19:52:47 +00:00
268da2fcde Handle stbiterr in 4bit wide mode for sdmmc_v1 2023-09-10 20:27:38 +01:00
a992d4895d Merge pull request #1884 from xoviat/doc
stm32: fix docs
2023-09-10 18:52:42 +00:00
1bae34d37c stm32: fix docs 2023-09-10 13:50:28 -05:00
aac42e3209 Merge pull request #1882 from xoviat/rcc-f3
stm32/f3: add high res for hrtim and misc.
2023-09-10 18:35:33 +00:00
08415e001e stm32/f3: add high res for hrtim and misc. 2023-09-10 13:33:17 -05:00
d6a1b567ee add SocketNotBound error message 2023-09-10 20:13:56 +02:00
a47fb42962 Merge pull request #1878 from xoviat/adc
stm32: fix adc f3 and example
2023-09-10 03:02:42 +00:00
70a4a193c5 stm32: fix adc f3 and example 2023-09-09 22:01:51 -05:00
2132afb48b Merge pull request #1874 from JuliDi/eth-getstatus-async
embassy-net: add async wait_config_up
2023-09-09 20:06:52 +00:00
0e9131fd14 yield -> return
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-09-09 12:36:57 +02:00
40a18b075d improve docstring 2023-09-09 09:50:24 +02:00
f17f09057d Merge pull request #1877 from xoviat/rcc
rcc: more cleanup
2023-09-08 23:22:39 +00:00
11a78fb1e4 rcc: more cleanup 2023-09-08 18:20:58 -05:00
48154e18bf Merge pull request #1873 from vDorst/adin1110-pr3
Adin1110: documents and comment fixes
2023-09-08 18:11:47 +00:00
cf2d4eca7c add wait_config_up to examples 2023-09-08 17:40:20 +02:00
3e0b752bef fix poll_fn, add documentation 2023-09-08 17:26:01 +02:00
6070d61d8c fix typos 2023-09-08 15:59:46 +02:00
a4f8d82ef5 wait_config_up first steps 2023-09-08 15:58:47 +02:00
c27b0296fe Add more documentation and comment 2023-09-07 22:32:20 +02:00
336ae54a56 mdio: reenable and async the tests 2023-09-07 21:25:53 +02:00
d6a1118406 fix some spelling 2023-09-07 21:02:33 +02:00
9de08d56a0 nrf: spim: Anomaly 109 workaround for SPIM peripheral (#460)
This implements SPIM TX workaround suggested from section 3.8.1
from Anomaly 109 addendum.

In workaround case we first keep track of original maxcnt values,
then initiate "fake" transfer with zero-length maxcnt values.
Once the "fake" transfer is triggered, we handle it, fill in the
original maxcnt values and restart the transmission.
2023-09-07 18:58:22 +03:00
26740bb3ef Merge pull request #1869 from xoviat/rcc-bd
add rcc bd lsi/lse abstraction
2023-09-06 23:24:24 +00:00
4550452f43 rustfmt 2023-09-06 17:53:02 -05:00
08410432b5 stm32: fix rcc merge 2023-09-06 17:51:40 -05:00
3cf3caa3ab Merge branch 'main' into rcc-bd 2023-09-06 17:49:29 -05:00
c21ad04c2e stm32: extract lse/lsi into bd mod 2023-09-06 17:48:12 -05:00
d097c99719 stm32/rcc: add lsi and lse bd abstraction 2023-09-06 17:33:56 -05:00
af7c93abba Merge pull request #1864 from oll3/feat/stm32wl-adc
ADC support for STM32WLx
2023-09-06 16:32:12 +00:00
c356585a59 update metapac tag 2023-09-06 11:49:18 +02:00
0d3ff34d80 adc: enable ADC and clock selection for STM32WLx 2023-09-06 06:57:30 +02:00
bb2d6c8542 adc_v3: replace cfg(stm32g0) + friends with cfg(adc_g0)
Since any MCU (not just STM32G0) using adc_g0 should probably be handled the same way.
2023-09-06 06:57:28 +02:00
a05afc5426 Merge pull request #1867 from xoviat/adc-g4
Adc g4
2023-09-05 23:31:03 +00:00
50116e5b27 remove paste dependency 2023-09-05 18:20:17 -05:00
a80acf686e Merge pull request #1868 from MabezDev/f2-rtc-clocks
[F2] Allow the RTC clock source to be configured with the new RTC mechanism
2023-09-05 23:13:57 +00:00
6770d8e8a6 Allow the RTC clock source to be configured with the new RTC mechanism 2023-09-06 00:04:09 +01:00
7307098780 stm32: don't generate adc5 2023-09-05 17:50:45 -05:00
f4601af2a4 stm32: don't generate adc4 for g4 2023-09-05 17:48:20 -05:00
fd22f4fac5 stm32: remove paste and use refcount statics 2023-09-05 17:45:52 -05:00
7622d2eb61 stm32: fix merge issues 2023-09-05 17:10:15 -05:00
7573160077 Merge branch 'main' of https://github.com/embassy-rs/embassy into adc-g4 2023-09-05 17:02:28 -05:00
7e18e5e0c1 Merge branch 'stm32g4_adc' of https://github.com/daehyeok/embassy into adc-g4 2023-09-05 16:50:33 -05:00
9d76a6e933 Merge pull request #1849 from xoviat/adc-f3
Add adc f3
2023-09-05 21:48:44 +00:00
f502271940 stm32: add initial adc f3 impl 2023-09-05 16:46:57 -05:00
e2f8bf19ea Merge pull request #1865 from embassy-rs/esp-hosted-status
net-esp-hosted: add get_status()
2023-09-05 18:33:22 +00:00
1180e1770d net-esp-hosted: add get_status() 2023-09-05 19:50:21 +02:00
49ba9c3da2 initial support for STM32G4 ADC 2023-09-04 23:36:41 -07:00
ce662766be Merge pull request #1771 from rubdos/zero-copy-channel
embassy_sync::zero_copy_channel
2023-09-04 23:38:11 +02:00
a03b6be693 Merge pull request #1862 from xoviat/rcc-refcount
stm32: refcount peripheral enable/disable
2023-09-04 23:37:59 +02:00
87d3086533 Merge pull request #1863 from embassy-rs/reenable-test
Revert "ci: remove failing tests"
2023-09-04 23:20:00 +02:00
d19e1c1dd1 stm32: only refcount usart and use kind direclty 2023-09-04 16:18:31 -05:00
8a55adbfd8 Revert "ci: remove failing tests"
This reverts commit c5732ce285.
2023-09-04 23:16:48 +02:00
6dc56d2b35 stm32: include uart-named peripherals 2023-09-04 16:04:29 -05:00
394503ab69 ci: run HIL 2023-09-04 15:54:23 -05:00
bfb4cf775a remove adc refcount 2023-09-04 15:54:00 -05:00
274f63a879 stm32: fix refcounts for usart, spi, and i2c 2023-09-04 15:47:33 -05:00
615882ebd6 Rename zero_copy -> zerocopy. 2023-09-04 22:16:28 +02:00
6e38b07642 Add docs to zero-copy-channel 2023-09-04 22:13:27 +02:00
1eb03dc41a Prefer receive over recv 2023-09-04 22:13:27 +02:00
a2656f402b Move embassy-net-driver-channel::zerocopy_channel to embassy_sync::zero_copy_channel 2023-09-04 22:13:27 +02:00
3466c9cfa9 stm32: refcount peripheral enable/disable 2023-09-04 13:47:02 -05:00
3295ec94e5 Merge pull request #1858 from xoviat/psc-cleanup
stm32: cleanup psc design
2023-09-03 16:49:27 +00:00
c5732ce285 ci: remove failing tests 2023-09-03 11:48:41 -05:00
2e6f4237f2 stm32: cleanup psc design 2023-09-03 11:40:34 -05:00
ac11635b0b Merge pull request #1856 from embassy-rs/teleprobe-cache
Add teleprobe cache.
2023-09-03 01:45:28 +02:00
9dd58660c3 Add teleprobe cache. 2023-09-03 01:41:52 +02:00
9baa3bafb0 Merge pull request #1854 from bugadani/str
embassy-{net, sync, time}: Use fmt::unwrap
2023-09-03 00:35:21 +02:00
360286e67c Fix bootloader application examples 2023-09-02 08:50:03 +02:00
0c66636d00 Use fmt::unwrap 2023-09-02 08:39:52 +02:00
9d8c527308 Merge pull request #1831 from vDorst/adin1110-part2
embassy-net-adin1110 more improvements
2023-09-02 00:49:17 +02:00
1d87ec9cc3 stm32/qei: fix struct naming (#1852)
Co-authored-by: xoviat <xoviat@users.noreply.github.com>
2023-09-02 00:30:27 +02:00
b74645e259 Delete .github/bors.toml 2023-09-01 00:21:01 +02:00
56351cedcb Merge pull request #1844 from xoviat/rtc
stm32/rtc: autocompute prescalers
2023-08-30 23:28:00 +00:00
0823d9dc93 Merge pull request #1845 from xoviat/qei
stm32: add qei
2023-08-30 23:16:33 +00:00
c10fb7c1c4 stm32: implement qei 2023-08-30 18:10:26 -05:00
a2ce3aa1a1 Merge pull request #1848 from kalkyl/rp-write-size
rp: Fix write size in embassy-boot example app
2023-08-30 21:34:34 +00:00
3769447382 rp: Fix write size in embassy-boot example app 2023-08-30 23:20:38 +02:00
2c6b428ed4 Merge pull request #1847 from mvniekerk/main
RP2040: XOSC delay multiplier
2023-08-30 20:00:40 +00:00
83a976cf4b RP2040: Fixes as per PR 2023-08-30 21:59:41 +02:00
a76ff53fb3 RP2040: Fixes as per PR 2023-08-30 21:58:36 +02:00
f69e8459c9 RP2040: Fixes as per PR 2023-08-30 21:52:03 +02:00
891f1758bc RP2040: XOSC delay multiplier 2023-08-30 21:43:57 +02:00
ae174fd0e0 RP2040: XOSC delay multiplier 2023-08-30 21:42:27 +02:00
5c936d33d4 Merge pull request #1846 from diondokter/stm32-timer-prevent-hardfault
Stm32 timer prevent hardfault when frequency is 0
2023-08-30 17:40:06 +00:00
36ec9bcc1d Stm32 timer prevent hardfault 2023-08-30 19:35:15 +02:00
5adc80f6d9 Merge pull request #1838 from Frostie314159/cyw43-next
cyw43: Add utility functions.
2023-08-30 14:04:27 +00:00
98f55fa54d Reverted patch for lint fix. 2023-08-30 09:59:47 +02:00
416ecc73d8 add qei draft 2023-08-29 20:06:53 -05:00
27dfced285 stm32: fix rcc wb 2023-08-29 19:51:21 -05:00
21681d8b4e rustfmt 2023-08-29 19:44:43 -05:00
989c98f316 stm32/rtc: autocompute prescalers 2023-08-29 19:41:03 -05:00
fdb2c4946a Merge pull request #1843 from embassy-rs/fmt-sync
Sync all fmt.rs files.
2023-08-29 23:42:59 +00:00
5e613d9abb Sync all fmt.rs files. 2023-08-30 01:37:18 +02:00
40b576584e Merge pull request #1832 from embassy-rs/pipe-bufread
sync/pipe: impl BufRead.
2023-08-29 23:12:06 +00:00
aa7752020e Merge pull request #1842 from embassy-rs/ppp-terminate
net-ppp: return error when PPP link gets terminated by the peer.
2023-08-29 23:09:30 +00:00
6c165f8dc0 sync/pipe: impl BufRead. 2023-08-30 01:06:41 +02:00
975f2f23c0 net-ppp: return error when PPP link gets terminated by the peer. 2023-08-30 01:04:43 +02:00
0eeefd3dbf cyw43: Make Scanner public. 2023-08-29 23:05:05 +02:00
de01fe352b Removed unnecessary newline. 2023-08-29 08:35:29 +02:00
70662ec4ba embassy-time: Introduced reset function for Ticker 2023-08-29 08:29:38 +02:00
a4d78a6552 Merge pull request #1835 from oll3/fix/stm32-rng
stm32: fix wait for RNG data
2023-08-28 21:38:54 +00:00
f503417f4c Merge pull request #1833 from xoviat/rtc
stm32: misc rtc fixes
2023-08-28 21:18:42 +00:00
6b8b145266 stm32: revert changes to rcc f4 2023-08-28 16:17:42 -05:00
e07f943562 rustfmt 2023-08-28 15:52:13 -05:00
70a5221b2e stm32/bd: consolidate enable_rtc 2023-08-28 15:34:08 -05:00
b315c28d4e stm32/rtc: remove rtc-debug and asbtract exti wakeup 2023-08-28 15:30:29 -05:00
e025693914 cyw43: Create leave function on Control struct.
Create a function, which disassociates us, from the currently connected infra.
2023-08-28 21:34:14 +02:00
05ee02b593 cyw43: Introduce seperate up/down functions.
Create two helper functions, for setting the interface up/down.
2023-08-28 21:32:31 +02:00
4098a61ef0 cyw43: Fix warning in event.rs.
Allow non_upper_case_globals, to prevent the compiler from spitting out a warning about the Event enum.
2023-08-28 21:02:38 +02:00
1db00f5439 embassy-net-adin1110: Add basic benchmark results. 2023-08-28 20:11:56 +02:00
7fc17bc150 embassy-net-adin1110 bump deps. 2023-08-28 19:29:32 +02:00
6e616a6fe6 Update comment about turn around byte. 2023-08-28 19:23:15 +02:00
d02886786e Show the error type 2023-08-28 19:00:00 +02:00
2db4d01198 Merge branch 'embassy-rs:main' into adin1110-part2 2023-08-28 16:45:17 +00:00
fd739250ea stm32: fix wait for RNG data
If no data was available to read then the loop would wait for an interrupt and skip to the next chunk without writing the current one.
This could cause the given slice to only be partially filled with random data.

Fixed by moving the wait to before actually writing data to the chunk.
2023-08-28 11:44:05 +02:00
71c4e7e4d2 Fix timing on RP2040 pio_ws2812.rs example
The example spins too fast so it doesn't appear to change;
it's delaying for microseconds instead of milliseconds.
This commit slows it down and adds a comment noting the pin
mapping for the Adafruit feather rp2040+RFM95 LoRA module,
which has its Neopixel on pin 4 instead of 16.
2023-08-27 22:39:44 -04:00
2c80784fe6 stm32/rtc: feature-gate instant 2023-08-27 21:26:29 -05:00
538001a4bc stm32/rtc: fix psc div 2023-08-27 21:24:16 -05:00
e981cd4968 stm32: fix rtc wakeup timing and add dbg 2023-08-27 21:15:57 -05:00
91bb3aae3f stm32l4: bump embassy-net-adin1110 to v0.2.0 2023-08-28 00:32:05 +02:00
e08dbcd027 embassy-net-adin1110: bump version v0.2.0 2023-08-28 00:32:05 +02:00
5c27265a21 Add fmt.rs to improve log/debug and embbed and PC
Also add `defmt` to the features list.
2023-08-28 00:31:51 +02:00
2c36199dea stm32l4: Update adin1110 example add FCS option 2023-08-28 00:28:45 +02:00
13a0be6289 Validate FCS in fifo_read() and refactor tests.
Adding TestHarnass to declutter the tests.
Also added a test for FCS and SPI_CRC.
2023-08-28 00:28:40 +02:00
9f928010a8 stm32/rtc: use psc to compute instants 2023-08-27 16:06:33 -05:00
7f7256050c Don't let the MAC add FCS when it is done by app
The application can append FSC to outgoing packets and the MAC can detect
and report when a bitflip has occurred.

But the MAC can also add FSC if we want, but we can´t do both.
When adding FSC by the application and MAC results in the packet drop by
the MAC when the TX packet size > (MTU - 4).
Having the application append the FSC is preferred.

So set the right config bits.
2023-08-27 10:37:45 +02:00
4b6538c8a8 Fix read_fifo() better readout and more checks
read_fifo() used part of the frame buffer to readout non-frame data.
This results in incorrect readout of the fifo buffer but also the full
MTU could not be used.

Also added some more tests to check this and that the readout is a
multipule of 4 bytes.
2023-08-27 10:37:45 +02:00
f033089625 Merge pull request #3 from embassy-rs/main
Update to embassy head
2023-08-24 17:38:04 -06:00
6d8a5c6c20 Merge pull request #2 from embassy-rs/main
Pull changes from base embassy repo
2023-07-16 19:08:01 -05:00
3aedbce5c2 Merge pull request #1 from embassy-rs/main
Pull changes from embassy main
2023-07-01 15:41:11 -05:00
649 changed files with 22509 additions and 17790 deletions

3
.cargo/config.toml Normal file
View File

@ -0,0 +1,3 @@
[patch.crates-io]
embedded-storage = { git = "https://github.com/rust-embedded-community/embedded-storage", rev = "634302740f8d676538c3890748e7d7dfe372a040" }
embedded-storage-async = { git = "https://github.com/rust-embedded-community/embedded-storage", rev = "634302740f8d676538c3890748e7d7dfe372a040" }

4
.github/bors.toml vendored
View File

@ -1,4 +0,0 @@
status = [
"all",
]
delete_merged_branches = true

View File

@ -8,9 +8,23 @@ export RUSTUP_HOME=/ci/cache/rustup
export CARGO_HOME=/ci/cache/cargo
export CARGO_TARGET_DIR=/ci/cache/target
# needed for "dumb HTTP" transport support
# used when pointing stm32-metapac to a CI-built one.
export CARGO_NET_GIT_FETCH_WITH_CLI=true
# Restore lockfiles
if [ -f /ci/cache/lockfiles.tar ]; then
echo Restoring lockfiles...
tar xf /ci/cache/lockfiles.tar
fi
hashtime restore /ci/cache/filetime.json || true
hashtime save /ci/cache/filetime.json
sed -i 's/channel.*/channel = "stable"/g' rust-toolchain.toml
sed -i 's/channel.*/channel = "beta"/g' rust-toolchain.toml
./ci_stable.sh
# Save lockfiles
echo Saving lockfiles...
find . -type f -name Cargo.lock -exec tar -cf /ci/cache/lockfiles.tar '{}' \+

15
.github/ci/build.sh vendored
View File

@ -11,9 +11,24 @@ if [ -f /ci/secrets/teleprobe-token.txt ]; then
echo Got teleprobe token!
export TELEPROBE_HOST=https://teleprobe.embassy.dev
export TELEPROBE_TOKEN=$(cat /ci/secrets/teleprobe-token.txt)
export TELEPROBE_CACHE=/ci/cache/teleprobe_cache.json
fi
# needed for "dumb HTTP" transport support
# used when pointing stm32-metapac to a CI-built one.
export CARGO_NET_GIT_FETCH_WITH_CLI=true
# Restore lockfiles
if [ -f /ci/cache/lockfiles.tar ]; then
echo Restoring lockfiles...
tar xf /ci/cache/lockfiles.tar
fi
hashtime restore /ci/cache/filetime.json || true
hashtime save /ci/cache/filetime.json
./ci.sh
# Save lockfiles
echo Saving lockfiles...
find . -type f -name Cargo.lock -exec tar -cf /ci/cache/lockfiles.tar '{}' \+

2
.github/ci/doc.sh vendored
View File

@ -48,8 +48,8 @@ kubectl cp webroot/static $POD:/data
# build and upload stm32 last
# so that it doesn't prevent other crates from getting docs updates when it breaks.
rm -rf webroot
docserver-builder -i ./embassy-stm32 -o webroot/crates/embassy-stm32/git.zup
POD=$(kubectl -n embassy get po -l app=docserver -o jsonpath={.items[0].metadata.name})
kubectl cp webroot/crates $POD:/data

23
.github/ci/test.sh vendored
View File

@ -4,12 +4,8 @@
set -euo pipefail
export RUSTUP_HOME=/ci/cache/rustup
export CARGO_HOME=/ci/cache/cargo
export CARGO_TARGET_DIR=/ci/cache/target
hashtime restore /ci/cache/filetime.json || true
hashtime save /ci/cache/filetime.json
MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --manifest-path ./embassy-executor/Cargo.toml
MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --manifest-path ./embassy-executor/Cargo.toml --features nightly
cargo test --manifest-path ./embassy-sync/Cargo.toml
cargo test --manifest-path ./embassy-embedded-hal/Cargo.toml
@ -17,16 +13,15 @@ cargo test --manifest-path ./embassy-hal-internal/Cargo.toml
cargo test --manifest-path ./embassy-time/Cargo.toml --features generic-queue
cargo test --manifest-path ./embassy-boot/boot/Cargo.toml
cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features nightly
cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features nightly,ed25519-dalek
cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features nightly,ed25519-salty
cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features ed25519-dalek
cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features ed25519-salty
cargo test --manifest-path ./embassy-nrf/Cargo.toml --no-default-features --features nightly,nrf52840,time-driver-rtc1,gpiote
cargo test --manifest-path ./embassy-nrf/Cargo.toml --no-default-features --features nrf52840,time-driver-rtc1,gpiote
cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features nightly,time-driver
cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features time-driver
cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features nightly,stm32f429vg,exti,time-driver-any,exti
cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features nightly,stm32f732ze,exti,time-driver-any,exti
cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features nightly,stm32f769ni,exti,time-driver-any,exti
cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f429vg,exti,time-driver-any,exti
cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f732ze,exti,time-driver-any,exti
cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f769ni,exti,time-driver-any,exti
cargo test --manifest-path ./embassy-net-adin1110/Cargo.toml

View File

@ -62,9 +62,9 @@ async fn blink(pin: AnyPin) {
loop {
// Timekeeping is globally available, no need to mess with hardware timers.
led.set_high();
Timer::after(Duration::from_millis(150)).await;
Timer::after_millis(150).await;
led.set_low();
Timer::after(Duration::from_millis(150)).await;
Timer::after_millis(150).await;
}
}

191
ci.sh
View File

@ -1,9 +1,12 @@
#!/bin/bash
set -euo pipefail
set -eo pipefail
export RUSTFLAGS=-Dwarnings
export DEFMT_LOG=trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,cyw43=info,cyw43_pio=info,smoltcp=info
if [[ -z "${CARGO_TARGET_DIR}" ]]; then
export CARGO_TARGET_DIR=target_ci
fi
TARGET=$(rustc -vV | sed -n 's|host: ||p')
@ -32,80 +35,94 @@ cargo batch \
--- build --release --manifest-path embassy-executor/Cargo.toml --target riscv32imac-unknown-none-elf --features nightly,arch-riscv32,integrated-timers \
--- build --release --manifest-path embassy-executor/Cargo.toml --target riscv32imac-unknown-none-elf --features nightly,arch-riscv32,executor-thread \
--- build --release --manifest-path embassy-executor/Cargo.toml --target riscv32imac-unknown-none-elf --features nightly,arch-riscv32,executor-thread,integrated-timers \
--- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \
--- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \
--- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features defmt \
--- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,igmp,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,nightly \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,dhcpv4-hostname \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ieee802154 \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,medium-ieee802154 \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,nightly \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet,nightly \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,nightly \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,nightly \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,medium-ieee802154,nightly \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52820,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52832,gpiote,time-driver-rtc1,reset-pin-as-gpio \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52833,gpiote,time-driver-rtc1,unstable-traits,nfc-pins-as-gpio \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-s,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-ns,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,log,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,defmt \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,intrinsics \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,qspi-as-gpio \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet \
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,medium-ieee802154 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52820,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832,gpiote,time-driver-rtc1,reset-pin-as-gpio \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1,nfc-pins-as-gpio \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-s,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-ns,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,log,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features defmt \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features log \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features intrinsics \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features qspi-as-gpio \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f413vh,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,unstable-traits,embedded-sdmmc \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f730i8,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l422cb,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f378cc,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5jb,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32g474pe,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32h503rb,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32h562ag,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f412zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f413vh,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f415zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f417zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f423zh,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f427zi,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embedded-sdmmc,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f437zi,log,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f439zi,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f446ze,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f469zi,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f479zi,defmt,exti,time-driver-any,embedded-sdmmc,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f730i8,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h753zi,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h735zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l041f6,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l073cz,defmt,exti,time-driver-any,low-power,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f398ve,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f378cc,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32g0c1ve,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32wl54jc-cm0p,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wle5jb,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g474pe,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f107vc,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103re,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f100c4,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h503rb,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h562ag,defmt,exti,time-driver-any,time \
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features ''\
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'log' \
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt' \
@ -113,10 +130,10 @@ cargo batch \
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt,firmware-logs' \
--- build --release --manifest-path cyw43-pio/Cargo.toml --target thumbv6m-none-eabi --features '' \
--- build --release --manifest-path cyw43-pio/Cargo.toml --target thumbv6m-none-eabi --features 'overclock' \
--- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840,nightly \
--- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns,nightly \
--- build --release --manifest-path embassy-boot/rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \
--- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,nightly \
--- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
--- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \
--- build --release --manifest-path embassy-boot/rp/Cargo.toml --target thumbv6m-none-eabi \
--- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \
--- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
--- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \
--- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \
@ -144,9 +161,10 @@ cargo batch \
--- build --release --manifest-path examples/stm32l5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32l5 \
--- build --release --manifest-path examples/stm32u5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32u5 \
--- build --release --manifest-path examples/stm32wb/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb \
--- build --release --manifest-path examples/stm32wba/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32wba \
--- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl \
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840,skip-include --out-dir out/examples/boot/nrf \
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns,skip-include --out-dir out/examples/boot/nrf \
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840,skip-include --out-dir out/examples/boot/nrf52840 \
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns,skip-include --out-dir out/examples/boot/nrf9160 \
--- build --release --manifest-path examples/boot/application/rp/Cargo.toml --target thumbv6m-none-eabi --features skip-include --out-dir out/examples/boot/rp \
--- build --release --manifest-path examples/boot/application/stm32f3/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32f3 \
--- build --release --manifest-path examples/boot/application/stm32f7/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32f7 \
@ -162,19 +180,46 @@ cargo batch \
--- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/stm32f103c8 \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/stm32f429zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f446re --out-dir out/tests/stm32f446re \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re --out-dir out/tests/stm32g491re \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32g071rb --out-dir out/tests/stm32g071rb \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32c031c6 --out-dir out/tests/stm32c031c6 \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi --out-dir out/tests/stm32h755zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h753zi --out-dir out/tests/stm32h753zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7a3zi --out-dir out/tests/stm32h7a3zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55rg --out-dir out/tests/stm32wb55rg \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h563zi --out-dir out/tests/stm32h563zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585ai --out-dir out/tests/stm32u585ai \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u5a5zj --out-dir out/tests/stm32u5a5zj \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wba52cg --out-dir out/tests/stm32wba52cg \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l073rz --out-dir out/tests/stm32l073rz \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l152re --out-dir out/tests/stm32l152re \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4a6zg --out-dir out/tests/stm32l4a6zg \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r5zi --out-dir out/tests/stm32l4r5zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze --out-dir out/tests/stm32l552ze \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f767zi --out-dir out/tests/stm32f767zi \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f207zg --out-dir out/tests/stm32f207zg \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303ze --out-dir out/tests/stm32f303ze \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l496zg --out-dir out/tests/stm32l496zg \
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55jc --out-dir out/tests/stm32wl55jc \
--- build --release --manifest-path tests/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/rpi-pico \
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --out-dir out/tests/nrf52840-dk \
--- build --release --manifest-path tests/riscv32/Cargo.toml --target riscv32imac-unknown-none-elf \
$BUILD_EXTRA
rm out/tests/stm32wb55rg/wpan_mac
rm out/tests/stm32wb55rg/wpan_ble
# not in CI yet.
rm -rf out/tests/stm32f446re
# unstable, I think it's running out of RAM?
rm out/tests/stm32f207zg/eth
# doesn't work, gives "noise error", no idea why. usart_dma does pass.
rm out/tests/stm32u5a5zj/usart
if [[ -z "${TELEPROBE_TOKEN-}" ]]; then
echo No teleprobe token found, skipping running HIL tests
exit

View File

@ -22,51 +22,56 @@ cargo batch \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52820,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-s,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-ns,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,log,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1 \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features defmt \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features log \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features qspi-as-gpio \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,time \
--- build --release --manifest-path examples/nrf52840/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf52840 --bin raw_spawn \
--- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \

View File

@ -1,6 +1,5 @@
#![no_std]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
#![allow(async_fn_in_trait)]
use core::slice;

View File

@ -11,11 +11,10 @@ log = ["dep:log"]
firmware-logs = []
[dependencies]
embassy-time = { version = "0.1.3", path = "../embassy-time"}
embassy-sync = { version = "0.2.0", path = "../embassy-sync"}
embassy-time = { version = "0.1.5", path = "../embassy-time"}
embassy-sync = { version = "0.4.0", path = "../embassy-sync"}
embassy-futures = { version = "0.1.0", path = "../embassy-futures"}
embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel"}
atomic-polyfill = "0.1.5"
embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel"}
defmt = { version = "0.3", optional = true }
log = { version = "0.4.17", optional = true }
@ -24,7 +23,7 @@ cortex-m = "0.7.6"
cortex-m-rt = "0.7.0"
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-rc.1" }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-rc.2" }
num_enum = { version = "0.5.7", default-features = false }
[package.metadata.embassy_docs]

View File

@ -1,5 +1,5 @@
use embassy_futures::yield_now;
use embassy_time::{Duration, Timer};
use embassy_time::Timer;
use embedded_hal_1::digital::OutputPin;
use futures::FutureExt;
@ -51,9 +51,9 @@ where
pub async fn init(&mut self) {
// Reset
self.pwr.set_low().unwrap();
Timer::after(Duration::from_millis(20)).await;
Timer::after_millis(20).await;
self.pwr.set_high().unwrap();
Timer::after(Duration::from_millis(250)).await;
Timer::after_millis(250).await;
while self
.read32_swapped(REG_BUS_TEST_RO)

View File

@ -96,6 +96,7 @@ pub(crate) const IOCTL_CMD_UP: u32 = 2;
pub(crate) const IOCTL_CMD_DOWN: u32 = 3;
pub(crate) const IOCTL_CMD_SET_SSID: u32 = 26;
pub(crate) const IOCTL_CMD_SET_CHANNEL: u32 = 30;
pub(crate) const IOCTL_CMD_DISASSOC: u32 = 52;
pub(crate) const IOCTL_CMD_ANTDIV: u32 = 64;
pub(crate) const IOCTL_CMD_SET_AP: u32 = 118;
pub(crate) const IOCTL_CMD_SET_VAR: u32 = 263;

View File

@ -1,10 +1,10 @@
use core::cmp::{max, min};
use core::iter::zip;
use ch::driver::LinkState;
use embassy_net_driver_channel as ch;
use embassy_time::{Duration, Timer};
use embassy_net_driver_channel::driver::{HardwareAddress, LinkState};
use embassy_time::Timer;
pub use crate::bus::SpiBusCyw43;
use crate::consts::*;
use crate::events::{Event, EventSubscriber, Events};
use crate::fmt::Bytes;
@ -17,6 +17,12 @@ pub struct Error {
pub status: u32,
}
#[derive(Debug)]
pub enum AddMulticastAddressError {
NotMulticast,
NoFreeSlots,
}
pub struct Control<'a> {
state_ch: ch::StateRunner<'a>,
events: &'a Events,
@ -87,22 +93,22 @@ impl<'a> Control<'a> {
self.set_iovar("country", &country_info.to_bytes()).await;
// set country takes some time, next ioctls fail if we don't wait.
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
// Set antenna to chip antenna
self.ioctl_set_u32(IOCTL_CMD_ANTDIV, 0, 0).await;
self.set_iovar_u32("bus:txglom", 0).await;
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
//self.set_iovar_u32("apsta", 1).await; // this crashes, also we already did it before...??
//Timer::after(Duration::from_millis(100)).await;
//Timer::after_millis(100).await;
self.set_iovar_u32("ampdu_ba_wsize", 8).await;
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
self.set_iovar_u32("ampdu_mpdu", 4).await;
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
//self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes
//Timer::after(Duration::from_millis(100)).await;
//Timer::after_millis(100).await;
// evts
let mut evts = EventMask {
@ -121,23 +127,33 @@ impl<'a> Control<'a> {
self.set_iovar("bsscfg:event_msgs", &evts.to_bytes()).await;
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
// set wifi up
self.ioctl(IoctlType::Set, IOCTL_CMD_UP, 0, &mut []).await;
self.up().await;
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto
self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
self.state_ch.set_ethernet_address(mac_addr);
self.state_ch.set_hardware_address(HardwareAddress::Ethernet(mac_addr));
debug!("INIT DONE");
}
/// Set the WiFi interface up.
async fn up(&mut self) {
self.ioctl(IoctlType::Set, IOCTL_CMD_UP, 0, &mut []).await;
}
/// Set the interface down.
async fn down(&mut self) {
self.ioctl(IoctlType::Set, IOCTL_CMD_DOWN, 0, &mut []).await;
}
pub async fn set_power_management(&mut self, mode: PowerManagementMode) {
// power save mode
let mode_num = mode.mode();
@ -175,7 +191,7 @@ impl<'a> Control<'a> {
self.set_iovar_u32x2("bsscfg:sup_wpa2_eapver", 0, 0xFFFF_FFFF).await;
self.set_iovar_u32x2("bsscfg:sup_wpa_tmo", 0, 2500).await;
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
let mut pfi = PassphraseInfo {
len: passphrase.len() as _,
@ -256,13 +272,13 @@ impl<'a> Control<'a> {
}
// Temporarily set wifi down
self.ioctl(IoctlType::Set, IOCTL_CMD_DOWN, 0, &mut []).await;
self.down().await;
// Turn off APSTA mode
self.set_iovar_u32("apsta", 0).await;
// Set wifi up again
self.ioctl(IoctlType::Set, IOCTL_CMD_UP, 0, &mut []).await;
self.up().await;
// Turn on AP mode
self.ioctl_set_u32(IOCTL_CMD_SET_AP, 0, 1).await;
@ -287,7 +303,7 @@ impl<'a> Control<'a> {
if security != Security::OPEN {
self.set_iovar_u32x2("bsscfg:wpa_auth", 0, 0x0084).await; // wpa_auth = WPA2_AUTH_PSK | WPA_AUTH_PSK
Timer::after(Duration::from_millis(100)).await;
Timer::after_millis(100).await;
// Set passphrase
let mut pfi = PassphraseInfo {
@ -307,6 +323,54 @@ impl<'a> Control<'a> {
self.set_iovar_u32x2("bss", 0, 1).await; // bss = BSS_UP
}
/// Add specified address to the list of hardware addresses the device
/// listens on. The address must be a Group address (I/G bit set). Up
/// to 10 addresses are supported by the firmware. Returns the number of
/// address slots filled after adding, or an error.
pub async fn add_multicast_address(&mut self, address: [u8; 6]) -> Result<usize, AddMulticastAddressError> {
// The firmware seems to ignore non-multicast addresses, so let's
// prevent the user from adding them and wasting space.
if address[0] & 0x01 != 1 {
return Err(AddMulticastAddressError::NotMulticast);
}
let mut buf = [0; 64];
self.get_iovar("mcast_list", &mut buf).await;
let n = u32::from_le_bytes(buf[..4].try_into().unwrap()) as usize;
let (used, free) = buf[4..].split_at_mut(n * 6);
if used.chunks(6).any(|a| a == address) {
return Ok(n);
}
if free.len() < 6 {
return Err(AddMulticastAddressError::NoFreeSlots);
}
free[..6].copy_from_slice(&address);
let n = n + 1;
buf[..4].copy_from_slice(&(n as u32).to_le_bytes());
self.set_iovar_v::<80>("mcast_list", &buf).await;
Ok(n)
}
/// Retrieve the list of configured multicast hardware addresses.
pub async fn list_mulistcast_addresses(&mut self, result: &mut [[u8; 6]; 10]) -> usize {
let mut buf = [0; 64];
self.get_iovar("mcast_list", &mut buf).await;
let n = u32::from_le_bytes(buf[..4].try_into().unwrap()) as usize;
let used = &buf[4..][..n * 6];
for (addr, output) in zip(used.chunks(6), result.iter_mut()) {
output.copy_from_slice(addr)
}
n
}
async fn set_iovar_u32x2(&mut self, name: &str, val1: u32, val2: u32) {
let mut buf = [0; 8];
buf[0..4].copy_from_slice(&val1.to_le_bytes());
@ -423,6 +487,11 @@ impl<'a> Control<'a> {
events: &self.events,
}
}
/// Leave the wifi, with which we are currently associated.
pub async fn leave(&mut self) {
self.ioctl(IoctlType::Set, IOCTL_CMD_DISASSOC, 0, &mut []).await;
info!("Disassociated")
}
}
pub struct Scanner<'a> {

View File

@ -83,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -226,7 +229,8 @@ impl<T, E> Try for Result<T, E> {
}
}
pub struct Bytes<'a>(pub &'a [u8]);
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

View File

@ -1,7 +1,6 @@
#![no_std]
#![no_main]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait, type_alias_impl_trait, concat_bytes)]
#![allow(async_fn_in_trait)]
#![deny(unused_must_use)]
// This mod MUST go first, so that the others see its macros.
@ -27,7 +26,7 @@ use ioctl::IoctlState;
use crate::bus::Bus;
pub use crate::bus::SpiBusCyw43;
pub use crate::control::{Control, Error as ControlError};
pub use crate::control::{AddMulticastAddressError, Control, Error as ControlError, Scanner};
pub use crate::runner::Runner;
pub use crate::structs::BssInfo;

View File

@ -1,54 +1,48 @@
macro_rules! nvram {
($($s:literal,)*) => {
concat_bytes!($($s, b"\x00",)* b"\x00\x00")
};
}
pub static NVRAM: &'static [u8] = &*nvram!(
b"NVRAMRev=$Rev$",
b"manfid=0x2d0",
b"prodid=0x0727",
b"vendid=0x14e4",
b"devid=0x43e2",
b"boardtype=0x0887",
b"boardrev=0x1100",
b"boardnum=22",
b"macaddr=00:A0:50:b5:59:5e",
b"sromrev=11",
b"boardflags=0x00404001",
b"boardflags3=0x04000000",
b"xtalfreq=37400",
b"nocrc=1",
b"ag0=255",
b"aa2g=1",
b"ccode=ALL",
b"pa0itssit=0x20",
b"extpagain2g=0",
b"pa2ga0=-168,6649,-778",
b"AvVmid_c0=0x0,0xc8",
b"cckpwroffset0=5",
b"maxp2ga0=84",
b"txpwrbckof=6",
b"cckbw202gpo=0",
b"legofdmbw202gpo=0x66111111",
b"mcsbw202gpo=0x77711111",
b"propbw202gpo=0xdd",
b"ofdmdigfilttype=18",
b"ofdmdigfilttypebe=18",
b"papdmode=1",
b"papdvalidtest=1",
b"pacalidx2g=45",
b"papdepsoffset=-30",
b"papdendidx=58",
b"ltecxmux=0",
b"ltecxpadnum=0x0102",
b"ltecxfnsel=0x44",
b"ltecxgcigpio=0x01",
b"il0macaddr=00:90:4c:c5:12:38",
b"wl0id=0x431b",
b"deadman_to=0xffffffff",
b"muxenab=0x100",
b"spurconfig=0x3",
b"glitch_based_crsmin=1",
b"btc_mode=1",
);
pub static NVRAM: &'static [u8] = b"
NVRAMRev=$Rev$\x00\
manfid=0x2d0\x00\
prodid=0x0727\x00\
vendid=0x14e4\x00\
devid=0x43e2\x00\
boardtype=0x0887\x00\
boardrev=0x1100\x00\
boardnum=22\x00\
macaddr=00:A0:50:b5:59:5e\x00\
sromrev=11\x00\
boardflags=0x00404001\x00\
boardflags3=0x04000000\x00\
xtalfreq=37400\x00\
nocrc=1\x00\
ag0=255\x00\
aa2g=1\x00\
ccode=ALL\x00\
pa0itssit=0x20\x00\
extpagain2g=0\x00\
pa2ga0=-168,6649,-778\x00\
AvVmid_c0=0x0,0xc8\x00\
cckpwroffset0=5\x00\
maxp2ga0=84\x00\
txpwrbckof=6\x00\
cckbw202gpo=0\x00\
legofdmbw202gpo=0x66111111\x00\
mcsbw202gpo=0x77711111\x00\
propbw202gpo=0xdd\x00\
ofdmdigfilttype=18\x00\
ofdmdigfilttypebe=18\x00\
papdmode=1\x00\
papdvalidtest=1\x00\
pacalidx2g=45\x00\
papdepsoffset=-30\x00\
papdendidx=58\x00\
ltecxmux=0\x00\
ltecxpadnum=0x0102\x00\
ltecxfnsel=0x44\x00\
ltecxgcigpio=0x01\x00\
il0macaddr=00:90:4c:c5:12:38\x00\
wl0id=0x431b\x00\
deadman_to=0xffffffff\x00\
muxenab=0x100\x00\
spurconfig=0x3\x00\
glitch_based_crsmin=1\x00\
btc_mode=1\x00\
\x00";

View File

@ -555,14 +555,14 @@ where
self.bus.bp_write8(base + AI_RESETCTRL_OFFSET, 0).await;
Timer::after(Duration::from_millis(1)).await;
Timer::after_millis(1).await;
self.bus
.bp_write8(base + AI_IOCTRL_OFFSET, AI_IOCTRL_BIT_CLOCK_EN)
.await;
let _ = self.bus.bp_read8(base + AI_IOCTRL_OFFSET).await;
Timer::after(Duration::from_millis(1)).await;
Timer::after_millis(1).await;
}
async fn core_is_up(&mut self, core: Core) -> bool {

View File

@ -6,9 +6,9 @@ version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-executor = { version = "0.3.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] }
embassy-time = { version = "0.1.0", path = "../../../../../embassy-time", features = ["defmt", "nightly"] }
embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] }
embassy-executor = { version = "0.3.0", path = "../../../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] }
embassy-time = { version = "0.1.4", path = "../../../../../embassy-time", features = ["defmt"] }
embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] }
defmt = "0.3"
defmt-rtt = "0.3"

View File

@ -1,6 +1,7 @@
* xref:getting_started.adoc[Getting started]
** xref:basic_application.adoc[Basic application]
** xref:layer_by_layer.adoc[Layer by Layer]
** xref:project_structure.adoc[Project Structure]
* xref:layer_by_layer.adoc[Bare metal to async]
* xref:runtime.adoc[Executor]
* xref:hal.adoc[HAL]
** xref:nrf.adoc[nRF]
@ -8,3 +9,6 @@
* xref:bootloader.adoc[Bootloader]
* xref:examples.adoc[Examples]
* xref:developer.adoc[Developer]
** xref:developer_stm32.adoc[Developer: STM32]
* xref:faq.adoc[Frequently Asked Questions]

View File

@ -6,13 +6,22 @@ So you've got one of the xref:examples.adoc[examples] running, but what now? Let
The full example can be found link:https://github.com/embassy-rs/embassy/tree/master/docs/modules/ROOT/examples/basic[here].
=== Rust Nightly
=== Bare metal
The first thing you'll notice is a few declarations stating that Embassy requires some nightly features:
The first thing you'll notice is a few declarations, two of which indicate that Embassy is suitable for bare metal development:
[source,rust]
----
include::example$basic/src/main.rs[lines="1..3"]
include::example$basic/src/main.rs[lines="1..2"]
----
=== Rust Nightly
The next declaration is a Rust Unstable feature, which means that Embassy requires Rust Nightly:
[source,rust]
----
include::example$basic/src/main.rs[lines="3"]
----
=== Dealing with errors
@ -48,7 +57,7 @@ The `Spawner` is the way the main application spawns other tasks. The `Periphera
include::example$basic/src/main.rs[lines="22..-1"]
----
What happens when the `blinker` task has been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy::main]` macro. The macro does the following:
What happens when the `blinker` task has been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy_executor::main]` macro. The macro does the following:
. Creates an Embassy Executor
. Initializes the microcontroller HAL to get the `Peripherals`

View File

@ -0,0 +1 @@
= Developer Documentation

View File

@ -0,0 +1,79 @@
= Developer Documentation: STM32
== Understanding metapac
When a project that imports `embassy-stm32` is compiled, that project selects the feature corresponding to the chip that project is using. Based on that feature, `embassy-stm32` selects supported link:https://anysilicon.com/ip-intellectual-property-core-semiconductors/[IP] for the chip, and enables the corresponding HAL implementations. But how does `embassy-stm32` know what IP the chip contains, out of the hundreds of chips that we support? It's a long story that starts with `stm32-data-sources`.
== `stm32-data-sources`
link:https://github.com/embassy-rs/stm32-data-sources[`stm32-data-sources`] is as mostly barren repository. It has no README, no documentation, and few watchers. But it's the core of what makes `embassy-stm32` possible. The data for every chip that we support is taken in part from a corresponding XML file like link:https://github.com/embassy-rs/stm32-data-sources/blob/b8b85202e22a954d6c59d4a43d9795d34cff05cf/cubedb/mcu/STM32F051K4Ux.xml[`STM32F051K4Ux.xml`]. In that file, you'll see lines like the following:
[source,xml]
----
<IP InstanceName="I2C1" Name="I2C" Version="i2c2_v1_1_Cube"/>
<!-- snip -->
<IP ConfigFile="TIM-STM32F0xx" InstanceName="TIM1" Name="TIM1_8F0" Version="gptimer2_v2_x_Cube"/>
----
These lines indicate that this chip has an i2c, and that it's version is "v1_1". It also indicates that it has a general purpose timer that with a version of "v2_x". From this data, it's possible to determine which implementations should be included in `embassy-stm32`. But actually doing that is another matter.
== `stm32-data`
While all users of this project are familiar with `embassy-stm32`, fewer are familiar with the project that powers it: `stm32-data`. This project doesn't just aim to generate data for `embassy-stm32`, but for machine consumption in general. To acheive this, information from multiple files from the `stm32-data-sources` project are combined and parsed to assign register block implementations for each supported IP. The core of this matching resides in `chips.rs`:
[source,rust]
----
(".*:I2C:i2c2_v1_1", ("i2c", "v2", "I2C")),
// snip
(r".*TIM\d.*:gptimer.*", ("timer", "v1", "TIM_GP16")),
----
In this case, the i2c version corresponds to our "v2" and the general purpose timer version corresponds to our "v1". Therefore, the `i2c_v2.yaml` and `timer_v1.yaml` register block implementations are assigned to those IP, respectively. The result is that these lines arr generated in `STM32F051K4.json`:
[source,json]
----
{
"name": "I2C1",
"address": 1073763328,
"registers": {
"kind": "i2c",
"version": "v2",
"block": "I2C"
},
// snip
}
// snip
{
"name": "TIM1",
"address": 1073818624,
"registers": {
"kind": "timer",
"version": "v1",
"block": "TIM_ADV"
},
// snip
}
----
In addition to register blocks, data for pin and RCC mapping is also generated and consumed by `embassy-stm32`. `stm32-metapac-gen` is used to package and publish the data as a crate.
== `embassy-stm32`
In the `lib.rs` file located in the root of `embassy-stm32`, you'll see this line:
[source,rust]
----
#[cfg(i2c)]
pub mod i2c;
----
And in the `mod.rs` of the i2c mod, you'll see this:
[source,rust]
----
#[cfg_attr(i2c_v2, path = "v2.rs")]
----
Because i2c is supported for STM32F051K4 and its version corresponds to our "v2", the `i2c` and `i2c_v2`, configuration directives will be present, and `embassy-stm32` will include these files, respectively. This and other configuration directives and tables are generated from the data for chip, allowing `embassy-stm32` to expressively and clearly adapt logic and implementations to what is required for each chip. Compared to other projects across the embedded ecosystem, `embassy-stm32` is the only project that can re-use code across the entire stm32 lineup and remove difficult-to-implement unsafe logic to the HAL.

View File

@ -0,0 +1,137 @@
= Frequently Asked Questions
These are a list of unsorted, commonly asked questions and answers.
Please feel free to add items to link:https://github.com/embassy-rs/embassy/edit/main/docs/modules/ROOT/pages/faq.adoc[this page], especially if someone in the chat answered a question for you!
== How to deploy to RP2040 without a debugging probe.
Install link:https://github.com/JoNil/elf2uf2-rs[elf2uf2-rs] for converting the generated elf binary into a uf2 file.
Configure the runner to use this tool, add this to `.cargo/config.toml`:
[source,toml]
----
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "elf2uf2-rs --deploy --serial --verbose"
----
The command-line parameters `--deploy` will detect your device and upload the binary, `--serial` starts a serial connection. See the documentation for more info.
== Missing main macro
If you see an error like this:
[source,rust]
----
#[embassy_executor::main]
| ^^^^ could not find `main` in `embassy_executor`
----
You are likely missing some features of the `embassy-executor` crate.
For Cortex-M targets, consider making sure that ALL of the following features are active in your `Cargo.toml` for the `embassy-executor` crate:
* `arch-cortex-m`
* `executor-thread`
* `nightly`
For Xtensa ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate].
== Why is my binary so big?
The first step to managing your binary size is to set up your link:https://doc.rust-lang.org/cargo/reference/profiles.html[profiles].
[source,toml]
----
[profile.release]
debug = false
lto = true
opt-level = "s"
incremental = true
----
All of these flags are elaborated on in the Rust Book page linked above.
=== My binary is still big... filled with `std::fmt` stuff!
This means your code is sufficiently complex that `panic!` invocation's formatting requirements could not be optimized out, despite your usage of `panic-halt` or `panic-reset`.
You can remedy this by adding the following to your `.cargo/config.toml`:
[source,toml]
----
[unstable]
build-std = ["core"]
build-std-features = ["panic_immediate_abort"]
----
This replaces all panics with a `UDF` (undefined) instruction.
Depending on your chipset, this will exhibit different behavior.
Refer to the spec for your chipset, but for `thumbv6m`, it results in a hardfault. Which can be configured like so:
[source,rust]
----
#[exception]
unsafe fn HardFault(_frame: &ExceptionFrame) -> ! {
SCB::sys_reset() // <- you could do something other than reset
}
----
Refer to cortex-m's link:https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.exception.html[exception handling] for more info.
== `embassy-time` throws linker errors
If you see linker error like this:
[source,text]
----
= note: rust-lld: error: undefined symbol: _embassy_time_now
>>> referenced by driver.rs:127 (src/driver.rs:127)
>>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::now::hefb1f99d6e069842) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib
rust-lld: error: undefined symbol: _embassy_time_allocate_alarm
>>> referenced by driver.rs:134 (src/driver.rs:134)
>>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::allocate_alarm::hf5145b6bd46706b2) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib
rust-lld: error: undefined symbol: _embassy_time_set_alarm_callback
>>> referenced by driver.rs:139 (src/driver.rs:139)
>>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::set_alarm_callback::h24f92388d96eafd2) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib
rust-lld: error: undefined symbol: _embassy_time_set_alarm
>>> referenced by driver.rs:144 (src/driver.rs:144)
>>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::set_alarm::h530a5b1f444a6d5b) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib
----
You probably need to enable a time driver for your HAL (not in `embassy-time`!). For example with `embassy-stm32`, you might need to enable `time-driver-any`:
[source,toml]
----
[dependencies.embassy-stm32]
version = "0.1.0"
features = [
# ...
"time-driver-any", # Add this line!
# ...
]
----
== Error: `Only one package in the dependency graph may specify the same links value.`
You have multiple versions of the same crate in your dependency tree. This means that some of your
embassy crates are coming from crates.io, and some from git, each of them pulling in a different set
of dependencies.
To resolve this issue, make sure to only use a single source for all your embassy crates! To do this,
you should patch your dependencies to use git sources using `[patch.crates.io]` and maybe `[patch.'https://github.com/embassy-rs/embassy.git']`.
Example:
[source,toml]
----
[patch.crates-io]
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" }
----
Note that the git revision should match any other embassy patches or git dependencies that you are using!

View File

@ -3,7 +3,7 @@
So you want to try Embassy, great! To get started, there are a few tools you need to install:
* link:https://rustup.rs/[rustup] - the Rust toolchain is needed to compile Rust code.
* link:https://crates.io/crates/probe-run[probe-run] - to flash the firmware on your device. If you already have other tools like `OpenOCD` setup, you can use that as well.
* link:https://crates.io/crates/probe-rs[probe-rs] - to flash the firmware on your device. If you already have other tools like `OpenOCD` setup, you can use that as well.
If you don't have any supported board, don't worry: you can also run embassy on your PC using the `std` examples.
@ -30,6 +30,10 @@ Embassy supports many microcontroller families, but the easiest ways to get star
* link:https://www.raspberrypi.com/products/raspberry-pi-pico/[Raspberry Pi Pico]
=== ESP32
* link:https://github.com/esp-rs/esp-rust-board[ESP32C3]
== Running an example
First you need to clone the [github repository];
@ -38,7 +42,6 @@ First you need to clone the [github repository];
----
git clone https://github.com/embassy-rs/embassy.git
cd embassy
git submodule update --init
----
You can run an example by opening a terminal and entering the following commands:

View File

@ -7,4 +7,6 @@ Embassy provides HALs for several microcontroller families:
* `embassy-rp` for the Raspberry Pi RP2040 microcontrollers
These HALs implement async/await functionality for most peripherals while also implementing the
async traits in `embedded-hal-async`. You can also use these HALs with another executor.
async traits in `embedded-hal` and `embedded-hal-async`. You can also use these HALs with another executor.
For the ESP32 series, there is an link:https://github.com/esp-rs/esp-hal[esp-hal] which you can use.

View File

@ -4,14 +4,9 @@ Embassy is a project to make async/await a first-class option for embedded devel
== What is async?
Software written without async may block on I/O operations. In an std environment, such as a PC, software can handle this either by using threads or non-blocking operations.
When handling I/O, software must call functions that block program execution until the I/O operation completes. When running inside of an OS such as Linux, such functions generally transfer control to the kernel so that another task, known as a thread, can be executed if available, or the CPU can be put to sleep until another such task is ready to perform more work. Because an OS cannot presume that threads will behave cooperatively, threads are relatively resource-intensive, and may be forcibly interrupted they do not transfer control back to the kernel within an allotted time. But if tasks could be presumed to behave cooperatively, or at least not maliciously, it would be possible to create tasks that appear to be almost free when compared to a traditional OS thread. In Rust, these lightweight tasks, known as 'coroutines' or 'goroutines' in other languages, are implemented with async.
With threads, one thread blocks on an I/O operation, another is able to take its place. However, even on a PC, threads are relatively heavy, and therefore some programming languages, such as Go, have implemented a concept called coroutines or 'goroutines' that are much lighter and less-intensive than threads.
The other way to handle blocking I/O operations is to support polling the state of the underlying peripherals to check whether it is available to perform the requested operation. In programming languages without builtin async support,
this requires building a complex loop checking for events.
In Rust, non-blocking operations can be implemented using async-await. Async-await works by transforming each async function into an object called a future. When a future blocks on I/O the future yields, and the scheduler, called an executor, can select a different future to execute. Compared to alternatives such as an RTOS, async can yield better performance and lower power consumption because the executor doesn't have to guess when a future is ready to execute. However, program size may be higher than other alternatives, which may be a problem for certain space-constrained devices with very low memory. On the devices Embassy supports, such as stm32 and nrf, memory is generally large enough to accommodate the modestly-increased program size.
Async-await works by transforming each async function into an object called a future. When a future blocks on I/O the future yields, and the scheduler, called an executor, can select a different future to execute. Compared to alternatives such as an RTOS, async can yield better performance and lower power consumption because the executor doesn't have to guess when a future is ready to execute. However, program size may be higher than other alternatives, which may be a problem for certain space-constrained devices with very low memory. On the devices Embassy supports, such as stm32 and nrf, memory is generally large enough to accommodate the modestly-increased program size.
== What is Embassy?
@ -22,13 +17,26 @@ The Embassy project consists of several crates that you can use together or inde
* **Hardware Abstraction Layers** - HALs implement safe, idiomatic Rust APIs to use the hardware capabilities, so raw register manipulation is not needed. The Embassy project maintains HALs for select hardware, but you can still use HALs from other projects with Embassy.
** link:https://docs.embassy.dev/embassy-stm32/[embassy-stm32], for all STM32 microcontroller families.
** link:https://docs.embassy.dev/embassy-nrf/[embassy-nrf], for the Nordic Semiconductor nRF52, nRF53, nRF91 series.
** link:https://docs.embassy.dev/embassy-rp/[embassy-rp], for the Raspberry Pi RP2040 microcontroller.
** link:https://github.com/esp-rs[esp-rs], for the Espressif Systems ESP32 series of chips.
+
NOTE: A common question is if one can use the Embassy HALs standalone. Yes, it is possible! There are no dependency on the executor within the HALs. You can even use them without async,
as they implement both the link:https://github.com/rust-embedded/embedded-hal[Embedded HAL] blocking and async traits.
* **Networking** - The link:https://docs.embassy.dev/embassy-net/[embassy-net] network stack implements extensive networking functionality, including Ethernet, IP, TCP, UDP, ICMP and DHCP. Async drastically simplifies managing timeouts and serving multiple connections concurrently.
* **Networking** - The link:https://docs.embassy.dev/embassy-net/[embassy-net] network stack implements extensive networking functionality, including Ethernet, IP, TCP, UDP, ICMP and DHCP. Async drastically simplifies managing timeouts and serving multiple connections concurrently. Several drivers for WiFi and Ethernet chips can be found.
* **Bluetooth** - The link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] crate provides Bluetooth Low Energy 4.x and 5.x support for nRF52 microcontrollers.
* **LoRa** - link:https://docs.embassy.dev/embassy-lora/[embassy-lora] supports LoRa networking on STM32WL wireless microcontrollers and Semtech SX127x transceivers.
* **LoRa** - link:https://github.com/embassy-rs/lora-phy[lora-phy] and link:https://docs.embassy.dev/embassy-lora/[embassy-lora] supports LoRa networking on a wide range of LoRa radios, fully integrated with a Rust link:https://github.com/ivajloip/rust-lorawan[LoRaWAN] implementation.
* **USB** - link:https://docs.embassy.dev/embassy-usb/[embassy-usb] implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own.
* **Bootloader and DFU** - link:https://github.com/embassy-rs/embassy/tree/master/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks.
== Resources
For more reading material on async Rust and Embassy:
* link:https://tweedegolf.nl/en/blog/65/async-rust-vs-rtos-showdown[Comparsion of FreeRTOS and Embassy]
* link:https://dev.to/apollolabsbin/series/20707[Tutorials]
* link:https://blog.drogue.io/firmware-updates-part-1/[Firmware Updates with Embassy]

View File

@ -1,4 +1,4 @@
= Embassy layer by layer
= From bare metal to async Rust
If you're new to Embassy, it can be overwhelming to grasp all the terminology and concepts. This guide aims to clarify the different layers in Embassy, which problem each layer solves for the application writer.
@ -8,8 +8,7 @@ The application we'll write is a simple 'push button, blink led' application, wh
== PAC version
The PAC is the lowest API for accessing peripherals and registers, if you don't count reading/writing directly to memory addresses. It provides distinct types
to make accessing peripheral registers easier, but it does not prevent you from writing unsafe code.
The PAC is the lowest API for accessing peripherals and registers, if you don't count reading/writing directly to memory addresses. It provides distinct types to make accessing peripheral registers easier, but it does not prevent you from writing unsafe code.
Writing an application using the PAC directly is therefore not recommended, but if the functionality you want to use is not exposed in the upper layers, that's what you need to use.

View File

@ -8,7 +8,7 @@ The nRF timer driver operates at 32768 Hz by default.
== Peripherals
The following peripherals have a HAL implementation at present:
The following peripherals have a HAL implementation at present
* PWM
* SPIM
@ -23,3 +23,7 @@ The following peripherals have a HAL implementation at present:
* UARTE
* TWIM
* SAADC
== Bluetooth
For bluetooth, you can use the link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] crate.

View File

@ -0,0 +1,80 @@
= Project Structure
There are many ways to configure embassy and its components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrates how your project structure should look. Let's break it down:
The toplevel file structure of your project should look like this:
[source,plain]
----
{} = Maybe
my-project
|- .cargo
| |- config.toml
|- src
| |- main.rs
|- build.rs
|- Cargo.toml
|- {memory.x}
|- rust-toolchain.toml
----
=== .cargo/config.toml
This directory/file describes what platform you're on, and configures link:https://github.com/probe-rs/probe-rs[probe-rs] to deploy to your device.
Here is a minimal example:
[source,toml]
----
[target.thumbv6m-none-eabi] # <-change for your platform
runner = 'probe-rs run --chip STM32F031K6Tx' # <- change for your chip
[build]
target = "thumbv6m-none-eabi" # <-change for your platform
[env]
DEFMT_LOG = "trace" # <- can change to info, warn, or error
----
=== build.rs
This is the build script for your project. It links defmt (what is defmt?) and the `memory.x` file if needed. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example].
=== Cargo.toml
This is your manifest file, where you can configure all of the embassy components to use the features you need.
TODO: someone should exhaustively describe every feature for every component!
=== memory.x
This file outlines the flash/ram usage of your program. It is especially useful when using link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] on an nRF5x.
Here is an example for using S140 with an nRF52840:
[source,x]
----
MEMORY
{
/* NOTE 1 K = 1 KiBi = 1024 bytes */
/* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */
FLASH : ORIGIN = 0x00027000, LENGTH = 868K
RAM : ORIGIN = 0x20020000, LENGTH = 128K
}
----
=== rust-toolchain.toml
This file configures the rust version and configuration to use.
A minimal example:
[source,toml]
----
[toolchain]
channel = "nightly-2023-08-19" # <- as of writing, this is the exact rust version embassy uses
components = [ "rust-src", "rustfmt" ] # <- optionally add "llvm-tools-preview" for some extra features like "cargo size"
targets = [
"thumbv6m-none-eabi" # <-change for your platform
]
----

View File

@ -6,11 +6,11 @@ The Embassy executor is an async/await executor designed for embedded usage alon
* No `alloc`, no heap needed. Task are statically allocated.
* No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning.
* Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`.
* Integrated timer queue: sleeping is easy, just do `Timer::after_secs(1).await;`.
* No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`.
* Efficient polling: a wake will only poll the woken task, not all of them.
* Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time.
* Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks.
* Creating multiple executor instances is supported, to run tasks at different priority levels. This allows higher-priority tasks to preempt lower-priority tasks.
== Executor
@ -27,7 +27,7 @@ If you use the `#[embassy_executor::main]` macro in your application, it creates
Interrupts are a common way for peripherals to signal completion of some operation and fits well with the async execution model. The following diagram describes a typical application flow where (1) a task is polled and is attempting to make progress. The task then (2) instructs the peripheral to perform some operation, and awaits. After some time has passed, (3) an interrupt is raised, marking the completion of the operation.
The peripheral HAL then (4) ensures that interrupt signals are routed to to the peripheral and updating the peripheral state with the results of the operation. The executor is then (5) notified that the task should be polled, which it will do.
The peripheral HAL then (4) ensures that interrupt signals are routed to the peripheral and updating the peripheral state with the results of the operation. The executor is then (5) notified that the task should be polled, which it will do.
image::embassy_irq.png[Interrupt handling]

View File

@ -25,12 +25,12 @@ features = ["defmt"]
[dependencies]
defmt = { version = "0.3", optional = true }
digest = "0.10"
log = { version = "0.4", optional = true }
log = { version = "0.4", optional = true }
ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true }
embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }
embassy-sync = { version = "0.2.0", path = "../../embassy-sync" }
embassy-sync = { version = "0.4.0", path = "../../embassy-sync" }
embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.4.0", optional = true }
embedded-storage-async = { version = "0.4.0" }
salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true }
signature = { version = "1.6.4", default-features = false }
@ -50,7 +50,5 @@ features = ["rand", "std", "u32_backend"]
ed25519-dalek = ["dep:ed25519-dalek", "_verify"]
ed25519-salty = ["dep:salty", "_verify"]
nightly = ["dep:embedded-storage-async", "embassy-embedded-hal/nightly"]
#Internal features
_verify = []

View File

@ -1,8 +1,6 @@
#[cfg(feature = "nightly")]
mod asynch;
mod blocking;
#[cfg(feature = "nightly")]
pub use asynch::{FirmwareState, FirmwareUpdater};
pub use blocking::{BlockingFirmwareState, BlockingFirmwareUpdater};
use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -1,5 +1,5 @@
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
#![no_std]
#![allow(async_fn_in_trait)]
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
mod fmt;
@ -17,10 +17,9 @@ mod test_flash;
pub(crate) const STATE_ERASE_VALUE: u8 = 0xFF;
pub use boot_loader::{BootError, BootLoader, BootLoaderConfig};
pub use firmware_updater::{
BlockingFirmwareState, BlockingFirmwareUpdater, FirmwareUpdaterConfig, FirmwareUpdaterError,
BlockingFirmwareState, BlockingFirmwareUpdater, FirmwareState, FirmwareUpdater, FirmwareUpdaterConfig,
FirmwareUpdaterError,
};
#[cfg(feature = "nightly")]
pub use firmware_updater::{FirmwareState, FirmwareUpdater};
pub(crate) const BOOT_MAGIC: u8 = 0xD0;
pub(crate) const SWAP_MAGIC: u8 = 0xF0;
@ -56,7 +55,6 @@ mod tests {
#![allow(unused_imports)]
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
#[cfg(feature = "nightly")]
use embedded_storage_async::nor_flash::NorFlash as AsyncNorFlash;
use futures::executor::block_on;
@ -64,9 +62,7 @@ mod tests {
use crate::boot_loader::BootLoaderConfig;
use crate::firmware_updater::FirmwareUpdaterConfig;
use crate::mem_flash::MemFlash;
#[cfg(feature = "nightly")]
use crate::test_flash::AsyncTestFlash;
use crate::test_flash::BlockingTestFlash;
use crate::test_flash::{AsyncTestFlash, BlockingTestFlash};
/*
#[test]
@ -104,7 +100,7 @@ mod tests {
}
#[test]
#[cfg(all(feature = "nightly", not(feature = "_verify")))]
#[cfg(not(feature = "_verify"))]
fn test_swap_state() {
const FIRMWARE_SIZE: usize = 57344;
let flash = AsyncTestFlash::new(BootLoaderConfig {
@ -182,7 +178,7 @@ mod tests {
}
#[test]
#[cfg(all(feature = "nightly", not(feature = "_verify")))]
#[cfg(not(feature = "_verify"))]
fn test_swap_state_active_page_biggest() {
const FIRMWARE_SIZE: usize = 12288;
let flash = AsyncTestFlash::new(BootLoaderConfig {
@ -227,7 +223,7 @@ mod tests {
}
#[test]
#[cfg(all(feature = "nightly", not(feature = "_verify")))]
#[cfg(not(feature = "_verify"))]
fn test_swap_state_dfu_page_biggest() {
const FIRMWARE_SIZE: usize = 12288;
let flash = AsyncTestFlash::new(BootLoaderConfig {
@ -271,7 +267,7 @@ mod tests {
}
#[test]
#[cfg(all(feature = "nightly", feature = "_verify"))]
#[cfg(feature = "_verify")]
fn test_verify() {
// The following key setup is based on:
// https://docs.rs/ed25519-dalek/latest/ed25519_dalek/#example

View File

@ -3,7 +3,6 @@
use core::ops::{Bound, Range, RangeBounds};
use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash};
#[cfg(feature = "nightly")]
use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
pub struct MemFlash<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> {
@ -141,7 +140,6 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> NorFla
}
}
#[cfg(feature = "nightly")]
impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncReadNorFlash
for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE>
{
@ -156,7 +154,6 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncR
}
}
#[cfg(feature = "nightly")]
impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncNorFlash
for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE>
{

View File

@ -51,7 +51,6 @@ where
}
}
#[cfg(feature = "nightly")]
impl<ACTIVE, DFU, STATE> BlockingTestFlash<ACTIVE, DFU, STATE>
where
ACTIVE: NorFlash + embedded_storage_async::nor_flash::NorFlash,

View File

@ -1,7 +1,5 @@
#[cfg(feature = "nightly")]
mod asynch;
mod blocking;
#[cfg(feature = "nightly")]
pub(crate) use asynch::AsyncTestFlash;
pub(crate) use blocking::BlockingTestFlash;

View File

@ -16,13 +16,13 @@ target = "thumbv7em-none-eabi"
[dependencies]
defmt = { version = "0.3", optional = true }
embassy-sync = { path = "../../embassy-sync" }
embassy-sync = { version = "0.4.0", path = "../../embassy-sync" }
embassy-nrf = { path = "../../embassy-nrf" }
embassy-boot = { path = "../boot", default-features = false }
cortex-m = { version = "0.7.6" }
cortex-m-rt = { version = "0.7" }
embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.4.0", optional = true }
embedded-storage-async = { version = "0.4.0" }
cfg-if = "1.0.0"
nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true }
@ -36,8 +36,3 @@ defmt = [
softdevice = [
"nrf-softdevice-mbr",
]
nightly = [
"dep:embedded-storage-async",
"embassy-boot/nightly",
"embassy-nrf/nightly"
]

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -4,10 +4,9 @@
mod fmt;
pub use embassy_boot::{
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareUpdaterConfig,
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater,
FirmwareUpdaterConfig,
};
#[cfg(feature = "nightly")]
pub use embassy_boot::{FirmwareState, FirmwareUpdater};
use embassy_nrf::nvmc::PAGE_SIZE;
use embassy_nrf::peripherals::WDT;
use embassy_nrf::wdt;

View File

@ -17,7 +17,7 @@ defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.4", optional = true }
log = { version = "0.4", optional = true }
embassy-sync = { path = "../../embassy-sync" }
embassy-sync = { version = "0.4.0", path = "../../embassy-sync" }
embassy-rp = { path = "../../embassy-rp", default-features = false }
embassy-boot = { path = "../boot", default-features = false }
embassy-time = { path = "../../embassy-time" }
@ -25,7 +25,7 @@ embassy-time = { path = "../../embassy-time" }
cortex-m = { version = "0.7.6" }
cortex-m-rt = { version = "0.7" }
embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.4.0", optional = true }
embedded-storage-async = { version = "0.4.0" }
cfg-if = "1.0.0"
[features]
@ -40,12 +40,6 @@ log = [
"embassy-rp/log",
]
debug = ["defmt-rtt"]
nightly = [
"dep:embedded-storage-async",
"embassy-boot/nightly",
"embassy-rp/nightly",
"embassy-time/nightly"
]
[profile.dev]
debug = 2

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -4,10 +4,9 @@
mod fmt;
pub use embassy_boot::{
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareUpdaterConfig, State,
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater,
FirmwareUpdaterConfig, State,
};
#[cfg(feature = "nightly")]
pub use embassy_boot::{FirmwareState, FirmwareUpdater};
use embassy_rp::flash::{Blocking, Flash, ERASE_SIZE};
use embassy_rp::peripherals::{FLASH, WATCHDOG};
use embassy_rp::watchdog::Watchdog;

View File

@ -18,32 +18,19 @@ defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.4", optional = true }
log = { version = "0.4", optional = true }
embassy-sync = { path = "../../embassy-sync" }
embassy-sync = { version = "0.4.0", path = "../../embassy-sync" }
embassy-stm32 = { path = "../../embassy-stm32", default-features = false }
embassy-boot = { path = "../boot", default-features = false }
cortex-m = { version = "0.7.6" }
cortex-m-rt = { version = "0.7" }
embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.4.0", optional = true }
embedded-storage-async = { version = "0.4.0" }
cfg-if = "1.0.0"
[features]
defmt = [
"dep:defmt",
"embassy-boot/defmt",
"embassy-stm32/defmt",
]
log = [
"dep:log",
"embassy-boot/log",
"embassy-stm32/log",
]
defmt = ["dep:defmt", "embassy-boot/defmt", "embassy-stm32/defmt"]
log = ["dep:log", "embassy-boot/log", "embassy-stm32/log"]
debug = ["defmt-rtt"]
nightly = [
"dep:embedded-storage-async",
"embassy-boot/nightly",
"embassy-stm32/nightly"
]
[profile.dev]
debug = 2

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -4,10 +4,9 @@
mod fmt;
pub use embassy_boot::{
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareUpdaterConfig, State,
AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater,
FirmwareUpdaterConfig, State,
};
#[cfg(feature = "nightly")]
pub use embassy_boot::{FirmwareState, FirmwareUpdater};
use embedded_storage::nor_flash::NorFlash;
/// A bootloader for STM32 devices.

View File

@ -8,27 +8,25 @@ license = "MIT OR Apache-2.0"
[package.metadata.embassy_docs]
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/"
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/"
features = ["nightly", "std"]
features = ["std"]
target = "x86_64-unknown-linux-gnu"
[features]
std = []
# Enable nightly-only features
nightly = ["embassy-futures", "embedded-hal-async", "embedded-storage-async"]
time = ["dep:embassy-time"]
default = ["time"]
[dependencies]
embassy-futures = { version = "0.1.0", path = "../embassy-futures", optional = true }
embassy-sync = { version = "0.2.0", path = "../embassy-sync" }
embassy-time = { version = "0.1.3", path = "../embassy-time", optional = true }
embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
embassy-sync = { version = "0.4.0", path = "../embassy-sync" }
embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [
"unproven",
] }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" }
embedded-hal-async = { version = "=1.0.0-rc.1", optional = true }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" }
embedded-hal-async = { version = "=1.0.0-rc.2" }
embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.4.0", optional = true }
embedded-storage-async = { version = "0.4.0" }
nb = "1.0.0"
defmt = { version = "0.3", optional = true }

View File

@ -0,0 +1,18 @@
use std::env;
use std::ffi::OsString;
use std::process::Command;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
let output = Command::new(rustc)
.arg("--version")
.output()
.expect("failed to run `rustc --version`");
if String::from_utf8_lossy(&output.stdout).contains("nightly") {
println!("cargo:rustc-cfg=nightly");
}
}

View File

@ -1,5 +1,4 @@
use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, ReadNorFlash};
#[cfg(feature = "nightly")]
use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
/// Convenience helper for concatenating two consecutive flashes into one.
@ -117,7 +116,6 @@ where
}
}
#[cfg(feature = "nightly")]
impl<First, Second, E> AsyncReadNorFlash for ConcatFlash<First, Second>
where
First: AsyncReadNorFlash<Error = E>,
@ -146,7 +144,6 @@ where
}
}
#[cfg(feature = "nightly")]
impl<First, Second, E> AsyncNorFlash for ConcatFlash<First, Second>
where
First: AsyncNorFlash<Error = E>,

View File

@ -1,7 +1,6 @@
use alloc::vec::Vec;
use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
#[cfg(feature = "nightly")]
use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
extern crate alloc;
@ -93,7 +92,6 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> NorFla
}
}
#[cfg(feature = "nightly")]
impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncReadNorFlash
for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE>
{
@ -109,7 +107,6 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncR
}
}
#[cfg(feature = "nightly")]
impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> AsyncNorFlash
for MemFlash<SIZE, ERASE_SIZE, WRITE_SIZE>
{

View File

@ -2,16 +2,14 @@
use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind};
#[cfg(feature = "nightly")]
mod asynch;
mod blocking;
#[cfg(feature = "nightly")]
pub use asynch::Partition;
pub use blocking::BlockingPartition;
/// Partition error
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error<T> {
/// The requested flash area is outside the partition

View File

@ -1,14 +1,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections, try_blocks))]
#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))]
#![cfg_attr(nightly, allow(stable_features, unknown_lints))]
#![allow(async_fn_in_trait)]
#![warn(missing_docs)]
//! Utilities to use `embedded-hal` traits with Embassy.
#[cfg(feature = "nightly")]
pub mod adapter;
pub mod flash;
pub mod shared_bus;
/// Set the configuration of a peripheral driver.
@ -26,6 +25,18 @@ pub trait SetConfig {
/// The configuration type used by this driver.
type Config;
/// The error type that can occur if `set_config` fails.
type ConfigError;
/// Set the configuration of the driver.
fn set_config(&mut self, config: &Self::Config);
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>;
}
/// Get the configuration of a peripheral driver.
pub trait GetConfig {
/// The configuration type used by this driver.
type Config;
/// Get the configuration of the driver.
fn get_config(&self) -> Self::Config;
}

View File

@ -2,16 +2,15 @@
//!
//! # Example (nrf52)
//!
//! ```rust
//! use embassy_embedded_hal::shared_bus::i2c::I2cDevice;
//! ```rust,ignore
//! use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
//! use embassy_sync::mutex::Mutex;
//! use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
//! use embassy_sync::blocking_mutex::raw::NoopRawMutex;
//!
//! static I2C_BUS: StaticCell<Mutex::<ThreadModeRawMutex, Twim<TWISPI0>>> = StaticCell::new();
//! static I2C_BUS: StaticCell<Mutex<NoopRawMutex, Twim<TWISPI0>>> = StaticCell::new();
//! let config = twim::Config::default();
//! let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0);
//! let i2c = Twim::new(p.TWISPI0, irq, p.P0_03, p.P0_04, config);
//! let i2c_bus = Mutex::<ThreadModeRawMutex, _>::new(i2c);
//! let i2c = Twim::new(p.TWISPI0, Irqs, p.P0_03, p.P0_04, config);
//! let i2c_bus = Mutex::new(i2c);
//! let i2c_bus = I2C_BUS.init(i2c_bus);
//!
//! // Device 1, using embedded-hal-async compatible driver for QMC5883L compass
@ -125,14 +124,14 @@ where
{
async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), I2cDeviceError<BUS::Error>> {
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.read(address, buffer).await.map_err(I2cDeviceError::I2c)?;
Ok(())
}
async fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), I2cDeviceError<BUS::Error>> {
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.write(address, bytes).await.map_err(I2cDeviceError::I2c)?;
Ok(())
}
@ -144,7 +143,7 @@ where
rd_buffer: &mut [u8],
) -> Result<(), I2cDeviceError<BUS::Error>> {
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.write_read(address, wr_buffer, rd_buffer)
.await
.map_err(I2cDeviceError::I2c)?;
@ -153,7 +152,7 @@ where
async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> {
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.transaction(address, operations)
.await
.map_err(I2cDeviceError::I2c)?;

View File

@ -2,17 +2,16 @@
//!
//! # Example (nrf52)
//!
//! ```rust
//! ```rust,ignore
//! use embassy_embedded_hal::shared_bus::spi::SpiDevice;
//! use embassy_sync::mutex::Mutex;
//! use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
//! use embassy_sync::blocking_mutex::raw::NoopRawMutex;
//!
//! static SPI_BUS: StaticCell<Mutex<ThreadModeRawMutex, spim::Spim<SPI3>>> = StaticCell::new();
//! static SPI_BUS: StaticCell<Mutex<NoopRawMutex, spim::Spim<SPI3>>> = StaticCell::new();
//! let mut config = spim::Config::default();
//! config.frequency = spim::Frequency::M32;
//! let irq = interrupt::take!(SPIM3);
//! let spi = spim::Spim::new_txonly(p.SPI3, irq, p.P0_15, p.P0_18, config);
//! let spi_bus = Mutex::<ThreadModeRawMutex, _>::new(spi);
//! let spi = spim::Spim::new_txonly(p.SPI3, Irqs, p.P0_15, p.P0_18, config);
//! let spi_bus = Mutex::new(spi);
//! let spi_bus = SPI_BUS.init(spi_bus);
//!
//! // Device 1, using embedded-hal-async compatible driver for ST7735 LCD display
@ -63,24 +62,36 @@ where
CS: OutputPin,
{
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> {
if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) {
return Err(SpiDeviceError::DelayNotSupported);
}
let mut bus = self.bus.lock().await;
self.cs.set_low().map_err(SpiDeviceError::Cs)?;
let op_res: Result<(), BUS::Error> = try {
let op_res = 'ops: {
for op in operations {
match op {
Operation::Read(buf) => bus.read(buf).await?,
Operation::Write(buf) => bus.write(buf).await?,
Operation::Transfer(read, write) => bus.transfer(read, write).await?,
Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await?,
let res = match op {
Operation::Read(buf) => bus.read(buf).await,
Operation::Write(buf) => bus.write(buf).await,
Operation::Transfer(read, write) => bus.transfer(read, write).await,
Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await,
#[cfg(not(feature = "time"))]
Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported),
Operation::DelayNs(_) => unreachable!(),
#[cfg(feature = "time")]
Operation::DelayUs(us) => {
embassy_time::Timer::after(embassy_time::Duration::from_micros(*us as _)).await
}
Operation::DelayNs(ns) => match bus.flush().await {
Err(e) => Err(e),
Ok(()) => {
embassy_time::Timer::after_nanos(*ns as _).await;
Ok(())
}
},
};
if let Err(e) = res {
break 'ops Err(e);
}
}
Ok(())
};
// On failure, it's important to still flush and deassert CS.
@ -129,25 +140,37 @@ where
CS: OutputPin,
{
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> {
if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) {
return Err(SpiDeviceError::DelayNotSupported);
}
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| SpiDeviceError::Config)?;
self.cs.set_low().map_err(SpiDeviceError::Cs)?;
let op_res: Result<(), BUS::Error> = try {
let op_res = 'ops: {
for op in operations {
match op {
Operation::Read(buf) => bus.read(buf).await?,
Operation::Write(buf) => bus.write(buf).await?,
Operation::Transfer(read, write) => bus.transfer(read, write).await?,
Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await?,
let res = match op {
Operation::Read(buf) => bus.read(buf).await,
Operation::Write(buf) => bus.write(buf).await,
Operation::Transfer(read, write) => bus.transfer(read, write).await,
Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await,
#[cfg(not(feature = "time"))]
Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported),
Operation::DelayNs(_) => unreachable!(),
#[cfg(feature = "time")]
Operation::DelayUs(us) => {
embassy_time::Timer::after(embassy_time::Duration::from_micros(*us as _)).await
}
Operation::DelayNs(ns) => match bus.flush().await {
Err(e) => Err(e),
Ok(()) => {
embassy_time::Timer::after_nanos(*ns as _).await;
Ok(())
}
},
};
if let Err(e) = res {
break 'ops Err(e);
}
}
Ok(())
};
// On failure, it's important to still flush and deassert CS.

View File

@ -148,7 +148,7 @@ where
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.bus.lock(|bus| {
let mut bus = bus.borrow_mut();
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.read(address, buffer).map_err(I2cDeviceError::I2c)
})
}
@ -156,7 +156,7 @@ where
fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error> {
self.bus.lock(|bus| {
let mut bus = bus.borrow_mut();
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.write(address, bytes).map_err(I2cDeviceError::I2c)
})
}
@ -164,7 +164,7 @@ where
fn write_read(&mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8]) -> Result<(), Self::Error> {
self.bus.lock(|bus| {
let mut bus = bus.borrow_mut();
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| I2cDeviceError::Config)?;
bus.write_read(address, wr_buffer, rd_buffer)
.map_err(I2cDeviceError::I2c)
})

View File

@ -55,6 +55,10 @@ where
CS: OutputPin,
{
fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Self::Error> {
if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) {
return Err(SpiDeviceError::DelayNotSupported);
}
self.bus.lock(|bus| {
let mut bus = bus.borrow_mut();
self.cs.set_low().map_err(SpiDeviceError::Cs)?;
@ -65,10 +69,10 @@ where
Operation::Transfer(read, write) => bus.transfer(read, write),
Operation::TransferInPlace(buf) => bus.transfer_in_place(buf),
#[cfg(not(feature = "time"))]
Operation::DelayUs(_) => Err(SpiDeviceError::DelayUsNotSupported),
Operation::DelayNs(_) => unreachable!(),
#[cfg(feature = "time")]
Operation::DelayUs(us) => {
embassy_time::block_for(embassy_time::Duration::from_micros(*us as _));
Operation::DelayNs(ns) => {
embassy_time::block_for(embassy_time::Duration::from_nanos(*ns as _));
Ok(())
}
});
@ -161,9 +165,13 @@ where
CS: OutputPin,
{
fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Self::Error> {
if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) {
return Err(SpiDeviceError::DelayNotSupported);
}
self.bus.lock(|bus| {
let mut bus = bus.borrow_mut();
bus.set_config(&self.config);
bus.set_config(&self.config).map_err(|_| SpiDeviceError::Config)?;
self.cs.set_low().map_err(SpiDeviceError::Cs)?;
let op_res = operations.iter_mut().try_for_each(|op| match op {
@ -172,10 +180,10 @@ where
Operation::Transfer(read, write) => bus.transfer(read, write),
Operation::TransferInPlace(buf) => bus.transfer_in_place(buf),
#[cfg(not(feature = "time"))]
Operation::DelayUs(_) => Err(SpiDeviceError::DelayUsNotSupported),
Operation::DelayNs(_) => unreachable!(),
#[cfg(feature = "time")]
Operation::DelayUs(us) => {
embassy_time::block_for(embassy_time::Duration::from_micros(*us as _));
Operation::DelayNs(ns) => {
embassy_time::block_for(embassy_time::Duration::from_nanos(*ns as _));
Ok(())
}
});

View File

@ -3,9 +3,7 @@ use core::fmt::Debug;
use embedded_hal_1::{i2c, spi};
#[cfg(feature = "nightly")]
pub mod asynch;
pub mod blocking;
/// Error returned by I2C device implementations in this crate.
@ -14,6 +12,8 @@ pub mod blocking;
pub enum I2cDeviceError<BUS> {
/// An operation on the inner I2C bus failed.
I2c(BUS),
/// Configuration of the inner I2C bus failed.
Config,
}
impl<BUS> i2c::Error for I2cDeviceError<BUS>
@ -23,6 +23,7 @@ where
fn kind(&self) -> i2c::ErrorKind {
match self {
Self::I2c(e) => e.kind(),
Self::Config => i2c::ErrorKind::Other,
}
}
}
@ -36,8 +37,10 @@ pub enum SpiDeviceError<BUS, CS> {
Spi(BUS),
/// Setting the value of the Chip Select (CS) pin failed.
Cs(CS),
/// DelayUs operations are not supported when the `time` Cargo feature is not enabled.
DelayUsNotSupported,
/// Delay operations are not supported when the `time` Cargo feature is not enabled.
DelayNotSupported,
/// The SPI bus could not be configured.
Config,
}
impl<BUS, CS> spi::Error for SpiDeviceError<BUS, CS>
@ -49,7 +52,8 @@ where
match self {
Self::Spi(e) => e.kind(),
Self::Cs(_) => spi::ErrorKind::Other,
Self::DelayUsNotSupported => spi::ErrorKind::Other,
Self::DelayNotSupported => spi::ErrorKind::Other,
Self::Config => spi::ErrorKind::Other,
}
}
}

View File

@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
- Removed `arch-xtensa`. Use the executor provided by the HAL crate (`esp-hal`, `esp32s3-hal`, etc...) instead.
## 0.3.3 - 2023-11-15
- Add `main` macro reexport for Xtensa arch.
- Remove use of `atomic-polyfill`. The executor now has multiple implementations of its internal data structures for cases where the target supports atomics or doesn't.
## 0.3.2 - 2023-11-06
- Use `atomic-polyfill` for `riscv32`
- Removed unused dependencies (static_cell, futures-util)
## 0.3.1 - 2023-11-01
- Fix spurious "Found waker not created by the Embassy executor" error in recent nightlies.
## 0.3.0 - 2023-08-25
- Replaced Pender. Implementations now must define an extern function called `__pender`.

View File

@ -1,6 +1,6 @@
[package]
name = "embassy-executor"
version = "0.3.0"
version = "0.3.3"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "async/await executor designed for embedded usage"
@ -27,14 +27,37 @@ default-target = "thumbv7em-none-eabi"
targets = ["thumbv7em-none-eabi"]
features = ["nightly", "defmt", "arch-cortex-m", "executor-thread", "executor-interrupt"]
[dependencies]
defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }
rtos-trace = { version = "0.1.2", optional = true }
embassy-macros = { version = "0.2.1", path = "../embassy-macros" }
embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true}
critical-section = "1.1"
# needed for riscv
# remove when https://github.com/rust-lang/rust/pull/114499 is merged
portable-atomic = { version = "1.5", optional = true }
# arch-cortex-m dependencies
cortex-m = { version = "0.7.6", optional = true }
# arch-wasm dependencies
wasm-bindgen = { version = "0.2.82", optional = true }
js-sys = { version = "0.3", optional = true }
[dev-dependencies]
critical-section = { version = "1.1", features = ["std"] }
[features]
# Architecture
_arch = [] # some arch was picked
arch-std = ["_arch", "critical-section/std"]
arch-cortex-m = ["_arch", "dep:cortex-m"]
arch-xtensa = ["_arch"]
arch-riscv32 = ["_arch"]
arch-riscv32 = ["_arch", "dep:portable-atomic"]
arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"]
# Enable the thread-mode executor (using WFE/SEV in Cortex-M, WFI in other embedded archs)
@ -43,30 +66,53 @@ executor-thread = []
executor-interrupt = []
# Enable nightly-only features
nightly = []
nightly = ["embassy-macros/nightly"]
turbowakers = []
integrated-timers = ["dep:embassy-time"]
# Trace interrupt invocations with rtos-trace.
rtos-trace-interrupt = ["rtos-trace", "embassy-macros/rtos-trace-interrupt"]
# BEGIN AUTOGENERATED CONFIG FEATURES
# Generated by gen_config.py. DO NOT EDIT.
task-arena-size-64 = []
task-arena-size-128 = []
task-arena-size-192 = []
task-arena-size-256 = []
task-arena-size-320 = []
task-arena-size-384 = []
task-arena-size-512 = []
task-arena-size-640 = []
task-arena-size-768 = []
task-arena-size-1024 = []
task-arena-size-1280 = []
task-arena-size-1536 = []
task-arena-size-2048 = []
task-arena-size-2560 = []
task-arena-size-3072 = []
task-arena-size-4096 = [] # Default
task-arena-size-5120 = []
task-arena-size-6144 = []
task-arena-size-8192 = []
task-arena-size-10240 = []
task-arena-size-12288 = []
task-arena-size-16384 = []
task-arena-size-20480 = []
task-arena-size-24576 = []
task-arena-size-32768 = []
task-arena-size-40960 = []
task-arena-size-49152 = []
task-arena-size-65536 = []
task-arena-size-81920 = []
task-arena-size-98304 = []
task-arena-size-131072 = []
task-arena-size-163840 = []
task-arena-size-196608 = []
task-arena-size-262144 = []
task-arena-size-327680 = []
task-arena-size-393216 = []
task-arena-size-524288 = []
task-arena-size-655360 = []
task-arena-size-786432 = []
task-arena-size-1048576 = []
[dependencies]
defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }
rtos-trace = { version = "0.1.2", optional = true }
futures-util = { version = "0.3.17", default-features = false }
embassy-macros = { version = "0.2.1", path = "../embassy-macros" }
embassy-time = { version = "0.1.3", path = "../embassy-time", optional = true}
atomic-polyfill = "1.0.1"
critical-section = "1.1"
static_cell = "1.1"
# arch-cortex-m dependencies
cortex-m = { version = "0.7.6", optional = true }
# arch-wasm dependencies
wasm-bindgen = { version = "0.2.82", optional = true }
js-sys = { version = "0.3", optional = true }
# END AUTOGENERATED CONFIG FEATURES

View File

@ -2,10 +2,36 @@
An async/await executor designed for embedded usage.
- No `alloc`, no heap needed. Task futures are statically allocated.
- No `alloc`, no heap needed.
- With nightly Rust, task futures can be fully statically allocated.
- No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning.
- Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`.
- Integrated timer queue: sleeping is easy, just do `Timer::after_secs(1).await;`.
- No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`.
- Efficient polling: a wake will only poll the woken task, not all of them.
- Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time.
- Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks.
## Task arena
When the `nightly` Cargo feature is not enabled, `embassy-executor` allocates tasks out of an arena (a very simple bump allocator).
If the task arena gets full, the program will panic at runtime. To guarantee this doesn't happen, you must set the size to the sum of sizes of all tasks.
Tasks are allocated from the arena when spawned for the first time. If the task exists, the allocation is not released to the arena, but can be reused to spawn the task again. For multiple-instance tasks (like `#[embassy_executor::task(pool_size = 4)]`), the first spawn will allocate memory for all instances. This is done for performance and to increase predictability (for example, spawning at least 1 instance of every task at boot guarantees an immediate panic if the arena is too small, while allocating instances on-demand could delay the panic to only when the program is under load).
The arena size can be configured in two ways:
- Via Cargo features: enable a Cargo feature like `task-arena-size-8192`. Only a selection of values
is available, check `Cargo.toml` for the list.
- Via environment variables at build time: set the variable named `EMBASSY_EXECUTOR_TASK_ARENA_SIZE`. For example
`EMBASSY_EXECUTOR_TASK_ARENA_SIZE=4321 cargo build`. You can also set them in the `[env]` section of `.cargo/config.toml`.
Any value can be set, unlike with Cargo features.
Environment variables take precedence over Cargo features. If two Cargo features are enabled for the same setting
with different values, compilation fails.
## Statically allocating tasks
When using nightly Rust, enable the `nightly` Cargo feature. This will make `embassy-executor` use the `type_alias_impl_trait` feature to allocate all tasks in `static`s. Each task gets its own `static`, with the exact size to hold the task (or multiple instances of it, if using `pool_size`) calculated automatically at compile time. If tasks don't fit in RAM, this is detected at compile time by the linker. Runtime panics due to running out of memory are not possible.
The configured arena size is ignored, no arena is used at all.

View File

@ -1,6 +1,97 @@
use std::env;
use std::collections::HashMap;
use std::fmt::Write;
use std::path::PathBuf;
use std::{env, fs};
static CONFIGS: &[(&str, usize)] = &[
// BEGIN AUTOGENERATED CONFIG FEATURES
// Generated by gen_config.py. DO NOT EDIT.
("TASK_ARENA_SIZE", 4096),
// END AUTOGENERATED CONFIG FEATURES
];
struct ConfigState {
value: usize,
seen_feature: bool,
seen_env: bool,
}
fn main() {
let crate_name = env::var("CARGO_PKG_NAME")
.unwrap()
.to_ascii_uppercase()
.replace('-', "_");
// only rebuild if build.rs changed. Otherwise Cargo will rebuild if any
// other file changed.
println!("cargo:rerun-if-changed=build.rs");
// Rebuild if config envvar changed.
for (name, _) in CONFIGS {
println!("cargo:rerun-if-env-changed={crate_name}_{name}");
}
let mut configs = HashMap::new();
for (name, default) in CONFIGS {
configs.insert(
*name,
ConfigState {
value: *default,
seen_env: false,
seen_feature: false,
},
);
}
let prefix = format!("{crate_name}_");
for (var, value) in env::vars() {
if let Some(name) = var.strip_prefix(&prefix) {
let Some(cfg) = configs.get_mut(name) else {
panic!("Unknown env var {name}")
};
let Ok(value) = value.parse::<usize>() else {
panic!("Invalid value for env var {name}: {value}")
};
cfg.value = value;
cfg.seen_env = true;
}
if let Some(feature) = var.strip_prefix("CARGO_FEATURE_") {
if let Some(i) = feature.rfind('_') {
let name = &feature[..i];
let value = &feature[i + 1..];
if let Some(cfg) = configs.get_mut(name) {
let Ok(value) = value.parse::<usize>() else {
panic!("Invalid value for feature {name}: {value}")
};
// envvars take priority.
if !cfg.seen_env {
if cfg.seen_feature {
panic!("multiple values set for feature {}: {} and {}", name, cfg.value, value);
}
cfg.value = value;
cfg.seen_feature = true;
}
}
}
}
}
let mut data = String::new();
for (name, cfg) in &configs {
writeln!(&mut data, "pub const {}: usize = {};", name, cfg.value).unwrap();
}
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let out_file = out_dir.join("config.rs").to_string_lossy().to_string();
fs::write(out_file, data).unwrap();
// cortex-m targets
let target = env::var("TARGET").unwrap();
if target.starts_with("thumbv6m-") {

View File

@ -0,0 +1,82 @@
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
features = []
def feature(name, default, min=None, max=None, pow2=None, vals=None, factors=[]):
if vals is None:
assert min is not None
assert max is not None
vals = set()
val = min
while val <= max:
vals.add(val)
for f in factors:
if val * f <= max:
vals.add(val * f)
if (pow2 == True or (isinstance(pow2, int) and val >= pow2)) and val > 0:
val *= 2
else:
val += 1
vals.add(default)
vals = sorted(list(vals))
features.append(
{
"name": name,
"default": default,
"vals": vals,
}
)
feature(
"task_arena_size", default=4096, min=64, max=1024 * 1024, pow2=True, factors=[3, 5]
)
# ========= Update Cargo.toml
things = ""
for f in features:
name = f["name"].replace("_", "-")
for val in f["vals"]:
things += f"{name}-{val} = []"
if val == f["default"]:
things += " # Default"
things += "\n"
things += "\n"
SEPARATOR_START = "# BEGIN AUTOGENERATED CONFIG FEATURES\n"
SEPARATOR_END = "# END AUTOGENERATED CONFIG FEATURES\n"
HELP = "# Generated by gen_config.py. DO NOT EDIT.\n"
with open("Cargo.toml", "r") as f:
data = f.read()
before, data = data.split(SEPARATOR_START, maxsplit=1)
_, after = data.split(SEPARATOR_END, maxsplit=1)
data = before + SEPARATOR_START + HELP + things + SEPARATOR_END + after
with open("Cargo.toml", "w") as f:
f.write(data)
# ========= Update build.rs
things = ""
for f in features:
name = f["name"].upper()
things += f' ("{name}", {f["default"]}),\n'
SEPARATOR_START = "// BEGIN AUTOGENERATED CONFIG FEATURES\n"
SEPARATOR_END = "// END AUTOGENERATED CONFIG FEATURES\n"
HELP = " // Generated by gen_config.py. DO NOT EDIT.\n"
with open("build.rs", "r") as f:
data = f.read()
before, data = data.split(SEPARATOR_START, maxsplit=1)
_, after = data.split(SEPARATOR_END, maxsplit=1)
data = before + SEPARATOR_START + HELP + things + " " + SEPARATOR_END + after
with open("build.rs", "w") as f:
f.write(data)

View File

@ -51,7 +51,6 @@ mod thread {
use core::arch::asm;
use core::marker::PhantomData;
#[cfg(feature = "nightly")]
pub use embassy_macros::main_cortex_m as main;
use crate::{raw, Spawner};
@ -115,12 +114,12 @@ mod thread {
pub use interrupt::*;
#[cfg(feature = "executor-interrupt")]
mod interrupt {
use core::cell::UnsafeCell;
use core::cell::{Cell, UnsafeCell};
use core::mem::MaybeUninit;
use atomic_polyfill::{AtomicBool, Ordering};
use cortex_m::interrupt::InterruptNumber;
use cortex_m::peripheral::NVIC;
use critical_section::Mutex;
use crate::raw;
@ -146,7 +145,7 @@ mod interrupt {
/// It is somewhat more complex to use, it's recommended to use the thread-mode
/// [`Executor`] instead, if it works for your use case.
pub struct InterruptExecutor {
started: AtomicBool,
started: Mutex<Cell<bool>>,
executor: UnsafeCell<MaybeUninit<raw::Executor>>,
}
@ -158,7 +157,7 @@ mod interrupt {
#[inline]
pub const fn new() -> Self {
Self {
started: AtomicBool::new(false),
started: Mutex::new(Cell::new(false)),
executor: UnsafeCell::new(MaybeUninit::uninit()),
}
}
@ -167,7 +166,8 @@ mod interrupt {
///
/// # Safety
///
/// You MUST call this from the interrupt handler, and from nowhere else.
/// - You MUST call this from the interrupt handler, and from nowhere else.
/// - You must not call this before calling `start()`.
pub unsafe fn on_interrupt(&'static self) {
let executor = unsafe { (&*self.executor.get()).assume_init_ref() };
executor.poll();
@ -196,11 +196,7 @@ mod interrupt {
/// do it after.
///
pub fn start(&'static self, irq: impl InterruptNumber) -> crate::SendSpawner {
if self
.started
.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
.is_err()
{
if critical_section::with(|cs| self.started.borrow(cs).replace(true)) {
panic!("InterruptExecutor::start() called multiple times on the same executor.");
}
@ -222,10 +218,10 @@ mod interrupt {
/// This returns a [`SendSpawner`] you can use to spawn tasks on this
/// executor.
///
/// This MUST only be called on an executor that has already been spawned.
/// This MUST only be called on an executor that has already been started.
/// The function will panic otherwise.
pub fn spawner(&'static self) -> crate::SendSpawner {
if !self.started.load(Ordering::Acquire) {
if !critical_section::with(|cs| self.started.borrow(cs).get()) {
panic!("InterruptExecutor::spawner() called on uninitialized executor.");
}
let executor = unsafe { (&*self.executor.get()).assume_init_ref() };

View File

@ -6,10 +6,9 @@ pub use thread::*;
#[cfg(feature = "executor-thread")]
mod thread {
use core::marker::PhantomData;
use core::sync::atomic::{AtomicBool, Ordering};
#[cfg(feature = "nightly")]
pub use embassy_macros::main_riscv as main;
use portable_atomic::{AtomicBool, Ordering};
use crate::{raw, Spawner};

View File

@ -8,7 +8,6 @@ mod thread {
use std::marker::PhantomData;
use std::sync::{Condvar, Mutex};
#[cfg(feature = "nightly")]
pub use embassy_macros::main_std as main;
use crate::{raw, Spawner};

View File

@ -8,7 +8,6 @@ mod thread {
use core::marker::PhantomData;
#[cfg(feature = "nightly")]
pub use embassy_macros::main_wasm as main;
use js_sys::Promise;
use wasm_bindgen::prelude::*;
@ -73,9 +72,10 @@ mod thread {
pub fn start(&'static mut self, init: impl FnOnce(Spawner)) {
unsafe {
let executor = &self.inner;
self.ctx.closure.write(Closure::new(move |_| {
let future = Closure::new(move |_| {
executor.poll();
}));
});
self.ctx.closure.write_in_place(|| future);
init(self.inner.spawner());
}
}

View File

@ -1,87 +0,0 @@
#[cfg(feature = "executor-interrupt")]
compile_error!("`executor-interrupt` is not supported with `arch-xtensa`.");
#[cfg(feature = "executor-thread")]
pub use thread::*;
#[cfg(feature = "executor-thread")]
mod thread {
use core::marker::PhantomData;
use core::sync::atomic::{AtomicBool, Ordering};
use crate::{raw, Spawner};
/// global atomic used to keep track of whether there is work to do since sev() is not available on Xtensa
static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false);
#[export_name = "__pender"]
fn __pender(_context: *mut ()) {
SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst);
}
/// Xtensa Executor
pub struct Executor {
inner: raw::Executor,
not_send: PhantomData<*mut ()>,
}
impl Executor {
/// Create a new Executor.
pub fn new() -> Self {
Self {
inner: raw::Executor::new(core::ptr::null_mut()),
not_send: PhantomData,
}
}
/// Run the executor.
///
/// The `init` closure is called with a [`Spawner`] that spawns tasks on
/// this executor. Use it to spawn the initial task(s). After `init` returns,
/// the executor starts running the tasks.
///
/// To spawn more tasks later, you may keep copies of the [`Spawner`] (it is `Copy`),
/// for example by passing it as an argument to the initial tasks.
///
/// This function requires `&'static mut self`. This means you have to store the
/// Executor instance in a place where it'll live forever and grants you mutable
/// access. There's a few ways to do this:
///
/// - a [StaticCell](https://docs.rs/static_cell/latest/static_cell/) (safe)
/// - a `static mut` (unsafe)
/// - a local variable in a function you know never returns (like `fn main() -> !`), upgrading its lifetime with `transmute`. (unsafe)
///
/// This function never returns.
pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! {
init(self.inner.spawner());
loop {
unsafe {
self.inner.poll();
// Manual critical section implementation that only masks interrupts handlers.
// We must not acquire the cross-core on dual-core systems because that would
// prevent the other core from doing useful work while this core is sleeping.
let token: critical_section::RawRestoreState;
core::arch::asm!("rsil {0}, 5", out(reg) token);
// we do not care about race conditions between the load and store operations, interrupts
// will only set this value to true.
// if there is work to do, loop back to polling
if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) {
SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst);
core::arch::asm!(
"wsr.ps {0}",
"rsync", in(reg) token)
} else {
// waiti sets the PS.INTLEVEL when slipping into sleep
// because critical sections in Xtensa are implemented via increasing
// PS.INTLEVEL the critical section ends here
// take care not add code after `waiti` if it needs to be inside the CS
core::arch::asm!("waiti 0"); // critical section ends here
}
}
}
}
}
}

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -1,5 +1,4 @@
#![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)]
#![cfg_attr(all(feature = "nightly", feature = "arch-xtensa"), feature(asm_experimental_arch))]
#![allow(clippy::new_without_default)]
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
@ -7,7 +6,6 @@
// This mod MUST go first, so that the others see its macros.
pub(crate) mod fmt;
#[cfg(feature = "nightly")]
pub use embassy_macros::task;
macro_rules! check_at_most_one {
@ -22,17 +20,17 @@ macro_rules! check_at_most_one {
check_at_most_one!(@amo [$($f)*] [$($f)*] []);
};
}
check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-xtensa", "arch-std", "arch-wasm",);
check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-std", "arch-wasm",);
#[cfg(feature = "_arch")]
#[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")]
#[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")]
#[cfg_attr(feature = "arch-xtensa", path = "arch/xtensa.rs")]
#[cfg_attr(feature = "arch-std", path = "arch/std.rs")]
#[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")]
mod arch;
#[cfg(feature = "_arch")]
#[allow(unused_imports)] // don't warn if the module is empty.
pub use arch::*;
pub mod raw;
@ -40,29 +38,101 @@ pub mod raw;
mod spawner;
pub use spawner::*;
mod config {
#![allow(unused)]
include!(concat!(env!("OUT_DIR"), "/config.rs"));
}
/// Implementation details for embassy macros.
/// Do not use. Used for macros and HALs only. Not covered by semver guarantees.
#[doc(hidden)]
#[cfg(not(feature = "nightly"))]
pub mod _export {
#[cfg(feature = "rtos-trace")]
pub use rtos_trace::trace;
pub use static_cell::StaticCell;
use core::alloc::Layout;
use core::cell::{Cell, UnsafeCell};
use core::future::Future;
use core::mem::MaybeUninit;
use core::ptr::null_mut;
/// Expands the given block of code when `embassy-executor` is compiled with
/// the `rtos-trace-interrupt` feature.
#[doc(hidden)]
#[macro_export]
#[cfg(feature = "rtos-trace-interrupt")]
macro_rules! rtos_trace_interrupt {
($($tt:tt)*) => { $($tt)* };
use critical_section::{CriticalSection, Mutex};
use crate::raw::TaskPool;
struct Arena<const N: usize> {
buf: UnsafeCell<MaybeUninit<[u8; N]>>,
ptr: Mutex<Cell<*mut u8>>,
}
/// Does not expand the given block of code when `embassy-executor` is
/// compiled without the `rtos-trace-interrupt` feature.
#[doc(hidden)]
#[macro_export]
#[cfg(not(feature = "rtos-trace-interrupt"))]
macro_rules! rtos_trace_interrupt {
($($tt:tt)*) => {};
unsafe impl<const N: usize> Sync for Arena<N> {}
unsafe impl<const N: usize> Send for Arena<N> {}
impl<const N: usize> Arena<N> {
const fn new() -> Self {
Self {
buf: UnsafeCell::new(MaybeUninit::uninit()),
ptr: Mutex::new(Cell::new(null_mut())),
}
}
fn alloc<T>(&'static self, cs: CriticalSection) -> &'static mut MaybeUninit<T> {
let layout = Layout::new::<T>();
let start = self.buf.get().cast::<u8>();
let end = unsafe { start.add(N) };
let mut ptr = self.ptr.borrow(cs).get();
if ptr.is_null() {
ptr = self.buf.get().cast::<u8>();
}
let bytes_left = (end as usize) - (ptr as usize);
let align_offset = (ptr as usize).next_multiple_of(layout.align()) - (ptr as usize);
if align_offset + layout.size() > bytes_left {
panic!("embassy-executor: task arena is full. You must increase the arena size, see the documentation for details: https://docs.embassy.dev/embassy-executor/");
}
let res = unsafe { ptr.add(align_offset) };
let ptr = unsafe { ptr.add(align_offset + layout.size()) };
self.ptr.borrow(cs).set(ptr);
unsafe { &mut *(res as *mut MaybeUninit<T>) }
}
}
static ARENA: Arena<{ crate::config::TASK_ARENA_SIZE }> = Arena::new();
pub struct TaskPoolRef {
// type-erased `&'static mut TaskPool<F, N>`
// Needed because statics can't have generics.
ptr: Mutex<Cell<*mut ()>>,
}
unsafe impl Sync for TaskPoolRef {}
unsafe impl Send for TaskPoolRef {}
impl TaskPoolRef {
pub const fn new() -> Self {
Self {
ptr: Mutex::new(Cell::new(null_mut())),
}
}
/// Get the pool for this ref, allocating it from the arena the first time.
///
/// safety: for a given TaskPoolRef instance, must always call with the exact
/// same generic params.
pub unsafe fn get<F: Future, const N: usize>(&'static self) -> &'static TaskPool<F, N> {
critical_section::with(|cs| {
let ptr = self.ptr.borrow(cs);
if ptr.get().is_null() {
let pool = ARENA.alloc::<TaskPool<F, N>>(cs);
pool.write(TaskPool::new());
ptr.set(pool as *mut _ as _);
}
unsafe { &*(ptr.get() as *const _) }
})
}
}
}

View File

@ -7,7 +7,15 @@
//! Using this module requires respecting subtle safety contracts. If you can, prefer using the safe
//! [executor wrappers](crate::Executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe.
#[cfg_attr(target_has_atomic = "ptr", path = "run_queue_atomics.rs")]
#[cfg_attr(not(target_has_atomic = "ptr"), path = "run_queue_critical_section.rs")]
mod run_queue;
#[cfg_attr(all(cortex_m, target_has_atomic = "8"), path = "state_atomics_arm.rs")]
#[cfg_attr(all(not(cortex_m), target_has_atomic = "8"), path = "state_atomics.rs")]
#[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")]
mod state;
#[cfg(feature = "integrated-timers")]
mod timer_queue;
pub(crate) mod util;
@ -21,7 +29,6 @@ use core::pin::Pin;
use core::ptr::NonNull;
use core::task::{Context, Poll};
use atomic_polyfill::{AtomicU32, Ordering};
#[cfg(feature = "integrated-timers")]
use embassy_time::driver::{self, AlarmHandle};
#[cfg(feature = "integrated-timers")]
@ -30,21 +37,14 @@ use embassy_time::Instant;
use rtos_trace::trace;
use self::run_queue::{RunQueue, RunQueueItem};
use self::state::State;
use self::util::{SyncUnsafeCell, UninitCell};
pub use self::waker::task_from_waker;
use super::SpawnToken;
/// Task is spawned (has a future)
pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
/// Task is in the executor run queue
pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1;
/// Task is in the executor timer queue
#[cfg(feature = "integrated-timers")]
pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2;
/// Raw task header for use in task pointers.
pub(crate) struct TaskHeader {
pub(crate) state: AtomicU32,
pub(crate) state: State,
pub(crate) run_queue_item: RunQueueItem,
pub(crate) executor: SyncUnsafeCell<Option<&'static SyncExecutor>>,
poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>,
@ -116,7 +116,7 @@ impl<F: Future + 'static> TaskStorage<F> {
pub const fn new() -> Self {
Self {
raw: TaskHeader {
state: AtomicU32::new(0),
state: State::new(),
run_queue_item: RunQueueItem::new(),
executor: SyncUnsafeCell::new(None),
// Note: this is lazily initialized so that a static `TaskStorage` will go in `.bss`
@ -161,7 +161,7 @@ impl<F: Future + 'static> TaskStorage<F> {
match future.poll(&mut cx) {
Poll::Ready(_) => {
this.future.drop_in_place();
this.raw.state.fetch_and(!STATE_SPAWNED, Ordering::AcqRel);
this.raw.state.despawn();
#[cfg(feature = "integrated-timers")]
this.raw.expires_at.set(Instant::MAX);
@ -193,17 +193,13 @@ impl<F: Future + 'static> AvailableTask<F> {
///
/// This function returns `None` if a task has already been spawned and has not finished running.
pub fn claim(task: &'static TaskStorage<F>) -> Option<Self> {
task.raw
.state
.compare_exchange(0, STATE_SPAWNED | STATE_RUN_QUEUED, Ordering::AcqRel, Ordering::Acquire)
.ok()
.map(|_| Self { task })
task.raw.state.spawn().then(|| Self { task })
}
fn initialize_impl<S>(self, future: impl FnOnce() -> F) -> SpawnToken<S> {
unsafe {
self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll));
self.task.future.write(future());
self.task.future.write_in_place(future);
let task = TaskRef::new(self.task);
@ -394,8 +390,7 @@ impl SyncExecutor {
#[cfg(feature = "integrated-timers")]
task.expires_at.set(Instant::MAX);
let state = task.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel);
if state & STATE_SPAWNED == 0 {
if !task.state.run_dequeue() {
// If task is not running, ignore it. This can happen in the following scenario:
// - Task gets dequeued, poll starts
// - While task is being polled, it gets woken. It gets placed in the queue.
@ -546,18 +541,7 @@ impl Executor {
/// You can obtain a `TaskRef` from a `Waker` using [`task_from_waker`].
pub fn wake_task(task: TaskRef) {
let header = task.header();
let res = header.state.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |state| {
// If already scheduled, or if not started,
if (state & STATE_RUN_QUEUED != 0) || (state & STATE_SPAWNED == 0) {
None
} else {
// Mark it as scheduled
Some(state | STATE_RUN_QUEUED)
}
});
if res.is_ok() {
if header.state.run_enqueue() {
// We have just marked the task as scheduled, so enqueue it.
unsafe {
let executor = header.executor.get().unwrap_unchecked();
@ -571,18 +555,7 @@ pub fn wake_task(task: TaskRef) {
/// You can obtain a `TaskRef` from a `Waker` using [`task_from_waker`].
pub fn wake_task_no_pend(task: TaskRef) {
let header = task.header();
let res = header.state.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |state| {
// If already scheduled, or if not started,
if (state & STATE_RUN_QUEUED != 0) || (state & STATE_SPAWNED == 0) {
None
} else {
// Mark it as scheduled
Some(state | STATE_RUN_QUEUED)
}
});
if res.is_ok() {
if header.state.run_enqueue() {
// We have just marked the task as scheduled, so enqueue it.
unsafe {
let executor = header.executor.get().unwrap_unchecked();

View File

@ -1,7 +1,6 @@
use core::ptr;
use core::ptr::NonNull;
use atomic_polyfill::{AtomicPtr, Ordering};
use core::sync::atomic::{AtomicPtr, Ordering};
use super::{TaskHeader, TaskRef};
use crate::raw::util::SyncUnsafeCell;

View File

@ -0,0 +1,75 @@
use core::cell::Cell;
use critical_section::{CriticalSection, Mutex};
use super::TaskRef;
pub(crate) struct RunQueueItem {
next: Mutex<Cell<Option<TaskRef>>>,
}
impl RunQueueItem {
pub const fn new() -> Self {
Self {
next: Mutex::new(Cell::new(None)),
}
}
}
/// Atomic task queue using a very, very simple lock-free linked-list queue:
///
/// To enqueue a task, task.next is set to the old head, and head is atomically set to task.
///
/// Dequeuing is done in batches: the queue is emptied by atomically replacing head with
/// null. Then the batch is iterated following the next pointers until null is reached.
///
/// Note that batches will be iterated in the reverse order as they were enqueued. This is OK
/// for our purposes: it can't create fairness problems since the next batch won't run until the
/// current batch is completely processed, so even if a task enqueues itself instantly (for example
/// by waking its own waker) can't prevent other tasks from running.
pub(crate) struct RunQueue {
head: Mutex<Cell<Option<TaskRef>>>,
}
impl RunQueue {
pub const fn new() -> Self {
Self {
head: Mutex::new(Cell::new(None)),
}
}
/// Enqueues an item. Returns true if the queue was empty.
///
/// # Safety
///
/// `item` must NOT be already enqueued in any queue.
#[inline(always)]
pub(crate) unsafe fn enqueue(&self, task: TaskRef) -> bool {
critical_section::with(|cs| {
let prev = self.head.borrow(cs).replace(Some(task));
task.header().run_queue_item.next.borrow(cs).set(prev);
prev.is_none()
})
}
/// Empty the queue, then call `on_task` for each task that was in the queue.
/// NOTE: It is OK for `on_task` to enqueue more tasks. In this case they're left in the queue
/// and will be processed by the *next* call to `dequeue_all`, *not* the current one.
pub(crate) fn dequeue_all(&self, on_task: impl Fn(TaskRef)) {
// Atomically empty the queue.
let mut next = critical_section::with(|cs| self.head.borrow(cs).take());
// Iterate the linked list of tasks that were previously in the queue.
while let Some(task) = next {
// If the task re-enqueues itself, the `next` pointer will get overwritten.
// Therefore, first read the next pointer, and only then process the task.
// safety: we know if the task is enqueued, no one else will touch the `next` pointer.
let cs = unsafe { CriticalSection::new() };
next = task.header().run_queue_item.next.borrow(cs).get();
on_task(task);
}
}
}

View File

@ -0,0 +1,73 @@
use core::sync::atomic::{AtomicU32, Ordering};
/// Task is spawned (has a future)
pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
/// Task is in the executor run queue
pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1;
/// Task is in the executor timer queue
#[cfg(feature = "integrated-timers")]
pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2;
pub(crate) struct State {
state: AtomicU32,
}
impl State {
pub const fn new() -> State {
Self {
state: AtomicU32::new(0),
}
}
/// If task is idle, mark it as spawned + run_queued and return true.
#[inline(always)]
pub fn spawn(&self) -> bool {
self.state
.compare_exchange(0, STATE_SPAWNED | STATE_RUN_QUEUED, Ordering::AcqRel, Ordering::Acquire)
.is_ok()
}
/// Unmark the task as spawned.
#[inline(always)]
pub fn despawn(&self) {
self.state.fetch_and(!STATE_SPAWNED, Ordering::AcqRel);
}
/// Mark the task as run-queued if it's spawned and isn't already run-queued. Return true on success.
#[inline(always)]
pub fn run_enqueue(&self) -> bool {
self.state
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |state| {
// If already scheduled, or if not started,
if (state & STATE_RUN_QUEUED != 0) || (state & STATE_SPAWNED == 0) {
None
} else {
// Mark it as scheduled
Some(state | STATE_RUN_QUEUED)
}
})
.is_ok()
}
/// Unmark the task as run-queued. Return whether the task is spawned.
#[inline(always)]
pub fn run_dequeue(&self) -> bool {
let state = self.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel);
state & STATE_SPAWNED != 0
}
/// Mark the task as timer-queued. Return whether it was newly queued (i.e. not queued before)
#[cfg(feature = "integrated-timers")]
#[inline(always)]
pub fn timer_enqueue(&self) -> bool {
let old_state = self.state.fetch_or(STATE_TIMER_QUEUED, Ordering::AcqRel);
old_state & STATE_TIMER_QUEUED == 0
}
/// Unmark the task as timer-queued.
#[cfg(feature = "integrated-timers")]
#[inline(always)]
pub fn timer_dequeue(&self) {
self.state.fetch_and(!STATE_TIMER_QUEUED, Ordering::AcqRel);
}
}

View File

@ -0,0 +1,103 @@
use core::arch::asm;
use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering};
// Must be kept in sync with the layout of `State`!
pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 8;
#[repr(C, align(4))]
pub(crate) struct State {
/// Task is spawned (has a future)
spawned: AtomicBool,
/// Task is in the executor run queue
run_queued: AtomicBool,
/// Task is in the executor timer queue
timer_queued: AtomicBool,
pad: AtomicBool,
}
impl State {
pub const fn new() -> State {
Self {
spawned: AtomicBool::new(false),
run_queued: AtomicBool::new(false),
timer_queued: AtomicBool::new(false),
pad: AtomicBool::new(false),
}
}
fn as_u32(&self) -> &AtomicU32 {
unsafe { &*(self as *const _ as *const AtomicU32) }
}
/// If task is idle, mark it as spawned + run_queued and return true.
#[inline(always)]
pub fn spawn(&self) -> bool {
compiler_fence(Ordering::Release);
let r = self
.as_u32()
.compare_exchange(
0,
STATE_SPAWNED | STATE_RUN_QUEUED,
Ordering::Relaxed,
Ordering::Relaxed,
)
.is_ok();
compiler_fence(Ordering::Acquire);
r
}
/// Unmark the task as spawned.
#[inline(always)]
pub fn despawn(&self) {
compiler_fence(Ordering::Release);
self.spawned.store(false, Ordering::Relaxed);
}
/// Mark the task as run-queued if it's spawned and isn't already run-queued. Return true on success.
#[inline(always)]
pub fn run_enqueue(&self) -> bool {
unsafe {
loop {
let state: u32;
asm!("ldrex {}, [{}]", out(reg) state, in(reg) self, options(nostack));
if (state & STATE_RUN_QUEUED != 0) || (state & STATE_SPAWNED == 0) {
asm!("clrex", options(nomem, nostack));
return false;
}
let outcome: usize;
let new_state = state | STATE_RUN_QUEUED;
asm!("strex {}, {}, [{}]", out(reg) outcome, in(reg) new_state, in(reg) self, options(nostack));
if outcome == 0 {
return true;
}
}
}
}
/// Unmark the task as run-queued. Return whether the task is spawned.
#[inline(always)]
pub fn run_dequeue(&self) -> bool {
compiler_fence(Ordering::Release);
let r = self.spawned.load(Ordering::Relaxed);
self.run_queued.store(false, Ordering::Relaxed);
r
}
/// Mark the task as timer-queued. Return whether it was newly queued (i.e. not queued before)
#[cfg(feature = "integrated-timers")]
#[inline(always)]
pub fn timer_enqueue(&self) -> bool {
!self.timer_queued.swap(true, Ordering::Relaxed)
}
/// Unmark the task as timer-queued.
#[cfg(feature = "integrated-timers")]
#[inline(always)]
pub fn timer_dequeue(&self) {
self.timer_queued.store(false, Ordering::Relaxed);
}
}

View File

@ -0,0 +1,93 @@
use core::cell::Cell;
use critical_section::Mutex;
/// Task is spawned (has a future)
pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
/// Task is in the executor run queue
pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1;
/// Task is in the executor timer queue
#[cfg(feature = "integrated-timers")]
pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2;
pub(crate) struct State {
state: Mutex<Cell<u32>>,
}
impl State {
pub const fn new() -> State {
Self {
state: Mutex::new(Cell::new(0)),
}
}
fn update<R>(&self, f: impl FnOnce(&mut u32) -> R) -> R {
critical_section::with(|cs| {
let s = self.state.borrow(cs);
let mut val = s.get();
let r = f(&mut val);
s.set(val);
r
})
}
/// If task is idle, mark it as spawned + run_queued and return true.
#[inline(always)]
pub fn spawn(&self) -> bool {
self.update(|s| {
if *s == 0 {
*s = STATE_SPAWNED | STATE_RUN_QUEUED;
true
} else {
false
}
})
}
/// Unmark the task as spawned.
#[inline(always)]
pub fn despawn(&self) {
self.update(|s| *s &= !STATE_SPAWNED);
}
/// Mark the task as run-queued if it's spawned and isn't already run-queued. Return true on success.
#[inline(always)]
pub fn run_enqueue(&self) -> bool {
self.update(|s| {
if (*s & STATE_RUN_QUEUED != 0) || (*s & STATE_SPAWNED == 0) {
false
} else {
*s |= STATE_RUN_QUEUED;
true
}
})
}
/// Unmark the task as run-queued. Return whether the task is spawned.
#[inline(always)]
pub fn run_dequeue(&self) -> bool {
self.update(|s| {
let ok = *s & STATE_SPAWNED != 0;
*s &= !STATE_RUN_QUEUED;
ok
})
}
/// Mark the task as timer-queued. Return whether it was newly queued (i.e. not queued before)
#[cfg(feature = "integrated-timers")]
#[inline(always)]
pub fn timer_enqueue(&self) -> bool {
self.update(|s| {
let ok = *s & STATE_TIMER_QUEUED == 0;
*s |= STATE_TIMER_QUEUED;
ok
})
}
/// Unmark the task as timer-queued.
#[cfg(feature = "integrated-timers")]
#[inline(always)]
pub fn timer_dequeue(&self) {
self.update(|s| *s &= !STATE_TIMER_QUEUED);
}
}

View File

@ -1,9 +1,8 @@
use core::cmp::min;
use atomic_polyfill::Ordering;
use embassy_time::Instant;
use super::{TaskRef, STATE_TIMER_QUEUED};
use super::TaskRef;
use crate::raw::util::SyncUnsafeCell;
pub(crate) struct TimerQueueItem {
@ -32,10 +31,7 @@ impl TimerQueue {
pub(crate) unsafe fn update(&self, p: TaskRef) {
let task = p.header();
if task.expires_at.get() != Instant::MAX {
let old_state = task.state.fetch_or(STATE_TIMER_QUEUED, Ordering::AcqRel);
let is_new = old_state & STATE_TIMER_QUEUED == 0;
if is_new {
if task.state.timer_enqueue() {
task.timer_queue_item.next.set(self.head.get());
self.head.set(Some(p));
}
@ -75,7 +71,7 @@ impl TimerQueue {
} else {
// Remove it
prev.set(task.timer_queue_item.next.get());
task.state.fetch_and(!STATE_TIMER_QUEUED, Ordering::AcqRel);
task.state.timer_dequeue();
}
}
}

View File

@ -17,8 +17,9 @@ impl<T> UninitCell<T> {
&mut *self.as_mut_ptr()
}
pub unsafe fn write(&self, val: T) {
ptr::write(self.as_mut_ptr(), val)
#[inline(never)]
pub unsafe fn write_in_place(&self, func: impl FnOnce() -> T) {
ptr::write(self.as_mut_ptr(), func())
}
pub unsafe fn drop_in_place(&self) {

View File

@ -3,7 +3,7 @@ use core::task::{RawWaker, RawWakerVTable, Waker};
use super::{wake_task, TaskHeader, TaskRef};
const VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop);
static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop);
unsafe fn clone(p: *const ()) -> RawWaker {
RawWaker::new(p, &VTABLE)

View File

@ -0,0 +1,137 @@
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
use std::boxed::Box;
use std::future::poll_fn;
use std::sync::{Arc, Mutex};
use std::task::Poll;
use embassy_executor::raw::Executor;
use embassy_executor::task;
#[export_name = "__pender"]
fn __pender(context: *mut ()) {
unsafe {
let trace = &*(context as *const Trace);
trace.push("pend");
}
}
#[derive(Clone)]
struct Trace {
trace: Arc<Mutex<Vec<&'static str>>>,
}
impl Trace {
fn new() -> Self {
Self {
trace: Arc::new(Mutex::new(Vec::new())),
}
}
fn push(&self, value: &'static str) {
self.trace.lock().unwrap().push(value)
}
fn get(&self) -> Vec<&'static str> {
self.trace.lock().unwrap().clone()
}
}
fn setup() -> (&'static Executor, Trace) {
let trace = Trace::new();
let context = Box::leak(Box::new(trace.clone())) as *mut _ as *mut ();
let executor = &*Box::leak(Box::new(Executor::new(context)));
(executor, trace)
}
#[test]
fn executor_noop() {
let (executor, trace) = setup();
unsafe { executor.poll() };
assert!(trace.get().is_empty())
}
#[test]
fn executor_task() {
#[task]
async fn task1(trace: Trace) {
trace.push("poll task1")
}
let (executor, trace) = setup();
executor.spawner().spawn(task1(trace.clone())).unwrap();
unsafe { executor.poll() };
unsafe { executor.poll() };
assert_eq!(
trace.get(),
&[
"pend", // spawning a task pends the executor
"poll task1", // poll only once.
]
)
}
#[test]
fn executor_task_self_wake() {
#[task]
async fn task1(trace: Trace) {
poll_fn(|cx| {
trace.push("poll task1");
cx.waker().wake_by_ref();
Poll::Pending
})
.await
}
let (executor, trace) = setup();
executor.spawner().spawn(task1(trace.clone())).unwrap();
unsafe { executor.poll() };
unsafe { executor.poll() };
assert_eq!(
trace.get(),
&[
"pend", // spawning a task pends the executor
"poll task1", //
"pend", // task self-wakes
"poll task1", //
"pend", // task self-wakes
]
)
}
#[test]
fn executor_task_self_wake_twice() {
#[task]
async fn task1(trace: Trace) {
poll_fn(|cx| {
trace.push("poll task1");
cx.waker().wake_by_ref();
trace.push("poll task1 wake 2");
cx.waker().wake_by_ref();
Poll::Pending
})
.await
}
let (executor, trace) = setup();
executor.spawner().spawn(task1(trace.clone())).unwrap();
unsafe { executor.poll() };
unsafe { executor.poll() };
assert_eq!(
trace.get(),
&[
"pend", // spawning a task pends the executor
"poll task1", //
"pend", // task self-wakes
"poll task1 wake 2", // task self-wakes again, shouldn't pend
"poll task1", //
"pend", // task self-wakes
"poll task1 wake 2", // task self-wakes again, shouldn't pend
]
)
}

View File

@ -1,6 +1,6 @@
[package]
name = "embassy-futures"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
description = "no-std, no-alloc utilities for working with futures"
repository = "https://github.com/embassy-rs/embassy"

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -1,4 +1,4 @@
# embassy-macros
# embassy-hal-internal
An [Embassy](https://embassy.dev) project.

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -81,14 +83,17 @@ macro_rules! todo {
};
}
#[cfg(not(feature = "defmt"))]
macro_rules! unreachable {
($($x:tt)*) => {
{
#[cfg(not(feature = "defmt"))]
::core::unreachable!($($x)*);
#[cfg(feature = "defmt")]
::defmt::unreachable!($($x)*);
}
::core::unreachable!($($x)*)
};
}
#[cfg(feature = "defmt")]
macro_rules! unreachable {
($($x:tt)*) => {
::defmt::unreachable!($($x)*)
};
}
@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> {
self
}
}
#[allow(unused)]
pub(crate) struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

View File

@ -4,6 +4,7 @@ use core::sync::atomic::{compiler_fence, Ordering};
use cortex_m::interrupt::InterruptNumber;
use cortex_m::peripheral::NVIC;
use critical_section::CriticalSection;
/// Generate a standard `mod interrupt` for a HAL.
#[macro_export]
@ -91,6 +92,12 @@ macro_rules! interrupt_mod {
fn set_priority(prio: crate::interrupt::Priority) {
Self::IRQ.set_priority(prio)
}
/// Set the interrupt priority with an already-acquired critical section
#[inline]
fn set_priority_with_cs(cs: critical_section::CriticalSection, prio: crate::interrupt::Priority) {
Self::IRQ.set_priority_with_cs(cs, prio)
}
}
$(
@ -195,10 +202,29 @@ pub unsafe trait InterruptExt: InterruptNumber + Copy {
/// Set the interrupt priority.
#[inline]
fn set_priority(self, prio: Priority) {
critical_section::with(|_| unsafe {
unsafe {
let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(());
nvic.set_priority(self, prio.into())
})
// On thumbv6, set_priority must do a RMW to change 8bit in a 32bit reg.
#[cfg(armv6m)]
critical_section::with(|_| nvic.set_priority(self, prio.into()));
// On thumbv7+, set_priority does an atomic 8bit write, so no CS needed.
#[cfg(not(armv6m))]
nvic.set_priority(self, prio.into());
}
}
/// Set the interrupt priority with an already-acquired critical section
///
/// Equivalent to `set_priority`, except you pass a `CriticalSection` to prove
/// you've already acquired a critical section. This prevents acquiring another
/// one, which saves code size.
#[inline]
fn set_priority_with_cs(self, _cs: CriticalSection, prio: Priority) {
unsafe {
let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(());
nvic.set_priority(self, prio.into());
}
}
}

View File

@ -10,7 +10,6 @@ pub mod drop;
mod macros;
mod peripheral;
pub mod ratio;
pub mod ring_buffer;
pub use peripheral::{Peripheral, PeripheralRef};
#[cfg(feature = "cortex-m")]

View File

@ -48,17 +48,23 @@ macro_rules! peripherals_struct {
///Returns all the peripherals *once*
#[inline]
pub(crate) fn take() -> Self {
critical_section::with(Self::take_with_cs)
}
///Returns all the peripherals *once*
#[inline]
pub(crate) fn take_with_cs(_cs: critical_section::CriticalSection) -> Self {
#[no_mangle]
static mut _EMBASSY_DEVICE_PERIPHERALS: bool = false;
critical_section::with(|_| unsafe {
// safety: OK because we're inside a CS.
unsafe {
if _EMBASSY_DEVICE_PERIPHERALS {
panic!("init called more than once!")
}
_EMBASSY_DEVICE_PERIPHERALS = true;
Self::steal()
})
}
}
}

View File

@ -1,136 +0,0 @@
pub struct RingBuffer<'a> {
buf: &'a mut [u8],
start: usize,
end: usize,
empty: bool,
}
impl<'a> RingBuffer<'a> {
pub fn new(buf: &'a mut [u8]) -> Self {
Self {
buf,
start: 0,
end: 0,
empty: true,
}
}
pub fn push_buf(&mut self) -> &mut [u8] {
if self.start == self.end && !self.empty {
trace!(" ringbuf: push_buf empty");
return &mut self.buf[..0];
}
let n = if self.start <= self.end {
self.buf.len() - self.end
} else {
self.start - self.end
};
trace!(" ringbuf: push_buf {:?}..{:?}", self.end, self.end + n);
&mut self.buf[self.end..self.end + n]
}
pub fn push(&mut self, n: usize) {
trace!(" ringbuf: push {:?}", n);
if n == 0 {
return;
}
self.end = self.wrap(self.end + n);
self.empty = false;
}
pub fn pop_buf(&mut self) -> &mut [u8] {
if self.empty {
trace!(" ringbuf: pop_buf empty");
return &mut self.buf[..0];
}
let n = if self.end <= self.start {
self.buf.len() - self.start
} else {
self.end - self.start
};
trace!(" ringbuf: pop_buf {:?}..{:?}", self.start, self.start + n);
&mut self.buf[self.start..self.start + n]
}
pub fn pop(&mut self, n: usize) {
trace!(" ringbuf: pop {:?}", n);
if n == 0 {
return;
}
self.start = self.wrap(self.start + n);
self.empty = self.start == self.end;
}
pub fn is_full(&self) -> bool {
self.start == self.end && !self.empty
}
pub fn is_empty(&self) -> bool {
self.empty
}
pub fn clear(&mut self) {
self.start = 0;
self.end = 0;
self.empty = true;
}
fn wrap(&self, n: usize) -> usize {
assert!(n <= self.buf.len());
if n == self.buf.len() {
0
} else {
n
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn push_pop() {
let mut b = [0; 4];
let mut rb = RingBuffer::new(&mut b);
let buf = rb.push_buf();
assert_eq!(4, buf.len());
buf[0] = 1;
buf[1] = 2;
buf[2] = 3;
buf[3] = 4;
rb.push(4);
let buf = rb.pop_buf();
assert_eq!(4, buf.len());
assert_eq!(1, buf[0]);
rb.pop(1);
let buf = rb.pop_buf();
assert_eq!(3, buf.len());
assert_eq!(2, buf[0]);
rb.pop(1);
let buf = rb.pop_buf();
assert_eq!(2, buf.len());
assert_eq!(3, buf[0]);
rb.pop(1);
let buf = rb.pop_buf();
assert_eq!(1, buf.len());
assert_eq!(4, buf[0]);
rb.pop(1);
let buf = rb.pop_buf();
assert_eq!(0, buf.len());
let buf = rb.push_buf();
assert_eq!(4, buf.len());
}
}

View File

@ -1,34 +0,0 @@
[package]
name = "embassy-lora"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
[package.metadata.embassy_docs]
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/embassy-lora/src/"
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/"
features = ["stm32wl", "embassy-stm32?/stm32wl55jc-cm4", "embassy-stm32?/unstable-pac", "time", "defmt"]
target = "thumbv7em-none-eabi"
[features]
stm32wl = ["dep:embassy-stm32"]
time = ["embassy-time", "lorawan-device"]
defmt = ["dep:defmt", "lorawan-device/defmt"]
[dependencies]
defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }
embassy-time = { version = "0.1.3", path = "../embassy-time", optional = true }
embassy-sync = { version = "0.2.0", path = "../embassy-sync" }
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true }
embedded-hal-async = { version = "=1.0.0-rc.1" }
embedded-hal = { version = "0.2", features = ["unproven"] }
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
lora-phy = { version = "1" }
lorawan-device = { version = "0.10.0", default-features = false, features = ["async"], optional = true }
[patch.crates-io]
lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"}

View File

@ -1,325 +0,0 @@
#[cfg(feature = "stm32wl")]
use embassy_stm32::interrupt;
#[cfg(feature = "stm32wl")]
use embassy_stm32::interrupt::InterruptExt;
#[cfg(feature = "stm32wl")]
use embassy_stm32::pac;
#[cfg(feature = "stm32wl")]
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
#[cfg(feature = "stm32wl")]
use embassy_sync::signal::Signal;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal_async::delay::DelayUs;
use embedded_hal_async::digital::Wait;
use lora_phy::mod_params::RadioError::*;
use lora_phy::mod_params::{BoardType, RadioError};
use lora_phy::mod_traits::InterfaceVariant;
/// Interrupt handler.
#[cfg(feature = "stm32wl")]
pub struct InterruptHandler {}
#[cfg(feature = "stm32wl")]
impl interrupt::typelevel::Handler<interrupt::typelevel::SUBGHZ_RADIO> for InterruptHandler {
unsafe fn on_interrupt() {
interrupt::SUBGHZ_RADIO.disable();
IRQ_SIGNAL.signal(());
}
}
#[cfg(feature = "stm32wl")]
static IRQ_SIGNAL: Signal<CriticalSectionRawMutex, ()> = Signal::new();
#[cfg(feature = "stm32wl")]
/// Base for the InterfaceVariant implementation for an stm32wl/sx1262 combination
pub struct Stm32wlInterfaceVariant<CTRL> {
board_type: BoardType,
rf_switch_rx: Option<CTRL>,
rf_switch_tx: Option<CTRL>,
}
#[cfg(feature = "stm32wl")]
impl<'a, CTRL> Stm32wlInterfaceVariant<CTRL>
where
CTRL: OutputPin,
{
/// Create an InterfaceVariant instance for an stm32wl/sx1262 combination
pub fn new(
_irq: impl interrupt::typelevel::Binding<interrupt::typelevel::SUBGHZ_RADIO, InterruptHandler>,
rf_switch_rx: Option<CTRL>,
rf_switch_tx: Option<CTRL>,
) -> Result<Self, RadioError> {
interrupt::SUBGHZ_RADIO.disable();
Ok(Self {
board_type: BoardType::Stm32wlSx1262, // updated when associated with a specific LoRa board
rf_switch_rx,
rf_switch_tx,
})
}
}
#[cfg(feature = "stm32wl")]
impl<CTRL> InterfaceVariant for Stm32wlInterfaceVariant<CTRL>
where
CTRL: OutputPin,
{
fn set_board_type(&mut self, board_type: BoardType) {
self.board_type = board_type;
}
async fn set_nss_low(&mut self) -> Result<(), RadioError> {
let pwr = pac::PWR;
pwr.subghzspicr().modify(|w| w.set_nss(pac::pwr::vals::Nss::LOW));
Ok(())
}
async fn set_nss_high(&mut self) -> Result<(), RadioError> {
let pwr = pac::PWR;
pwr.subghzspicr().modify(|w| w.set_nss(pac::pwr::vals::Nss::HIGH));
Ok(())
}
async fn reset(&mut self, _delay: &mut impl DelayUs) -> Result<(), RadioError> {
let rcc = pac::RCC;
rcc.csr().modify(|w| w.set_rfrst(true));
rcc.csr().modify(|w| w.set_rfrst(false));
Ok(())
}
async fn wait_on_busy(&mut self) -> Result<(), RadioError> {
let pwr = pac::PWR;
while pwr.sr2().read().rfbusys() == pac::pwr::vals::Rfbusys::BUSY {}
Ok(())
}
async fn await_irq(&mut self) -> Result<(), RadioError> {
unsafe { interrupt::SUBGHZ_RADIO.enable() };
IRQ_SIGNAL.wait().await;
Ok(())
}
async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_tx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchTx)?,
None => (),
};
match &mut self.rf_switch_rx {
Some(pin) => pin.set_high().map_err(|_| RfSwitchRx),
None => Ok(()),
}
}
async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_rx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?,
None => (),
};
match &mut self.rf_switch_tx {
Some(pin) => pin.set_high().map_err(|_| RfSwitchTx),
None => Ok(()),
}
}
async fn disable_rf_switch(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_rx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?,
None => (),
};
match &mut self.rf_switch_tx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchTx),
None => Ok(()),
}
}
}
/// Base for the InterfaceVariant implementation for an stm32l0/sx1276 combination
pub struct Stm32l0InterfaceVariant<CTRL, WAIT> {
board_type: BoardType,
nss: CTRL,
reset: CTRL,
irq: WAIT,
rf_switch_rx: Option<CTRL>,
rf_switch_tx: Option<CTRL>,
}
impl<CTRL, WAIT> Stm32l0InterfaceVariant<CTRL, WAIT>
where
CTRL: OutputPin,
WAIT: Wait,
{
/// Create an InterfaceVariant instance for an stm32l0/sx1276 combination
pub fn new(
nss: CTRL,
reset: CTRL,
irq: WAIT,
rf_switch_rx: Option<CTRL>,
rf_switch_tx: Option<CTRL>,
) -> Result<Self, RadioError> {
Ok(Self {
board_type: BoardType::Stm32l0Sx1276, // updated when associated with a specific LoRa board
nss,
reset,
irq,
rf_switch_rx,
rf_switch_tx,
})
}
}
impl<CTRL, WAIT> InterfaceVariant for Stm32l0InterfaceVariant<CTRL, WAIT>
where
CTRL: OutputPin,
WAIT: Wait,
{
fn set_board_type(&mut self, board_type: BoardType) {
self.board_type = board_type;
}
async fn set_nss_low(&mut self) -> Result<(), RadioError> {
self.nss.set_low().map_err(|_| NSS)
}
async fn set_nss_high(&mut self) -> Result<(), RadioError> {
self.nss.set_high().map_err(|_| NSS)
}
async fn reset(&mut self, delay: &mut impl DelayUs) -> Result<(), RadioError> {
delay.delay_ms(10).await;
self.reset.set_low().map_err(|_| Reset)?;
delay.delay_ms(10).await;
self.reset.set_high().map_err(|_| Reset)?;
delay.delay_ms(10).await;
Ok(())
}
async fn wait_on_busy(&mut self) -> Result<(), RadioError> {
Ok(())
}
async fn await_irq(&mut self) -> Result<(), RadioError> {
self.irq.wait_for_high().await.map_err(|_| Irq)
}
async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_tx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchTx)?,
None => (),
};
match &mut self.rf_switch_rx {
Some(pin) => pin.set_high().map_err(|_| RfSwitchRx),
None => Ok(()),
}
}
async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_rx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?,
None => (),
};
match &mut self.rf_switch_tx {
Some(pin) => pin.set_high().map_err(|_| RfSwitchTx),
None => Ok(()),
}
}
async fn disable_rf_switch(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_rx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?,
None => (),
};
match &mut self.rf_switch_tx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchTx),
None => Ok(()),
}
}
}
/// Base for the InterfaceVariant implementation for a generic Sx126x LoRa board
pub struct GenericSx126xInterfaceVariant<CTRL, WAIT> {
board_type: BoardType,
nss: CTRL,
reset: CTRL,
dio1: WAIT,
busy: WAIT,
rf_switch_rx: Option<CTRL>,
rf_switch_tx: Option<CTRL>,
}
impl<CTRL, WAIT> GenericSx126xInterfaceVariant<CTRL, WAIT>
where
CTRL: OutputPin,
WAIT: Wait,
{
/// Create an InterfaceVariant instance for an nrf52840/sx1262 combination
pub fn new(
nss: CTRL,
reset: CTRL,
dio1: WAIT,
busy: WAIT,
rf_switch_rx: Option<CTRL>,
rf_switch_tx: Option<CTRL>,
) -> Result<Self, RadioError> {
Ok(Self {
board_type: BoardType::Rak4631Sx1262, // updated when associated with a specific LoRa board
nss,
reset,
dio1,
busy,
rf_switch_rx,
rf_switch_tx,
})
}
}
impl<CTRL, WAIT> InterfaceVariant for GenericSx126xInterfaceVariant<CTRL, WAIT>
where
CTRL: OutputPin,
WAIT: Wait,
{
fn set_board_type(&mut self, board_type: BoardType) {
self.board_type = board_type;
}
async fn set_nss_low(&mut self) -> Result<(), RadioError> {
self.nss.set_low().map_err(|_| NSS)
}
async fn set_nss_high(&mut self) -> Result<(), RadioError> {
self.nss.set_high().map_err(|_| NSS)
}
async fn reset(&mut self, delay: &mut impl DelayUs) -> Result<(), RadioError> {
delay.delay_ms(10).await;
self.reset.set_low().map_err(|_| Reset)?;
delay.delay_ms(20).await;
self.reset.set_high().map_err(|_| Reset)?;
delay.delay_ms(10).await;
Ok(())
}
async fn wait_on_busy(&mut self) -> Result<(), RadioError> {
self.busy.wait_for_low().await.map_err(|_| Busy)
}
async fn await_irq(&mut self) -> Result<(), RadioError> {
if self.board_type != BoardType::RpPicoWaveshareSx1262 {
self.dio1.wait_for_high().await.map_err(|_| DIO1)?;
} else {
self.dio1.wait_for_rising_edge().await.map_err(|_| DIO1)?;
}
Ok(())
}
async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_tx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchTx)?,
None => (),
};
match &mut self.rf_switch_rx {
Some(pin) => pin.set_high().map_err(|_| RfSwitchRx),
None => Ok(()),
}
}
async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_rx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?,
None => (),
};
match &mut self.rf_switch_tx {
Some(pin) => pin.set_high().map_err(|_| RfSwitchTx),
None => Ok(()),
}
}
async fn disable_rf_switch(&mut self) -> Result<(), RadioError> {
match &mut self.rf_switch_rx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?,
None => (),
};
match &mut self.rf_switch_tx {
Some(pin) => pin.set_low().map_err(|_| RfSwitchTx),
None => Ok(()),
}
}
}

View File

@ -1,39 +0,0 @@
#![no_std]
#![feature(async_fn_in_trait, impl_trait_projections)]
//! embassy-lora holds LoRa-specific functionality.
pub(crate) mod fmt;
/// interface variants required by the external lora physical layer crate (lora-phy)
pub mod iv;
#[cfg(feature = "time")]
use embassy_time::{Duration, Instant, Timer};
/// A convenience timer to use with the LoRaWAN crate
#[cfg(feature = "time")]
pub struct LoraTimer {
start: Instant,
}
#[cfg(feature = "time")]
impl LoraTimer {
pub fn new() -> Self {
Self { start: Instant::now() }
}
}
#[cfg(feature = "time")]
impl lorawan_device::async_device::radio::Timer for LoraTimer {
fn reset(&mut self) {
self.start = Instant::now();
}
async fn at(&mut self, millis: u64) {
Timer::at(self.start + Duration::from_millis(millis)).await
}
async fn delay_ms(&mut self, millis: u64) {
Timer::after(Duration::from_millis(millis)).await
}
}

View File

@ -21,5 +21,4 @@ proc-macro2 = "1.0.29"
proc-macro = true
[features]
# Enabling this cause interrupt::take! to require embassy-executor
rtos-trace-interrupt = []
nightly = []

View File

@ -53,8 +53,7 @@ pub fn wasm() -> TokenStream {
quote! {
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn main() -> Result<(), wasm_bindgen::JsValue> {
static EXECUTOR: ::embassy_executor::_export::StaticCell<::embassy_executor::Executor> = ::embassy_executor::_export::StaticCell::new();
let executor = EXECUTOR.init(::embassy_executor::Executor::new());
let executor = ::std::boxed::Box::leak(::std::boxed::Box::new(::embassy_executor::Executor::new()));
executor.start(|spawner| {
spawner.spawn(__embassy_main(spawner)).unwrap();

View File

@ -79,6 +79,7 @@ pub fn run(args: &[NestedMeta], f: syn::ItemFn) -> Result<TokenStream, TokenStre
task_inner.vis = syn::Visibility::Inherited;
task_inner.sig.ident = task_inner_ident.clone();
#[cfg(feature = "nightly")]
let mut task_outer: ItemFn = parse_quote! {
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
type Fut = impl ::core::future::Future + 'static;
@ -87,6 +88,14 @@ pub fn run(args: &[NestedMeta], f: syn::ItemFn) -> Result<TokenStream, TokenStre
unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) }
}
};
#[cfg(not(feature = "nightly"))]
let mut task_outer: ItemFn = parse_quote! {
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
const POOL_SIZE: usize = #pool_size;
static POOL: ::embassy_executor::_export::TaskPoolRef = ::embassy_executor::_export::TaskPoolRef::new();
unsafe { POOL.get::<_, POOL_SIZE>()._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) }
}
};
task_outer.attrs.append(&mut task_inner.attrs.clone());

View File

@ -1,6 +1,6 @@
[package]
name = "embassy-net-adin1110"
version = "0.1.0"
version = "0.2.0"
description = "embassy-net driver for the ADIN1110 ethernet chip"
keywords = ["embedded", "ADIN1110", "embassy-net", "embedded-hal-async", "ethernet", "async"]
categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"]
@ -10,32 +10,31 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
heapless = "0.7.16"
heapless = "0.8"
defmt = { version = "0.3", optional = true }
log = { version = "0.4.4", default-features = false, optional = true }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" }
embedded-hal-async = { version = "=1.0.0-rc.1" }
embedded-hal-bus = { version = "=0.1.0-rc.1", features = ["async"] }
embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel" }
embassy-time = { version = "0.1.0" }
log = { version = "0.4", default-features = false, optional = true }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" }
embedded-hal-async = { version = "=1.0.0-rc.2" }
embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] }
embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" }
embassy-time = { version = "0.1.5", path = "../embassy-time" }
embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
bitfield = "0.14.0"
[dev-dependencies]
# reenable when https://github.com/dbrgn/embedded-hal-mock/pull/86 is merged.
#embedded-hal-mock = { git = "https://github.com/dbrgn/embedded-hal-mock", branch = "1-alpha", features = ["embedded-hal-async", "eh1"] }] }
embedded-hal-mock = { git = "https://github.com/newAM/embedded-hal-mock", branch = "eh1-rc.1", features = ["embedded-hal-async", "eh1"] }
embedded-hal-mock = { git = "https://github.com/Dirbaio/embedded-hal-mock", rev = "c5c4dca18e043e6386aee02173f61a65fea3981e", features = ["embedded-hal-async", "eh1"] }
crc = "3.0.1"
env_logger = "0.10"
critical-section = { version = "1.1.1", features = ["std"] }
futures-test = "0.3.17"
critical-section = { version = "1.1.2", features = ["std"] }
futures-test = "0.3.28"
[features]
default = [ ]
defmt = [ "dep:defmt" ]
defmt = [ "dep:defmt", "embedded-hal-1/defmt-03" ]
log = ["dep:log"]
[package.metadata.embassy_docs]
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-adin1110-v$VERSION/embassy-net-adin1110/src/"
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net-adin1110/src/"
target = "thumbv7em-none-eabi"
features = ["defmt"]

View File

@ -30,8 +30,8 @@ Currently only `Generic` SPI with or without CRC is supported.
## Hardware
- Tested on [`Analog Devices EVAL-ADIN1110EBZ`](https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/eval-adin1110.html) with an `STM32L4S5QII3P`, see [`spe_adin1110_http_server`](../examples/stm32l4/src/bin/spe_adin1110_http_server.rs) dor an example.
- [`SparkFun MicroMod Single Pair Ethernet Function Board`](https://www.sparkfun.com/products/19038) or [`SparkFun MicroMod Single Pair Ethernet Kit`](https://www.sparkfun.com/products/19628), supporting multiple microcontrollers. **Make sure to check if it's a microcontroller that is supported by Embassy!**
- Tested on [`Analog Devices EVAL-ADIN1110EBZ`](https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/eval-adin1110.html) with an `STM32L4S5QII3P`, see [`spe_adin1110_http_server`](../examples/stm32l4/src/bin/spe_adin1110_http_server.rs) for an example.
- [`SparkFun MicroMod Single Pair Ethernet Function Board`](https://www.sparkfun.com/products/19038) or [`SparkFun MicroMod Single Pair Ethernet Kit (End Of Life)`](https://www.sparkfun.com/products/19628), supporting multiple microcontrollers. **Make sure to check if it's a microcontroller that is supported by Embassy!**
## Other SPE chips
@ -44,6 +44,39 @@ ADIN1110 library can tested on the host with a mock SPI driver.
$ `cargo test --target x86_64-unknown-linux-gnu`
## Benchmark
- Benchmarked on [`Analog Devices EVAL-ADIN1110EBZ`](https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/eval-adin1110.html), with [`spe_adin1110_http_server`](../examples/stm32l4/src/bin/spe_adin1110_http_server.rs) example.
Basic `ping` benchmark
```rust,ignore
# ping <IP> -c 60
60 packets transmitted, 60 received, 0% packet loss, time 59066ms
rtt min/avg/max/mdev = 1.089/1.161/1.237/0.018 ms
# ping <IP> -s 1472 -M do -c 60
60 packets transmitted, 60 received, 0% packet loss, time 59066ms
rtt min/avg/max/mdev = 5.122/5.162/6.177/0.133 ms
```
HTTP load generator benchmark with [`oha`](https://github.com/hatoo/oha)
```rust,ignore
# oha -c 1 http://<IP> -z 60s
Summary:
Success rate: 50.00%
Total: 60.0005 secs
Slowest: 0.0055 secs
Fastest: 0.0033 secs
Average: 0.0034 secs
Requests/sec: 362.1971
Total data: 2.99 MiB
Size/request: 289 B
Size/sec: 51.11 KiB
```
## License
This work is licensed under either of

View File

@ -257,29 +257,30 @@ pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [
0x2D02_EF8D,
];
/// Generate Ethernet Frame Check Sequence
#[allow(non_camel_case_types)]
#[derive(Debug)]
pub struct ETH_FSC(pub u32);
pub struct ETH_FCS(pub u32);
impl ETH_FSC {
impl ETH_FCS {
pub const CRC32_OK: u32 = 0x2144_df1c;
#[must_use]
pub fn new(data: &[u8]) -> Self {
let fsc = data.iter().fold(u32::MAX, |crc, byte| {
let fcs = data.iter().fold(u32::MAX, |crc, byte| {
let idx = u8::try_from(crc & 0xFF).unwrap() ^ byte;
CRC32R_LOOKUP_TABLE[usize::from(idx)] ^ (crc >> 8)
}) ^ u32::MAX;
Self(fsc)
Self(fcs)
}
#[must_use]
pub fn update(self, data: &[u8]) -> Self {
let fsc = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| {
let fcs = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| {
let idx = u8::try_from(crc & 0xFF).unwrap() ^ byte;
CRC32R_LOOKUP_TABLE[usize::from(idx)] ^ (crc >> 8)
}) ^ u32::MAX;
Self(fsc)
Self(fcs)
}
#[must_use]
@ -319,24 +320,24 @@ mod tests {
];
// Packet A
let own_crc = ETH_FSC::new(&packet_a[0..60]);
let own_crc = ETH_FCS::new(&packet_a[0..60]);
let crc_bytes = own_crc.hton_bytes();
println!("{:08x} {:02x?}", own_crc.0, crc_bytes);
assert_eq!(&crc_bytes, &packet_a[60..64]);
let own_crc = ETH_FSC::new(packet_a);
let own_crc = ETH_FCS::new(packet_a);
println!("{:08x}", own_crc.0);
assert_eq!(own_crc.0, ETH_FSC::CRC32_OK);
assert_eq!(own_crc.0, ETH_FCS::CRC32_OK);
// Packet B
let own_crc = ETH_FSC::new(&packet_b[0..60]);
let own_crc = ETH_FCS::new(&packet_b[0..60]);
let crc_bytes = own_crc.hton_bytes();
println!("{:08x} {:02x?}", own_crc.0, crc_bytes);
assert_eq!(&crc_bytes, &packet_b[60..64]);
let own_crc = ETH_FSC::new(packet_b);
let own_crc = ETH_FCS::new(packet_b);
println!("{:08x}", own_crc.0);
assert_eq!(own_crc.0, ETH_FSC::CRC32_OK);
assert_eq!(own_crc.0, ETH_FCS::CRC32_OK);
}
#[test]
@ -349,9 +350,9 @@ mod tests {
];
let (part_a, part_b) = full_data.split_at(16);
let crc_partially = ETH_FSC::new(part_a).update(part_b);
let crc_partially = ETH_FCS::new(part_a).update(part_b);
let crc_full = ETH_FSC::new(full_data);
let crc_full = ETH_FCS::new(full_data);
assert_eq!(crc_full.0, crc_partially.0);
}

View File

@ -1,6 +1,8 @@
#![macro_use]
#![allow(unused_macros)]
use core::fmt::{Debug, Display, LowerHex};
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
@ -111,7 +113,7 @@ macro_rules! trace {
#[cfg(feature = "defmt")]
::defmt::trace!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
let _ignored = ($( & $x ),*);
}
};
}
@ -124,7 +126,7 @@ macro_rules! debug {
#[cfg(feature = "defmt")]
::defmt::debug!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
let _ignored = ($( & $x ),*);
}
};
}
@ -137,7 +139,7 @@ macro_rules! info {
#[cfg(feature = "defmt")]
::defmt::info!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
let _ignored = ($( & $x ),*);
}
};
}
@ -150,7 +152,7 @@ macro_rules! warn {
#[cfg(feature = "defmt")]
::defmt::warn!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
let _ignored = ($( & $x ),*);
}
};
}
@ -163,7 +165,7 @@ macro_rules! error {
#[cfg(feature = "defmt")]
::defmt::error!($s $(, $x)*);
#[cfg(not(any(feature = "log", feature="defmt")))]
let _ = ($( & $x ),*);
let _ignored = ($( & $x ),*);
}
};
}
@ -223,3 +225,30 @@ impl<T, E> Try for Result<T, E> {
self
}
}
pub struct Bytes<'a>(pub &'a [u8]);
impl<'a> Debug for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> Display for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
impl<'a> LowerHex for Bytes<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{:#02x?}", self.0)
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for Bytes<'a> {
fn format(&self, fmt: defmt::Formatter) {
defmt::write!(fmt, "{:02x}", self.0)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -32,11 +32,12 @@ enum Reg13Op {
PostReadIncAddr = 0b10 << 14,
Read = 0b11 << 14,
}
/// `MdioBus` trait
/// Driver needs to implement the Clause 22
/// Optional Clause 45 is the device supports this.
///
/// Claus 45 methodes are bases on <https://www.ieee802.org/3/efm/public/nov02/oam/pannell_oam_1_1102.pdf>
/// Clause 45 methodes are bases on <https://www.ieee802.org/3/efm/public/nov02/oam/pannell_oam_1_1102.pdf>
pub trait MdioBus {
type Error;
@ -87,89 +88,89 @@ pub trait MdioBus {
}
}
// #[cfg(test)]
// mod tests {
// use core::convert::Infallible;
#[cfg(test)]
mod tests {
use core::convert::Infallible;
// use super::{MdioBus, PhyAddr, RegC22, RegVal};
use super::{MdioBus, PhyAddr, RegC22, RegVal};
// #[derive(Debug, PartialEq, Eq)]
// enum A {
// Read(PhyAddr, RegC22),
// Write(PhyAddr, RegC22, RegVal),
// }
#[derive(Debug, PartialEq, Eq)]
enum A {
Read(PhyAddr, RegC22),
Write(PhyAddr, RegC22, RegVal),
}
// struct MockMdioBus(Vec<A>);
struct MockMdioBus(Vec<A>);
// impl MockMdioBus {
// pub fn clear(&mut self) {
// self.0.clear();
// }
// }
impl MockMdioBus {
pub fn clear(&mut self) {
self.0.clear();
}
}
// impl MdioBus for MockMdioBus {
// type Error = Infallible;
impl MdioBus for MockMdioBus {
type Error = Infallible;
// fn write_cl22(
// &mut self,
// phy_id: super::PhyAddr,
// reg: super::RegC22,
// reg_val: super::RegVal,
// ) -> Result<(), Self::Error> {
// self.0.push(A::Write(phy_id, reg, reg_val));
// Ok(())
// }
async fn write_cl22(
&mut self,
phy_id: super::PhyAddr,
reg: super::RegC22,
reg_val: super::RegVal,
) -> Result<(), Self::Error> {
self.0.push(A::Write(phy_id, reg, reg_val));
Ok(())
}
// fn read_cl22(
// &mut self,
// phy_id: super::PhyAddr,
// reg: super::RegC22,
// ) -> Result<super::RegVal, Self::Error> {
// self.0.push(A::Read(phy_id, reg));
// Ok(0)
// }
// }
async fn read_cl22(
&mut self,
phy_id: super::PhyAddr,
reg: super::RegC22,
) -> Result<super::RegVal, Self::Error> {
self.0.push(A::Read(phy_id, reg));
Ok(0)
}
}
// #[test]
// fn read_test() {
// let mut mdiobus = MockMdioBus(Vec::with_capacity(20));
#[futures_test::test]
async fn read_test() {
let mut mdiobus = MockMdioBus(Vec::with_capacity(20));
// mdiobus.clear();
// mdiobus.read_cl22(0x01, 0x00).unwrap();
// assert_eq!(mdiobus.0, vec![A::Read(0x01, 0x00)]);
mdiobus.clear();
mdiobus.read_cl22(0x01, 0x00).await.unwrap();
assert_eq!(mdiobus.0, vec![A::Read(0x01, 0x00)]);
// mdiobus.clear();
// mdiobus.read_cl45(0x01, (0xBB, 0x1234)).unwrap();
// assert_eq!(
// mdiobus.0,
// vec![
// #[allow(clippy::identity_op)]
// A::Write(0x01, 13, (0b00 << 14) | 27),
// A::Write(0x01, 14, 0x1234),
// A::Write(0x01, 13, (0b11 << 14) | 27),
// A::Read(0x01, 14)
// ]
// );
// }
mdiobus.clear();
mdiobus.read_cl45(0x01, (0xBB, 0x1234)).await.unwrap();
assert_eq!(
mdiobus.0,
vec![
#[allow(clippy::identity_op)]
A::Write(0x01, 13, (0b00 << 14) | 27),
A::Write(0x01, 14, 0x1234),
A::Write(0x01, 13, (0b11 << 14) | 27),
A::Read(0x01, 14)
]
);
}
// #[test]
// fn write_test() {
// let mut mdiobus = MockMdioBus(Vec::with_capacity(20));
#[futures_test::test]
async fn write_test() {
let mut mdiobus = MockMdioBus(Vec::with_capacity(20));
// mdiobus.clear();
// mdiobus.write_cl22(0x01, 0x00, 0xABCD).unwrap();
// assert_eq!(mdiobus.0, vec![A::Write(0x01, 0x00, 0xABCD)]);
mdiobus.clear();
mdiobus.write_cl22(0x01, 0x00, 0xABCD).await.unwrap();
assert_eq!(mdiobus.0, vec![A::Write(0x01, 0x00, 0xABCD)]);
// mdiobus.clear();
// mdiobus.write_cl45(0x01, (0xBB, 0x1234), 0xABCD).unwrap();
// assert_eq!(
// mdiobus.0,
// vec![
// A::Write(0x01, 13, 27),
// A::Write(0x01, 14, 0x1234),
// A::Write(0x01, 13, (0b01 << 14) | 27),
// A::Write(0x01, 14, 0xABCD)
// ]
// );
// }
// }
mdiobus.clear();
mdiobus.write_cl45(0x01, (0xBB, 0x1234), 0xABCD).await.unwrap();
assert_eq!(
mdiobus.0,
vec![
A::Write(0x01, 13, 27),
A::Write(0x01, 14, 0x1234),
A::Write(0x01, 13, (0b01 << 14) | 27),
A::Write(0x01, 14, 0xABCD)
]
);
}
}

Some files were not shown because too many files have changed in this diff Show More