Commit Graph

262 Commits

Author SHA1 Message Date
huntc
baab52d40c Avoid a race condition by reducing the locks to one 2021-07-15 12:31:52 +10:00
huntc
5a5795ef2b NoopMutex does not require an UnsafeCell 2021-07-15 12:31:52 +10:00
huntc
9b5f2e465b Tidying 2021-07-15 12:31:52 +10:00
huntc
108cffcba0 Migrated to the waker registration functionality for Embassy specific optimisations 2021-07-15 12:31:52 +10:00
huntc
dcd0c38109 Return a new future each time recv is called 2021-07-15 12:31:52 +10:00
huntc
f159beec1c Use of a NoopMutex 2021-07-15 12:31:52 +10:00
huntc
5f87c7808c Remove the cell and trait
At the expense of exposing the channel types again. We do this as we want to avoid using dyn traits given their overhead for embedded environments.
2021-07-15 12:31:52 +10:00
huntc
56b3e927fe ChannelState should be private 2021-07-15 12:31:52 +10:00
huntc
3fdf61c819 Constraint the use of ChannelCell to just channels 2021-07-15 12:31:52 +10:00
huntc
ae62948d6c Replace UnsafeCell
Using a new ChannelCell so that there's no leaking of the abstraction
2021-07-15 12:31:52 +10:00
huntc
1b49acc2f7 Fixed some clippy warnings 2021-07-15 12:31:52 +10:00
huntc
a156f72bfb Improves the representation of side effects 2021-07-15 12:31:52 +10:00
huntc
816b78c0d9 Reduces the types on sender and receiver
In exchange for an UnsafeCell being passed into split
2021-07-15 12:31:52 +10:00
huntc
1b9d5e5071 Multi Producer Single Consumer channel
An MPSC inspired by Tokio and Crossbeam. The MPSC is designed to support both single and multi core processors, with only single core implemented at this time. The allocation of the channel’s buffer is inspired by the const generic parameters that Heapless provides.
2021-07-15 12:31:52 +10:00
Dario Nieuwenhuis
c210a6efd1 embassy/time: remove useless impl 2021-07-12 03:45:48 +02:00
Dario Nieuwenhuis
16bb678368 Merge BlockingTimer and Delay 2021-07-12 03:45:48 +02:00
Dario Nieuwenhuis
35a76c364a embassy/time: make optional via Cargo feature 2021-07-12 03:45:48 +02:00
Dario Nieuwenhuis
94bd4eb7d5 embassy/time: refactor module structure 2021-07-12 03:45:48 +02:00
huntc
e13aa4c2a0 Add tests to our CI
Also found some doctests that were failing
2021-07-06 12:29:08 +10:00
Rukai
56d0c5ffe1 Fix warnings in std and rp 2021-07-04 12:46:04 +10:00
Thales Fragoso
51583afc1e Add docs for BlockingTimer and rename tick features 2021-06-28 18:52:27 -03:00
Thales Fragoso
54197d1663 Add BlockingTimer and features to choose tick rate 2021-06-28 18:01:40 -03:00
Dario Nieuwenhuis
3be49d3e79 fmt: Add dunmy use to avoid "unused variable" errors when no log is enabled. 2021-06-07 03:21:37 +02:00
Dario Nieuwenhuis
ef1ebefec0 fmt: use absolute paths 2021-06-07 03:15:05 +02:00
Dario Nieuwenhuis
e7dc5c0939 fmt: make all macros macro_rules so scoping is consistent. 2021-06-07 00:16:39 +02:00
Timo Kröger
628e58020f Add Unborrow trait bound for Interrupt
Allows the compiler to figure out bounds for wrapper code of owned
peripherals and interrupts.
Example: https://gist.github.com/timokroeger/f025ef590557f1cd6c2e9c7ab30442d2
2021-06-04 23:42:25 +02:00
Ulf Lilleengen
ec9b51833c Allow non-mut register and wake 2021-06-01 15:18:53 +02:00
Dario Nieuwenhuis
1c0ad53841 Unborrow docs 2021-05-19 23:39:45 +02:00
Dario Nieuwenhuis
105c8504b6 Mark Unborrow as unsafe to implement 2021-05-19 23:29:33 +02:00
Dario Nieuwenhuis
dc67d2f4a4 impl Unborrow for &'a mut T
This plays nicer with user code that's generic over peripheral traits like `Instance` or `Pin`.
2021-05-19 23:20:26 +02:00
Dario Nieuwenhuis
a8902b0592 Fix build with executor-agnostic 2021-05-19 13:00:01 +02:00
Dario Nieuwenhuis
cd0d3c4b0d Merge branch 'stm32-neo' 2021-05-17 02:16:17 +02:00
Thales Fragoso
490152d028 Better interrupt handling 2021-05-14 23:42:09 -03:00
Ulf Lilleengen
3b86e85770 Bump version of critical-section to 0.2.1 2021-05-13 18:17:50 +02:00
Dario Nieuwenhuis
7fa0e57172 Use critical_section crate 2021-05-11 01:15:30 +02:00
Rukai
6c3299c82f Fix build on the latest nightly 2021-05-10 00:36:23 +02:00
Rukai
ab00c6987a Fix build on the latest nightly 2021-05-08 13:23:17 +10:00
Dario Nieuwenhuis
97ca54fa66 Rename PeripheralBorrow to Unborrow 2021-04-14 19:59:52 +02:00
Dario Nieuwenhuis
d336a4b38a Remove Pin from Delay trait 2021-04-14 17:04:40 +02:00
Dario Nieuwenhuis
fa8dc796a7 Workaround broken cast crate 2021-04-12 13:30:21 +02:00
Ulf Lilleengen
708e622ab0 Allow signals to be used when building for std 2021-04-12 12:06:42 +02:00
xoviat
009e1896bf stm32: consolidate crates 2021-03-30 10:05:52 -05:00
xoviat
49d87ac868 add with_timeout 2021-03-29 15:48:57 -05:00
Dario Nieuwenhuis
d7c3a38efc Reexport macros at root, use eveywhere as #[embassy::task] 2021-03-29 03:00:48 +02:00
Dario Nieuwenhuis
1c9f98e1b6 nrf/gpiote: fix irq race condition
The interrupt could fire between checking if sense=disabled and registering the waker,
in which case the future would get stuck.
2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
4ce46df160 Code size optimizations. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
0e8bb5dc0b util: Do not unregister waker on wake in AtomicWaker. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
df42c38492 nrf/uarte: update to new api 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
a134fce122 nrf: nicer Peripherals api, add take() 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
ba6e0a4058 util: add wake_on_interrupt.
This is a lighter version of InterruptFuture.
2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
9c4087ac5c Introduce PeripheralBorrow trait 2021-03-29 00:58:57 +02:00
xoviat
6ee9e012fc add embassy::main and implement for stm32f4 2021-03-27 17:27:39 -05:00
Joshua Salzedo
ea650b684c
its /// not //. 2021-03-24 13:31:08 -07:00
Joshua Salzedo
18d3c803de
Add missing newlines 2021-03-24 13:21:32 -07:00
Joshua Salzedo
40617fea04
Document embassy::util::signal & embassy::util 2021-03-24 13:19:36 -07:00
Joshua Salzedo
62009150bd
Document embassy::util::InterruptFuture 2021-03-24 13:19:36 -07:00
Joshua Salzedo
a9e099c215
Document embassy::util::Forever 2021-03-24 13:19:36 -07:00
Joshua Salzedo
da59112e86
Document the DropBomb 2021-03-24 13:19:35 -07:00
Joshua Salzedo
8fbe83ac26
Added remainder of the docs for embassy::time's public interface. 2021-03-21 18:30:03 -07:00
Joshua Salzedo
42be860446
Correct descriptions of Duration 2021-03-21 17:11:30 -07:00
Joshua Salzedo
7988b78107
remove now redundant non-doc comment 2021-03-21 17:05:36 -07:00
Joshua Salzedo
10f14747c3
Fix module-level docstring 2021-03-21 17:05:22 -07:00
Joshua Salzedo
e363607d70
Added doc to the embassy::time::Duration struct 2021-03-21 17:01:52 -07:00
Joshua Salzedo
f8d63279ef
Re-add erroneously removed newlines 2021-03-21 17:01:13 -07:00
Joshua Salzedo
dcdd768e03 Add Struct/impl documentation for embassy::time::Instant 2021-03-21 16:45:53 -07:00
Joshua Salzedo
d453b9dd95 Add Struct/impl documentation for embassy::time::Duration 2021-03-21 16:45:48 -07:00
Joshua Salzedo
cf1323fb67 Add module-level documentation for embassy::time 2021-03-21 16:45:24 -07:00
Michael Beaumont
d3673886b3
Run cargo fmt 2021-03-18 20:02:42 +01:00
Dario Nieuwenhuis
f248bb17ad Allow unused stuff in fmt.rs 2021-03-18 01:42:28 +01:00
Dario Nieuwenhuis
8c2da193b8 Add spawn/spawn_pool APIs to Task 2021-03-18 00:38:27 +01:00
Dario Nieuwenhuis
5c2bf3981e Move Task into raw 2021-03-18 00:20:11 +01:00
Dario Nieuwenhuis
278ce02824 Rename IrqExecutor to InterruptExecutor 2021-03-17 22:52:57 +01:00
Dario Nieuwenhuis
a9076636ac Do not export fmt macros.
This was introduced by accident by me struggling with the weird intra-crate macro importing system...
2021-03-17 22:50:27 +01:00
Dario Nieuwenhuis
bb68f5d0e8 Add optimized single-word WakerRegistration, add AtomicWakerRegistration. 2021-03-17 02:53:41 +01:00
Dario Nieuwenhuis
ab01e0be3b Do not reexport atomic-polyfill 2021-03-17 02:52:21 +01:00
Dario Nieuwenhuis
6ed1a87138 Update features for latest nightly. 2021-03-17 02:48:16 +01:00
Dario Nieuwenhuis
bd3deb785a Update deps 2021-03-04 22:41:54 +01:00
Dario Nieuwenhuis
18f6b8ad68 thumbv6m support with emulated atomics 2021-03-04 21:56:31 +01:00
Dario Nieuwenhuis
88946840d1 Make Delay public 2021-03-02 21:16:43 +01:00
Dario Nieuwenhuis
d4f2c6cf00 Remove cargo namespaced-features 2021-03-02 21:15:12 +01:00
xoviat
7ef81c75e7 traits: add delay trait
delay allows downstream libraries
to use async delay without depending
on a specific delay implementation
2021-03-02 08:45:22 -06:00
xoviat
9626aee7db Move traits to separate crate. 2021-03-02 00:32:23 +01:00
Dario Nieuwenhuis
084b64053a
Merge pull request #61 from xoviat/us-delay
add us delays
2021-03-01 19:06:57 +01:00
xoviat
a7549108a8 rename methods 2021-03-01 11:59:40 -06:00
xoviat
d029f651fa add us delays 2021-03-01 11:47:55 -06:00
Dario Nieuwenhuis
45355f184a move most interrupt methods to InterruptExt extension trait. Fixes #35 2021-03-01 00:44:38 +01:00
Dario Nieuwenhuis
7433dc1039 Port qspi to PeripheralMutex 2021-02-28 22:05:37 +01:00
Dario Nieuwenhuis
da91779117 interrupt: Split set_handler context.
Since introducing the ctx pointer, the handler is now two words, so setting it can
race with the interrupt firing. On race it's possible for the new handler to be
alled with the old ctx pointer or viceversa.

