Commit Graph

684 Commits

Author SHA1 Message Date
1d2f97b4e2 Fixed erase bug 2022-12-09 11:02:16 +01:00
58ab829049 Merge #1049
1049: embassy-nrf: Add I2S module r=lulf a=chris-zen

This PR adds I2S support for the nrf52 series (`nrf52832`, `nrf52833`, `nrf52840`).

We could only test it in a `nrf52840` in master mode for an output stream (see `i2s_waveform` example), using a clone of the [Adafruit I2S Stereo Decoder - UDA1334A](https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a/overview).

We were wondering if this could be a welcome addition to embassy, as we are working on this very informally and don't have much free time for it.

<img src="https://user-images.githubusercontent.com/932644/202316127-a8cf90ef-1e1a-4e1d-b796-961b8ad6cef5.png" width="600">

https://user-images.githubusercontent.com/932644/202316609-e53cd912-e463-4e01-839e-0bbdf37020da.mp4


Co-authored-by: `@brainstorm` <brainstorm@nopcode.org>

Co-authored-by: Christian Perez Llamas <932644+chris-zen@users.noreply.github.com>
Co-authored-by: Roman Valls Guimera <brainstorm@users.noreply.github.com>
2022-12-09 07:49:40 +00:00
5fdd521a76 Move the responsibility to manage buffers to the I2S stream 2022-12-08 20:22:50 +01:00
199504be56 Optimization to be able to work with only 2 buffers 2022-11-29 01:09:47 +01:00
6b8ab32536 Use &mut self for start methods 2022-11-26 15:22:31 +01:00
1e2fb0459d Switch to async-fn-in-trait 2022-11-25 21:02:06 +01:00
b76631bebe Merge #1069
1069: GPIOTE InputChannel with mutable reference. r=Dirbaio a=Ardelean-Calin

Adding these changes enables us to define a channel using a mutable reference to `GPIOTE_CH(n)`, similar to how we can do with other drivers. So instead of using:
```rust
let p = embassy_nrf::init(config);
let freq_in = InputChannel::new(
    p.GPIOTE_CH0,
    Input::new(&mut p.P0_19, embassy_nrf::gpio::Pull::Up),
    embassy_nrf::gpiote::InputChannelPolarity::HiToLo,
);
```
we can use:
```rust
let p = embassy_nrf::init(config);
let freq_in = InputChannel::new(
    &mut p.GPIOTE_CH0,
    Input::new(&mut p.P0_19, embassy_nrf::gpio::Pull::Up),
    embassy_nrf::gpiote::InputChannelPolarity::HiToLo,
);
```
therefore not giving ownership to GPIOTE_CH0.

Co-authored-by: Ardelean Călin Petru <ardelean.calin@outlook.com>
Co-authored-by: Ardelean Calin <ardelean.calin@proton.me>
2022-11-23 12:17:02 +00:00
eae67d0be8 Review comments. Corrected unused fields. 2022-11-23 14:16:18 +02:00
83b199a874 Merge #1056
1056: embassy-nrf: Add TWIS module r=Dirbaio a=kalkyl

Verified to be working on nrf9160

Co-authored-by: kalkyl <henrik.alser@me.com>
Co-authored-by: Henrik Alsér <henrik.alser@me.com>
2022-11-22 21:50:42 +00:00
cf900a8a3f Rename write to respond_to_read 2022-11-22 22:10:04 +01:00
4f2f375777 Corrected order of use statements. 2022-11-22 17:45:05 +02:00
e7c876d744 Changed pin to private as it is for OutputChannel 2022-11-22 17:36:22 +02:00
64c2e1b9b6 Switched to PeripheralRef for channel. 2022-11-22 17:35:38 +02:00
a074cd0625 Update gpiote.rs
Adding these changes enables us to define a channel using a mutable reference to `GPIOTE_CH(n)`, similar to how we can do with other drivers.
So instead of using:
```rust
let freq_in = InputChannel::new(
    p.GPIOTE_CH0,
    Input::new(&mut p.P0_19, embassy_nrf::gpio::Pull::Up),
    embassy_nrf::gpiote::InputChannelPolarity::HiToLo,
);
```
we can use:
```rust
let freq_in = InputChannel::new(
    &mut p.GPIOTE_CH0,
    Input::new(&mut p.P0_19, embassy_nrf::gpio::Pull::Up),
    embassy_nrf::gpiote::InputChannelPolarity::HiToLo,
);
```
2022-11-22 16:56:04 +02:00
97cb95bbf4 Merge #1042
1042: embassy-nrf: Add SPIS module r=Dirbaio a=kalkyl

Verified to be working on nrf9160

