Commit Graph

703 Commits

Author SHA1 Message Date
37598a5b37 wip: experimental async usb stack 2022-04-06 05:38:11 +02:00
aee19185b7 Add more docserver metadata. 2022-04-05 21:05:09 +02:00
490d4588ea nrf: nrf52832 doesn't have SPI3 2022-03-22 19:33:35 +01:00
6d994351a6 nrf/gpio: Make Input is_high/is_low public. 2022-03-17 23:27:55 +01:00
9bad9365dc Update rust nightly, embedded-hal 1.0, embedded-hal-async. 2022-03-11 00:38:07 +01:00
13247897b0 Merge #640
640: Skip EasyDMA slice location check for empty slices and copy data if necessary r=Dirbaio a=TilBlechschmidt

As discussed, this PR makes the following changes:
- Ignore pointer location of zero-length slices (fixes #631)
- Change default functions so they copy the tx buffer if it does not reside in RAM
- Introduce new variants for `write`, `transfer`, and their blocking versions which fails instead of copying
- Add documentation about the motivation behind all these variants
<img width="984" alt="image" src="https://user-images.githubusercontent.com/5037967/155415788-c2cd1055-9289-4004-959d-be3b1934a439.png">


Remaining TODOs:

- [x] Change copying behaviour for other peripherals
    - [x] TWI
    - [x] UART
- [x] Add module-level documentation regarding EasyDMA and `_from_ram` method variants

`@Dirbaio` it probably makes sense for you to review it now before I "copy" over the changes to the other two peripherals.

Co-authored-by: Til Blechschmidt <til@blechschmidt.de>
2022-03-09 01:47:52 +00:00
63030bf998 Move EasyDMA documentation to module level 2022-03-08 17:49:15 +01:00
7540b44050 Fix inverted boolean condition 2022-03-08 16:29:42 +01:00
3990f09b29 Simplifies the API by taking in the TIMER and PPI channels 2022-03-07 14:51:17 +11:00
98bdac51fe Improve nRF Saadc sampling
Starting the sampling task prior to starting the SAADC peripheral can lead to unexpected buffer behaviour with multiple channels. We now provide an init callback at the point where the SAADC has started for the first time. This callback can be used to kick off sampling via PPI.

We also need to trigger the SAADC to start sampling the next buffer when the previous one is ended so that we do not drop samples - the major benefit of double buffering.

As a bonus we provide a calibrate method as it is recommended to use before starting up the sampling.

The example has been updated to illustrate these new features.
2022-03-07 14:51:17 +11:00
44096358a2 docs: add metadata.embassy_docs to cargo tomls. 2022-03-04 18:03:41 +01:00
94b232cf88 docs: prevent inline doc spam for reexports. 2022-03-04 18:03:41 +01:00
993428e2d4 Refactor _from_ram methods to use more readable copy operation 2022-03-02 22:48:58 +01:00
3f2d9cfe0a Change TWIM methods to copy slice if required and add non-copying variants 2022-03-02 22:45:38 +01:00
2c402ecf16 Change UARTE methods to copy slice if required and add non-copying variants 2022-03-02 22:40:40 +01:00
62407da29b Fix EasyDMA slice copying not actually copying data 2022-02-23 23:38:18 +01:00
6dc58645d2 Change slice length check to use stable method 2022-02-23 23:30:50 +01:00
66fdec7abe Add defmt log outputs for SPIM memcpy 2022-02-23 23:27:12 +01:00
e96dd3654a Change SPIM methods to copy slice if required and add non-copying variants 2022-02-23 22:51:59 +01:00
ed9fad8c7e Skip EasyDMA slice location check if slice is empty 2022-02-23 22:51:01 +01:00
fdb6e66b4b time: better docs explaining overflow handling. 2022-02-23 05:16:30 +01:00
2e8f39ffdd Update nRF PACs 2022-02-15 16:35:54 +01:00
f2eb438905 Merge #615
615: rp: remove OptionalPin r=Dirbaio a=Dirbaio

Mirror of https://github.com/embassy-rs/embassy/pull/605 for rp2040

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-02-12 00:46:40 +00:00
49eb2f769e nrf: remove stray mention of OptionalPin 2022-02-12 01:33:56 +01:00
e728a32672 Merge #613
613: Rust stable support r=Dirbaio a=Dirbaio

This PR adds (limited) stable Rust support!

The drawbacks are: 

- No `#[embassy::task]`, `#[embassy::main]`. (requires `type_alias_impl_trait`). You have to manually allocate the tasks somewhere they'll live forever. See [example](https://github.com/embassy-rs/embassy/blob/master/examples/nrf/src/bin/raw_spawn.rs)
- No async trait impls (requires GATs). Note that the full API surface of HALs is still available through inherent methods: #552 #581 
- Some stuff is not constructible in const (requires `const_fn_trait_bound`), although there's an (ugly) workaround for the generic `Mutex`.

So it's not that bad in the end, it's fully usable for shipping production-ready firmwares. We'll still recommend nightly as the default, until GATs and `type_alias_impl_trait` are stable.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-02-12 00:30:47 +00:00
20e14b8edb embassy, embassy-nrf: add nightly Cargo feature to gate nightly-only features. 2022-02-12 01:16:31 +01:00
6c925b2342 blocking_mutex: refactor to work on stable. No GATs, and can be constructed in const. 2022-02-12 01:16:31 +01:00
6de02bb23e nrf: remove OptionalPin 2022-02-12 01:07:02 +01:00
f79624c3e6 Upgrade to embedded-storage 0.3.0 2022-02-07 12:35:58 +01:00
a1d6077446 Merge #591
591: PWM WS2812B example and flexible sequence config r=Dirbaio a=huntc

I've permitted the PWM sequences to be mutated on stopping the PWM by associating them with a new  `SingleSequencer` structure. This is so that we can perform effects on the LEDs (and other use-cases, I'm sure!). The example has been updated to illustrate the use of this by flashing a WS2812B LED.

