aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge #613bors[bot]2022-02-122-6/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * blocking_mutex: refactor to work on stable. No GATs, and can be constructed ↵Dario Nieuwenhuis2022-02-122-6/+6
| | | | | | | | in const.
* | nrf: remove OptionalPinDario Nieuwenhuis2022-02-129-25/+10
|/
* Further API simplification for the single seq scenariohuntc2022-02-053-9/+6
|
* Removed unrequired clonehuntc2022-02-041-1/+1
|
* Introduced the SingleSequencer and a more complex Sequencerhuntc2022-02-044-27/+62
|
* Small correction to timeshuntc2022-02-041-1/+1
|
* Revert the use of foreverhuntc2022-02-041-7/+2
|
* Update another examplehuntc2022-02-041-13/+14
|
* Expose PWMhuntc2022-02-042-11/+17
|
* Introduces a Sequences structhuntc2022-02-041-21/+18
|
* Some more docohuntc2022-01-301-2/+2
|
* Revert "Own the sequence buffer"huntc2022-01-303-32/+36
| | | | This reverts commit 482389a6911d8d3505872e6ad03d5b0af565eaf9.
* Own the sequence bufferhuntc2022-01-293-36/+32
| | | | 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.
* Now permits sequences to be mutated subsequentlyhuntc2022-01-283-14/+41
|
* Make the sequence a little nicer to pass aroundhuntc2022-01-283-27/+23
|
* PWM WS2812B example and per sequence confighuntc2022-01-283-9/+83
| | | | 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.
* Stop PWM before assigning the new sequencehuntc2022-01-252-2/+2
| | | | | | 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.
* Strengthen the borrowhuntc2022-01-242-2/+2
| | | | 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.
* Permit many sequences to be passedhuntc2022-01-232-17/+11
| | | | 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.
* nrf/rng: expose all functionality as inherent methods.Dario Nieuwenhuis2022-01-131-4/+2
|
* nrf/qspi: expose all functionality as inherent methods.Dario Nieuwenhuis2022-01-132-2/+0
|
* nrf/uarte: expose all functionality as inherent methods.Dario Nieuwenhuis2022-01-133-13/+7
|
* nrf/gpiote: expose all functionality as inherent methods.Dario Nieuwenhuis2022-01-132-2/+0
|
* nrf/twim: expose all functionality as inherent methods.Dario Nieuwenhuis2022-01-132-2/+2
|
* nrf/spim: expose all functionality as inherent methods.Dario Nieuwenhuis2022-01-131-5/+4
|
* Remove unsafe from new on RNDhuntc2022-01-061-1/+1
| | | | Unsafe is not required here given that all futures are required to live longer than their global peripheral instances. There are other occurrences of unsafe being used on new that should be removed. I started to do that but then went down a bit of a rabbit hole.
* Merge #539bors[bot]2022-01-042-0/+161
|\ | | | | | | | | | | | | | | | | | | 539: nrf: async usb r=Dirbaio a=jacobrosenthal Frankensteined together from this old pr https://github.com/embassy-rs/embassy/pull/115 and nrf-usdb ~Doesnt currently work..~ Co-authored-by: Jacob Rosenthal <[email protected]>
| * example cleanupJacob Rosenthal2021-12-162-5/+2
| |
| * usb_uart_io example equivilent to usb_uartJacob Rosenthal2021-12-161-0/+70
| |
| * simplify usb_uart exampleJacob Rosenthal2021-12-161-30/+30
| |
| * cleanup exampleJacob Rosenthal2021-12-151-23/+25
| |
| * enable USB peripheral for relevant chipsJacob Rosenthal2021-12-151-2/+2
| |
| * rename to UsbBusJacob Rosenthal2021-12-151-2/+2
| |
| * sorta works, too many interupts?Jacob Rosenthal2021-12-141-3/+3
| |
| * dont expose embedded_hal_common::usbJacob Rosenthal2021-12-141-6/+2
| |
| * revertJacob Rosenthal2021-12-141-2/+4
| |
| * make send, consolidate usb typesJacob Rosenthal2021-12-131-4/+2
| |
| * stub out the embassy registers for usbdJacob Rosenthal2021-12-131-2/+4
| |
| * usb feature gateJacob Rosenthal2021-12-121-1/+1
| |
| * nrf-usbdJacob Rosenthal2021-12-121-0/+94
| |
* | nrf/gpio: add infallible inherent methods, remove some duplication.Dario Nieuwenhuis2021-12-203-16/+12
| | | | | | | | This implements Input and Output using FlexPin, to avoid some code duplication.
* | Merge #544bors[bot]2021-12-161-0/+68
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 544: Introduces split on the nRF Uarte r=Dirbaio a=huntc A new `split` method is introduced such that the Uarte tx and rx can be used from separate tasks. An MPSC is used in an example to illustrate how data may be passed between these tasks. The approach taken within the `Uarte` struct is to split into tx and rx fields on calling `Uarte::new`. These fields are returned given a call to `Uarte::split`, but otherwise, if that call isn't made, then the API remains as it was before. Here's a snippet from a new example introduced: ```rust #[embassy::main] async fn main(spawner: Spawner, p: Peripherals) { // ... let uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config); let (mut tx, rx) = uart.split(); // ... // Spawn a task responsible purely for reading unwrap!(spawner.spawn(reader(rx, s))); // ... // Continue reading in this main task and write // back out the buffer we receive from the read // task. loop { if let Some(buf) = r.recv().await { info!("writing..."); unwrap!(tx.write(&buf).await); } } } #[embassy::task] async fn reader(mut rx: UarteRx<'static, UARTE0>, s: Sender<'static, Noop, [u8; 8], 1>) { let mut buf = [0; 8]; loop { info!("reading..."); unwrap!(rx.read(&mut buf).await); unwrap!(s.send(buf).await); } } ``` Co-authored-by: huntc <[email protected]>
| * | Introduces split on the nRF Uartehuntc2021-12-151-0/+68
| | | | | | | | | | | | A new `split` method is introduced such that the Uarte tx and rx can be used from separate tasks. An MPSC is used to illustrate how data may be passed between these tasks.
* | | Merge #542bors[bot]2021-12-142-8/+6
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 542: nrf/gpiote: remove PortInput, move impls to Input/FlexPin. r=Dirbaio a=Dirbaio `PortInput` is just a dumb wrapper around `Input`, it has no reason whatsoever to exist. This PR moves the `wait_for_x` functionality to `Input` directly. It also adds it to `FlexPin` for completeness and consistency with `Input`. (The reason `PortInput` exists is a while ago `GPIOTE` was an owned singleton that you had to initialize, so `PortInput::new()` would require it to enforce it's been initialized. This doesn't apply anymore now that GPIOTE is "global") Co-authored-by: Dario Nieuwenhuis <[email protected]>
| * | nrf/gpiote: remove PortInput, move impls to Input.Dario Nieuwenhuis2021-12-142-8/+6
| | |
| * | Revert blinky changes for nowUlf Lilleengen2021-12-101-11/+8
| | |
| * | More contentUlf Lilleengen2021-12-101-8/+11
| | |
* | | Documents the nRF BufferedUarte problemhuntc2021-12-121-3/+3
| |/ |/| | | | | Please see https://github.com/embassy-rs/embassy/issues/536 for the rationale.
* | Provides AsyncWrite with flushhuntc2021-12-101-0/+3
|/ | | | As per Tokio and others, this commit provides a `poll_flush` method on `AsyncWrite` so that a best-effort attempt at wakening once all bytes are flushed can be made.