Commit graph

67 commits

Author SHA1 Message Date
bors[bot]
2f43969dd4
Merge #742
742: Only 1 argument in embassy::main when there is no HAL r=Dirbaio a=jbeaurivage

There is a slight mistake in an error message from `[embassy::main]` macro. When there is no HAL specified, `main` should take only one argument.

Co-authored-by: Justin Beaurivage <justin@wearableavionics.com>
2022-04-29 14:29:26 +00:00
Justin Beaurivage
c53b2fdc05 Require 1 argument in embassy::main without HAL 2022-04-29 09:32:31 -04:00
Dario Nieuwenhuis
1599009a4f executor: "send-spawn is OK if the args are Send" only holds for async fn futures.
The normal `spawn()` methods can be called directly by the user, with arbitrary hand-implemented futures.
We can't enforce they're only called with `async fn` futures. Therefore, make these
require `F: Send`, and add a "private" one only for use in the macro, which can enforce it.
2022-04-27 04:56:41 +02:00
Dario Nieuwenhuis
6f6c16f449 executor: make send-spawning only require the task args to be Send, not the whole future. 2022-04-27 04:56:41 +02:00
Dario Nieuwenhuis
293f54d134 executor: add raw::TaskPool.
This simplifies the macro code a bit.
2022-04-27 04:56:41 +02:00
Dario Nieuwenhuis
96d917992c macros: simplify task macro using "TAIT laundering". 2022-04-26 18:40:45 +02:00
Dario Nieuwenhuis
c4cecec10c macros: isolate the TAIT into its own mod.
This fixes type inference issues due to the TAIT's defining scope
being the whole parent mod.
2022-04-25 22:18:52 +02:00
Dario Nieuwenhuis
408617266e Update Rust nightly.
Fixes a new opaque type error in the task macro.
Full error is "opaque type's hidden type cannot be another opaque type from the same scope".
This got disallwed by the lazy-TAIT PR: https://github.com/rust-lang/rust/pull/94081

Sadly there's now some weird type inference errors with pre-lazy-TAIT
nightlies, so support for those is dropped.
2022-04-24 04:24:08 +02:00
Dario Nieuwenhuis
611961b499 macros: cleanup, make work in stable. 2022-02-12 01:16:31 +01:00
Dario Nieuwenhuis
caf48d8a95 macros: initialize chip before executor.
The executor will call into the chip's time-driver, which may need the chip
to be initialized.
2022-01-05 13:30:46 +01:00
Ulf Lilleengen
985c11fad5 Update rust-toolchain 2021-12-16 11:34:20 +01:00
Matous Hybl
0ca6060bfd Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
Wilfried Chauveau
e6abd9f5df
Fix warning for field never used. 2021-11-21 08:33:18 +00:00
Dario Nieuwenhuis
a2e7c24e00 Clippy fixes 2021-10-18 01:05:29 +02:00
Ulf Lilleengen
e24528051b Add WASM support for executor
* Adds an executor for WASM runtimes based on wasm_bindgen.
* Add time driver based on JS time handling.
* Add example that can run in browser locally.
* Update to critical-section version that supports 'std' flag
2021-09-13 16:42:39 +02:00
Dario Nieuwenhuis
f2623e7e9b Update lots of deps 2021-09-11 01:35:23 +02:00
Ulf Lilleengen
5f04d6e6c5 Fix embassy::main macros for std target 2021-09-02 14:45:54 +02:00
Dario Nieuwenhuis
297de612e5 Improve executor naming. Add docs. 2021-08-31 23:59:28 +02:00
Ben Gamari
a3b56a3764 embassy-macros: Use defmt::unwrap! when spawning embassy::main
But only when `defmt` feature is enabled.
2021-08-05 22:40:12 +02:00
Dario Nieuwenhuis
0ea6a2d890 time: replace dyn clock/alarm with a global Driver trait 2021-08-05 19:14:09 +02:00
Liam Murphy
53e66a383f Forward attributes to generated task function
Fixes #18