There's also a `Sequencer` structure for more sophisticated PWM interactions, along with a `pwm_double_sequence`  example to illustrate.

These changes should make it possible to attain all of the nRF PWM functionality available.

Co-authored-by: huntc <huntchr@gmail.com>
2022-02-05 02:20:13 +00:00
df5ba727f2 Further API simplification for the single seq scenario 2022-02-05 08:05:23 +11:00
3b2beddc7a Forgot to expose the stop method 2022-02-04 19:14:24 +11:00
965a5f2c3f Introduced the SingleSequencer and a more complex Sequencer 2022-02-04 19:11:15 +11:00
fe5501293f Expose PWM 2022-02-04 16:26:23 +11:00
25be00878c Doco correction 2022-02-04 15:55:04 +11:00
1af6b23f97 Introduces a Sequences struct 2022-02-04 13:04:55 +11:00
bc7266394d Clarify why we need the mut buffer 2022-02-04 11:48:08 +11:00
986295998a Some more doco 2022-01-30 16:26:09 +11:00
1c67bd4643 Revert "Own the sequence buffer"
This reverts commit 482389a691.
2022-01-30 16:21:23 +11:00
482389a691 Own the sequence buffer
This approach owns the sequence buffers which, while introducing an extra move, it eliminates the need to guard the lifetime of the sequence buffer. Given ownership, the buffer will be retained until the PWM sequence task is stopped.
2022-01-29 18:01:06 +11:00
9ac52a768b Now permits sequences to be mutated subsequently 2022-01-28 16:32:58 +11:00
8e9f448866 Doc tidying 2022-01-28 13:43:36 +11:00
12ce024574 Make the sequence a little nicer to pass around 2022-01-28 13:38:20 +11:00
47aeab152f PWM WS2812B example and per sequence config
Demonstrates how to set the colour of a WS2812B to blue using PWM, and the use of multiple sequences along with their own config. This required an API change.
2022-01-28 11:20:04 +11:00
0719b05d63 traits: migrate Delay to embedded-hal 1.0+async, remove Rng and Flash. 2022-01-27 00:08:02 +01:00
c9f29534d6 Stop PWM before assigning the new sequence
I had introduced a small bug in my last PR where I assigned the sequence before stopping the PWM. I now stop the PWM before doing that now.

Also, corrected a math comment.
2022-01-25 16:51:24 +11:00
48afef28a0 Strengthen the borrow
The start method is now safe. Because it has the potential of borrowing the sequence and mutating itself, the sequence must outlive the Pwm struct.
2022-01-24 17:22:35 +11:00
7598b8a40f Permit many sequences to be passed
Sequences are now passed in via the start method to avoid having to stop the PWM and restart it. Sequences continue to be constrained with the same lifetime of the Pwm object itself. The pwm_sequence example has been extended to illustrate multiple sequences being passed around.
2022-01-23 16:29:52 +11:00
b640c72092 nrf: return ptr in slice_ptr_parts 2022-01-19 17:31:32 +01:00
7997687f3b nrf: impl embedded-hal 1.0 and embedded-hal-async traits. 2022-01-13 23:56:39 +01:00