aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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.
* | traits: migrate Delay to embedded-hal 1.0+async, remove Rng and Flash.Dario Nieuwenhuis2022-01-271-1/+0
|/
* 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: impl embedded-hal 1.0 and embedded-hal-async traits.Dario Nieuwenhuis2022-01-131-1/+0
|
* 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-043-0/+164
|\ | | | | | | | | | | | | | | | | | | 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
| |
| * dont rely on nrf-usdbJacob Rosenthal2021-12-141-1/+0
| |
| * sorta works, too many interupts?Jacob Rosenthal2021-12-142-4/+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-122-0/+99
| |
* | 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.
* Removed unsafe from uartehuntc2021-12-012-19/+16
| | | | The constructors themselves are not strictly unsafe. Interactions with DMA can be generally unsafe if a future is dropped, but that's a separate issue. It is important that we use the `unsafe` keyword diligently as it can lead to confusion otherwise.
* Merge #486bors[bot]2021-11-261-0/+73
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 486: Pwm ppi events r=Dirbaio a=jacobrosenthal More PWM yak shaving. I was going to do some safe pwm ppi events stuff but I just dont think it fits this api design.. ppi is just very low level, im not sure how safe it will be in general * first we should probably have borrows of handlers for ppi with lifetime of the peripheral? hal does https://github.com/nrf-rs/nrf-hal/blob/eb4ba6ae4204c7f58fc968e57b2995df15f5ac77/nrf-hal-common/src/pwm.rs#L714-L716 * in general having access to tasks can put the state in some configuration the api doesnt understand anymore. for `SequencePwm` ideally id hand you back either only seq_start0 or seq_start1 because youd only use one based on if your `Times` is even or odd.. but again we only know that with this api AFTER start has been called. I dont think were ready for typestates SO I figured why not add the pwm ppi events but make them unsafe and commit this example since I started it. Somewhat related drop IS removing the last duty cycle from the pin correctly, but stop DOES NOT..the only thing that sets the pin back is pin.conf() as far as I can tell, so I tried to document that better and got rid of stop for the `SimplePwm` again since that doesnt need it then. However its ackward we dont have a way to unset the pwm without setting a new sequence of 0s, or dropping the peripheral Co-authored-by: Jacob Rosenthal <[email protected]>
| * nrf: sequencepwm add eventsJacob Rosenthal2021-11-131-0/+73
| |
* | Fix interrupt_take macro by specifying path to panic macro.Matous Hybl2021-11-2313-13/+4
| |
* | Remove unused depsDario Nieuwenhuis2021-11-151-2/+2
| |
* | Remove extraneous defmt-trace feature.Bob McWhirter2021-11-151-1/+1
| |
* | Adjust all examples to defmt 0.3.Bob McWhirter2021-11-151-15/+4
|/
* pwm_sequence show implicit and explicit stop functionalityJacob Rosenthal2021-11-111-3/+6
|
* pwm_servo example comment for clarityJacob Rosenthal2021-11-111-0/+1
|
* nrf: dump the pwm_sequence example for clarityJacob Rosenthal2021-11-112-129/+9
| | | | It is basically impossible to directly convert that example to a sequence for various reasons. You cant have multiple channels on same buffer with one sequence instance for starters, also at that clock rate and max_duty 1 period is far longer than the 3ms it was using, which would require using a new max_duty and thus require regenerating the sine table which makes it not representitive of the original example anymore