Co-authored-by: Henrik Alsér <henrik.alser@me.com>
Co-authored-by: Henrik Alsér <henrik.alser@ucsmindbite.se>
Co-authored-by: kalkyl <henrik.alser@me.com>
2022-11-22 11:20:14 +00:00
f09745dfe1 embassy-nrf: Default disable UARTE (nrf9160) 2022-11-22 02:21:06 +01:00
da9f82f507 Fix pin refs 2022-11-22 02:13:03 +01:00
633ffe46ae config write, docs, add address_match_index 2022-11-22 01:57:00 +01:00
e6b9722a31 Remove nrf9160 UARTE fix 2022-11-22 01:07:59 +01:00
33ee48b9e8 Merge branch 'spis' of github.com:kalkyl/embassy into spis 2022-11-22 00:55:46 +01:00
a6d941fac3 Fix txonly/rxonly data pin dir, _from_ram and doc 2022-11-22 00:55:05 +01:00
15a93246d6 Buffer management in line with other peripherals. Constructor and config redesign 2022-11-19 19:18:20 +01:00
f5391efe22 Fix fmt 2022-11-19 02:17:58 +01:00
64e8cfef8e Fix build 2022-11-19 01:38:03 +01:00
6b88057aef Add missing parts and Cleanup 2022-11-19 00:29:05 +01:00
1ed260b105 Fix buffer overruns 2022-11-17 00:19:22 +01:00
0b066b22d1 Check events_acquired 2022-11-14 16:24:21 +01:00
3a1ddd66c6 Cleanup interrupts 2022-11-14 16:18:11 +01:00
8d2d5a30a5 Single waker 2022-11-14 11:39:55 +01:00
43c1afb6a6 Return number of bytes written, add address match getter 2022-11-14 11:22:14 +01:00
eba42cb5f4 embassy-nrf: Add TWIS module 2022-11-13 22:15:19 +01:00
5cfad3f853 Feature gate UARTE disable 2022-11-13 02:37:23 +01:00
17857bc18f Minor changes 2022-11-13 02:12:58 +01:00
dca11095e2 Disable UARTE in embassy-nrf::init 2022-11-13 01:49:55 +01:00
d2e8794f29 Investigating discontinuities in the signal 2022-11-13 01:41:32 +01:00
122a31d208 Interrupts, async, sine oscillator 2022-11-12 18:48:57 +01:00
10e3c3f2ec Cargo fmt 2022-11-11 23:49:20 +01:00
4a2e810485 Restrict to pacs supporting i2s 2022-11-10 23:13:01 +01:00
dbe97b4098 Adapted nvmc so it can be used for all nrf targets 2022-11-10 14:37:42 +01:00
f22f36f51b Add input rx 2022-11-10 00:24:49 +01:00
5a64bf651c Buffer trait. Simpler config. 2022-11-10 00:10:42 +01:00
356beabc3b Apply config 2022-11-09 23:08:09 +01:00
3760b60db3 Make bors grin ;) 2022-11-09 22:31:19 +01:00
cecd77938c Draft: Initial support for I2S with a working example.
Co-authored-by: @brainstorm <brainstorm@nopcode.org>
2022-11-09 19:19:01 +01:00
aecfce1159 rustfmt 2022-11-05 01:36:29 +01:00
207fa19551 Acquire semaphore on blocking 2022-11-05 01:34:52 +01:00
7da18e194a Add status checks 2022-11-05 01:12:25 +01:00
a3e8a6bc3a rustfmt 2022-11-05 00:19:52 +01:00
1920e90dcd embassy-nrf: Add SPIS module 2022-11-05 00:15:43 +01:00
e5097a8866 Merge #959
959: Generic, executor-agnostic queue implementation r=ivmarkov a=ivmarkov

Hopefully relatively well documented.

Implementation relies on a fixed-size `SortedLinkedList` from `heapless`. (By default, for up to 128 timer schedules, but we can lower this number to - say - 64.)

As discussed earlier, on queue overflow, the `WakerRegistration` approach is utilized, whereas the waker that is ordered first in the queue is awoken to make room for the incoming one (which might be the waker that would be awoken after all!). Wakers are compared with `Waker::will_wake`, so the queue should actually not fill up that easily, if at all.

I've left provisions for the user to manually instantiate the queue using a dedicated macro - `generic_queue!` so that users willing to adjust the queue size, or users (like me) who have to use the queue in a complex "on-top-of-RTOS-but-the-timer-driver-calling-back-from-ISR" scenario can customize the mutex that protects the queue.

The one thing I'm not completely happy with is the need to call `{ embassy_time::queue::initialize() }` early on before any futures using embassy-time are polled, which is currently on the shoulders of the user. I'm open to any ideas where we can get rid of this and do it on the first call to `_embassy_time_schedule_wake`, without introducing very complex combinations of critical sections, atomics and whatnot.




Co-authored-by: ivmarkov <ivan.markov@gmail.com>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-10-26 19:14:12 +00:00