Syn considers doc comments to be attributes, so forwarding those fixes the issue.
It's probably a good idea to forward most attributes anyway.
2021-08-05 15:35:50 +10:00
Dario Nieuwenhuis
7547c8d8d6 rp/timer: add 2021-07-12 03:45:57 +02:00
Thales Fragoso
f5e6b37b52 STM: Change embassy main to use TIM3 instead of TIM2 2021-07-04 15:51:10 -03:00
Ulf Lilleengen
952f525af5 Provide a way for a peripheral to query its clock frequency
Currently this looks up the frequency in the global singleton that must
be initialized by the per-chip RCC implementation. At present, this is
only done for the L0 family of chips.
2021-06-14 11:33:11 +02:00
Ulf Lilleengen
0a9022d59f Enable timer clock in RCC on timer start
* Moves the tim2-specific code into macro which always uses TIM2
* For peripherals without clock specified, attempt to locate enable and
  reset registers in the RCC block matching the peripheral name. This
  could be useful for peripherals where deducing the clock name might
  not be feasible, but it remains to be tested with more chip families
  to see if it is sufficiently accurate.
2021-06-10 09:37:30 +02:00
Ulf Lilleengen
bfa999a2e0 Assume tim2 in macro and remove clock setup in chip specific rcc init
Add temporary start_tim2() fn to Clock to assist macro in starting
embassy clock
2021-05-26 21:42:07 +02:00
Ulf Lilleengen
9a21d74273 Remove debug code 2021-05-26 13:08:55 +02:00
Ulf Lilleengen
c501b162fc Enable clock by default for stm32l0
Modify init function to return a Clock instance defined by a per-chip
SystemClock type and use this in macro setup

A proof of concept implementation for STM32 L0 chips.

This allows using embassy::main macros for STM32 devices that have the
clock setup logic.
2021-05-26 12:33:07 +02:00
Ulf Lilleengen
1c10e746b6 Re-adds embassy macros for stm32
* Hook RCC config into chip config and use chip-specific RCC init
  function
* RTC/clock setup is ignored for now
2021-05-25 13:30:42 +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
cd0d3c4b0d Merge branch 'stm32-neo' 2021-05-17 02:16:17 +02:00
Dario Nieuwenhuis
0310e4d458 Add init fn. Initializes hw and returns Peripherals. 2021-05-17 00:57:37 +02:00
Dario Nieuwenhuis
bfc7f52e6d Remove stm32.
stm32 developemnt continues in the `stm32-neo` branch for now.
2021-05-17 00:57:32 +02:00
Dario Nieuwenhuis
92be72e0e3 Add #[interrupt] macro to register static interrupts. 2021-05-17 00:57:20 +02:00
Dario Nieuwenhuis
bd9589d0ce nrf: add support for nrf52805, nrf52811, nrf52820 2021-05-17 00:57:20 +02:00
Dario Nieuwenhuis
7ef5806168 stm32: codegen interrupts 2021-05-01 03:08:52 +02:00
Dario Nieuwenhuis
71cf742621 Add Priority enums to embassy-extras 2021-05-01 03:08:19 +02:00
Ulf Lilleengen
9586365b07 Pass config directly to chip specific configure function
This removes the need to duplicate the configuration for each individual
chip, but will instead pass on the configuration specified in the config
attribute.

Update nrf, stm32, rp macros with passing the config to a per-chip
configure function which assumes the appropriate configuration to be
passed to it.

To demonstrate this feature, the stm32l0xx clock setup and RTC is added which exposes
clock configuration different from stm32f4xx (and has a different set of timers and HAL APIs).
2021-04-22 09:10:46 +02:00
Dario Nieuwenhuis
97ca54fa66 Rename PeripheralBorrow to Unborrow 2021-04-14 19:59:52 +02:00
Ulf Lilleengen
37b3d8b22c Add embassy_prefix attribute parameter to task and main macros
This allows crates depending on embassy that wants to use a different
module path to do so for the 'task' and 'main' macros, by passing the
parameter 'embassy_prefix'. The prefix defaults to '::', which will
retain the existing behavior.
2021-04-14 11:06:30 +02:00
Ulf Lilleengen
7671605452 Add std version of embassy::main 2021-04-12 14:14:03 +02:00
Dario Nieuwenhuis
02ae53e71b Fix unused import warnings 2021-03-29 21:35:25 +02:00
Dario Nieuwenhuis
2cd3bdc90c rp: add initial version 2021-03-29 21:35:25 +02:00
xoviat
32ca231fe6 stm32: use embassy::main in more places 2021-03-29 09:18:48 -05:00
Dario Nieuwenhuis
d7c3a38efc Reexport macros at root, use eveywhere as #[embassy::task] 2021-03-29 03:00:48 +02:00
Dario Nieuwenhuis
d5ab02792c nrf: add main macro support 2021-03-29 02:51:42 +02:00
Dario Nieuwenhuis
4ce46df160 Code size optimizations. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
d9aaa0edf8 Implement PeripheralBorrow for interrupts. 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