Rather than documenting this, it's better to split the function in two to make it
obvious to the user that it's not atomic. The user can use a critical section, or
disable/enable the interrupt to avoid races if this is a concern.
2021-02-26 02:04:48 +01:00
Dario Nieuwenhuis
17cf301d4f Remove rand(), fixes #50 2021-02-26 01:58:00 +01:00
Dario Nieuwenhuis
11be9170ec Cleanup interrupt package naming. Fixes #40
The `interrupt` package previously tried to be drop-in compatible with the
`interrupt` package from PACs. THis meant that there was both a PAC-style enum
value `UARTE0` and an embassy-style owned `UARTE0Interrupt` type. This made
things VERY confusing.

This drops compatibility with the PAC, improving the names for embassy interrupts.
2021-02-26 01:55:27 +01:00
Dario Nieuwenhuis
90476ef900 Fix some warnings. 2021-02-26 01:06:58 +01:00
fnafnio
f779ec4928 update defmt and defmt-rtt to 0.2.0 2021-02-24 08:44:23 +01:00
Dario Nieuwenhuis
7321ddb0b3 Update to cortex-m 0.7 2021-02-14 23:26:50 +01:00
Thales Fragoso
b69f72e055 Get rid of some warnings 2021-02-13 21:41:36 -03:00
Dario Nieuwenhuis
1879703153 CriticalSectionMutex should require Send. 2021-02-03 16:29:35 +01:00
Dario Nieuwenhuis
d71c4b4551 Make spawners Copy+Clone 2021-02-03 04:41:46 +01:00
Dario Nieuwenhuis
4192e52629 Update embassy-std to new executor api 2021-02-03 04:30:11 +01:00
Dario Nieuwenhuis
aeaa34d7a1 Executor API V2.
- It's no longer possible to call run() reentrantly from within a task (soundness issue)
- it's now possible to spawn Send tasks across threads (SendSpawner, #37)
2021-02-02 05:20:41 +01:00
xoviat
e0183f4495 optimize interruptfuture
remove critical secitons, impl. Unpin
2021-01-21 10:59:14 -06:00
xoviat
6503f9dbf5 implement interruptfuture
converts an interrupt to a future
2021-01-21 10:22:30 -06:00
Dario Nieuwenhuis
5b897b6605 executor: Add 'raw' api to wake tasks through raw pointers. 2021-01-21 01:00:12 +01:00
Dario Nieuwenhuis
4e789c663c
Merge pull request #15 from akiles/gpio-wait
RFC: GPIO WaitForFoo traits
2021-01-15 23:06:07 +01:00
Dario Nieuwenhuis
c91882a72c Add CriticalSectionMutex, ThreadModeMutex. 2021-01-11 10:38:43 +01:00
Dario Nieuwenhuis
877fc0321a WakerRegistration: Wake previous task if any 2021-01-11 10:38:25 +01:00
Dario Nieuwenhuis
60df9e0d38 Add non_exhaustive attrs. 2021-01-09 00:51:07 +01:00
Dario Nieuwenhuis
f6be0b8d12 Add gpio WaitForFoo traits 2021-01-06 01:10:48 +01:00
Dario Nieuwenhuis
9bb4c97dc2
Merge pull request #14 from timokroeger/uarte-power-optimization
UARTE power optimization and improvements
2021-01-05 22:10:52 +01:00
Timo Kröger
0631623b51 uarte: Low power wait for RX drop 2021-01-04 22:55:40 +01:00
Dario Nieuwenhuis
9e88718fbd Add "context" pointer to owned interrupt handlers. 2021-01-04 22:25:39 +01:00
Dario Nieuwenhuis
0ab88ea279 Add Uart trait, implement it for nrf. 2021-01-02 19:59:37 +01:00
Dario Nieuwenhuis
1d53985abe Remove now-stable slice_fill feature 2021-01-02 19:56:05 +01:00
Dario Nieuwenhuis
4783222f67 Rename WakerStore -> WakerRegistration. 2021-01-01 22:30:11 +01:00
Timo Kröger
c97d5262f5 Blocking wait method for signals 2020-12-30 19:24:12 +01:00
Dario Nieuwenhuis
6bc1a712ff Fix Forever 2020-12-30 04:17:45 +01:00
Dario Nieuwenhuis
a02d0a378e Fix race in enqueuing expired tasks. 2020-12-30 04:12:48 +01:00
Dario Nieuwenhuis
bb6f25d010 Remove use of deprecated compare_and_swap. 2020-12-30 01:07:22 +01:00
Dario Nieuwenhuis
015b6bbce4 Ensure timers always yield at least once.
This prevents a task that's constantly running late from monopolizing the CPU.
Add executor_fairness_test example showcasing it.
2020-12-30 00:57:35 +01:00
Dario Nieuwenhuis
0750234fbe WIP owned irqs 2020-12-29 00:05:52 +01:00
Dario Nieuwenhuis
b01a88a839 Do not run timer queue if no alarm is set. 2020-12-29 00:04:58 +01:00
Dario Nieuwenhuis
4a7344cb6f Add embassy-std crate with glue to run embassy on std. 2020-12-28 03:41:40 +01:00
Dario Nieuwenhuis
32c67381df Add missing ?Sized bound in read_line 2020-12-27 23:34:05 +01:00
Dario Nieuwenhuis
692d8bb813 More efficient timer queue, integrated into Executor directly. 2020-12-26 23:44:53 +01:00
Dario Nieuwenhuis
8b7a42a4f9 Split waker to separate file. 2020-12-26 17:22:36 +01:00
Dario Nieuwenhuis
3df66c44e3 Split executor into multiple files, remove old timers implementation. 2020-12-26 16:42:44 +01:00
Dario Nieuwenhuis
db8b4ca565 Better SpawnToken error messages 2020-12-26 15:15:50 +01:00
Dario Nieuwenhuis
80c504cd95 Add std impl for rand 2020-12-14 00:36:29 +01:00
Dario Nieuwenhuis
1aae27270e Better fmt macros. 2020-12-13 21:17:58 +01:00
Dario Nieuwenhuis
3be7ace878 add time::Ticker 2020-12-13 19:54:18 +01:00
Dario Nieuwenhuis
ca2ff632ba Fix possibly ambiguous macro 2020-12-01 20:00:55 +01:00
Dario Nieuwenhuis
6f76c0ebcc Add support for log+defmt again, but better. 2020-12-01 17:46:56 +01:00
Dario Nieuwenhuis
78135a81d9 Remove anyfmt 2020-11-27 18:42:59 +01:00
Dario Nieuwenhuis
49d5121094 Fix unsoundness in Forever 2020-11-16 01:04:56 +01:00
Dario Nieuwenhuis
2e062f5627 gpiote: change port api to directly return futures. 2020-11-09 01:04:34 +01:00
Dario Nieuwenhuis
a2735a716c Add signal reset() 2020-11-08 18:41:22 +01:00
Dario Nieuwenhuis
5e8608c7a5 Make defmt optional with new anyfmt crate 2020-11-01 17:17:24 +01:00
Dario Nieuwenhuis
2c13e25184 Fix for latest nightly 2020-10-31 23:14:09 +01:00
Dario Nieuwenhuis
2684bf605a update multiprio example. 2020-10-31 22:45:35 +01:00
Dario Nieuwenhuis
76196c424a Make Executor non-Send to close run() safety hole. 2020-10-31 22:36:45 +01:00
Dario Nieuwenhuis
5c575c29e6 cargo fmt 2020-10-31 20:02:16 +01:00
Dario Nieuwenhuis
4cc8bbd06c Remove unsafe from executor api 2020-10-31 16:37:50 +01:00
Dario Nieuwenhuis
e9843c3f0a cargo fmt 2020-10-31 16:37:34 +01:00
Dario Nieuwenhuis
b4a8b03c84 Improve std error compat 2020-10-31 16:37:09 +01:00
Dario Nieuwenhuis
53eb594878 Add Forever 2020-10-31 16:35:42 +01:00
Dario Nieuwenhuis
03bd11ce0d Add Rand trait 2020-10-31 16:35:18 +01:00
Dario Nieuwenhuis
878bfd2b75 Fixes 2020-10-26 12:43:28 +01:00
Dario Nieuwenhuis
a0cc229a3a time: 64bit duration, add some methods 2020-10-26 12:39:53 +01:00
Dario Nieuwenhuis
041a22a958 impl defmt::Format for Instant 2020-10-20 17:04:15 +02:00
Dario Nieuwenhuis
80ce73a2c1 Fix executor hanging in some cases where tasks wake themselves. 2020-10-19 22:08:37 +02:00
Dario Nieuwenhuis
53a064445f defmt feature doesn't really exist here 2020-10-19 21:46:25 +02:00
Dario Nieuwenhuis
a2e73cb549 time: some const fns 2020-10-19 21:25:54 +02:00