Commit Graph

733 Commits

Author SHA1 Message Date
c939edb8d0 rename error enum again 2021-11-02 10:57:01 -07:00
205a223af3 Update versions of critical-section and atomic-polyfill 2021-11-02 18:52:03 +01:00
f12b70535b Adjust for STM32U5. 2021-11-02 12:05:24 -04:00
4647792ad6 seperate start from pwmseq::new 2021-11-01 20:50:18 -07:00
49253152cf seperate sequence from duty cycle pwm struct 2021-11-01 20:50:14 -07:00
b297e5f7bd led dimming example, dont need to keep all examples, just covering ground to test api 2021-11-01 13:51:40 -07:00
5285179218 generalize new and change pwm example to a servo 2021-11-01 13:08:51 -07:00
12b2c5d5f7 better not as a constructor? 2021-11-01 08:54:07 -07:00
90be851e4b reduce complexity of loopmode 2021-11-01 08:45:07 -07:00
14dc524b84 documentation 2021-11-01 01:20:01 -07:00
78e382c9aa stop->sequence_stop 2021-10-31 23:13:49 -07:00
763e250dfe add ability to configure loop count from 1 to infinite 2021-10-30 16:16:10 -07:00
ef95441442 a runtime generated sin table example 2021-10-29 17:10:37 -07:00
1d1d8a848e simplify api, more interesting example 2021-10-29 16:39:41 -07:00
eb0bf1fd7a simple_playback api from nrf sdk 2021-10-29 16:27:26 -07:00
015cad84dd Initial support for STM32F767ZI. 2021-10-26 17:33:28 +02:00
4d3341dbb9 Fixed examples 2021-10-26 14:47:33 +02:00
11655af034 Another redo using the feedback.
PPI is now split up into PPI and DPPI under the name 'interconnect'.
The tasks and events are tracked and reset in the drop function.
2021-10-26 14:47:12 +02:00
e6ec81b999 Fixed examples and added defmt format to the new error types 2021-10-26 14:46:39 +02:00
65628e1f15 - Added _ppi and _dppi to distinguish between the new and the old peripheral.
- Removed ConfigurableChannel and added capacity numbers to the channels
- Replaced the PPI api with a new one using the DPPI terminology (publish & subscribe)
- Updated all tasks and event registers for DPPI
2021-10-26 14:46:39 +02:00
01e5376b25 Merge #456
456: Fix L4 clock setup for MSI and PLL to allow RNG operation r=Dirbaio a=lulf

Example is tested on STM32L475VG.

Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
2021-10-26 11:59:14 +00:00
f8bd9d2b1c Merge #441
441: Add implementation of async trait for STM32 I2C v2 r=Dirbaio a=lulf

* Add DMA read implementation for I2C v2
* Add example using DMA for I2C

Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
2021-10-26 11:49:45 +00:00
e55726964d Fix clock setup for MSI and PLL to allow RNG opereation
Add RNG example using PLL as clock source.
2021-10-26 13:45:53 +02:00
f3f3858328 Merge #444
444: nrf: add NVMC driver. r=lulf a=Dirbaio

I haven't implemented `embassy_traits::Flash` because I want to change it to match embedded_storage, which is much better designed. 

Either way, NVMC can't do async anyway, so the best we could do is implementing the async trait in a blocking way...

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2021-10-23 08:28:25 +00:00
504655d491 Use upstream version of rust-lorawan 2021-10-22 19:33:15 +02:00
e78d226acd nrf: add NVMC driver. 2021-10-22 02:14:33 +02:00
f8ebc967a9 Add implementation of async trait for STM32 I2C v2
* Add DMA read implementation for I2C v2
* Add example using DMA for I2C
2021-10-21 12:30:02 +02:00
acce0f1d25 Merge #440
440: Add i2c example for L4 r=Dirbaio a=lulf

Tested to work on STM32 IOT01A  (STM32L475VG) board.

Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
2021-10-20 11:34:18 +00:00
9e461b771a Add i2c example for L4 2021-10-20 10:11:34 +02:00
e807a9eaec Specify unit in log output 2021-10-19 15:32:16 +02:00
2ef4a45fa0 Add support for temperature sensor peripheral
* Add TEMP peripheral to all nRF52 chips
* Add async HAL for reading temperature values
* Add example application reading temperature values
2021-10-19 07:18:56 +02:00
a5c11b1a80 Merge #425
425: Implements continuous sampling for the nRF SAADC r=huntc a=huntc

Implements continuous sampling for the nRF SAADC and also renames `OneShot` to `Saadc`. The one-shot behaviour is retained with the `sample` method and a new `run_sampler` method is provided for efficiently (i.e. zero copying) sampler processing. A double buffer is used for continuously sampling, which is swapped appropriately.

A sample frequency is provided and will set the internal timer of the SAADC when there is just one channel being sampled. Otherwise, PPI will be used to hook up the TIMER peripheral to drive the sampling task. Two methods are provided for this: `run_task_sampler` and `run_task_sampler` with the latter available where the compiler sees that just one channel is configured. Note that we set up the PPI and timer behaviour outside of the `Saadc` for maximum flexibility.

A callback is provided to the `run_sampler` method. This is a synchronous callback that should return in a reasonably short space of time. The SAADC could stall if it does not. A reasonable practice is to perform a small amount of processing within the callback to yield a signal, perhaps via `mpsc`. In the case of `mpsc`, the `try_send` method becomes useful.

A new example has been provided to illustrate continuous sampling, along with multiple channels and external timing:

```rust
#[embassy::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
    let config = Config::default();
    let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02);
    let channel_2_config = ChannelConfig::single_ended(&mut p.P0_03);
    let channel_3_config = ChannelConfig::single_ended(&mut p.P0_04);
    let mut saadc = Saadc::new(
        p.SAADC,
        interrupt::take!(SAADC),
        config,
        [channel_1_config, channel_2_config, channel_3_config],
    );

    let mut timer = Timer::new(p.TIMER0);
    timer.set_frequency(Frequency::F1MHz);
    timer.cc(0).write(100); // We want to sample at 10KHz
    timer.cc(0).short_compare_clear();

    let mut ppi = Ppi::new(p.PPI_CH0);
    ppi.set_event(timer.cc(0).event_compare());
    ppi.set_task(saadc.task_sample());
    ppi.enable();

    timer.start();

    let mut bufs = [[[0; 3]; 50]; 2];

    let mut c = 0;
    let mut a: i32 = 0;

    saadc
        .run_task_sampler(&mut bufs, move |buf| {
            for b in buf {
                a += b[0] as i32;
            }
            c += buf.len();
            if c > 10000 {
                a = a / c as i32;
                info!("channel 1: {=i32}", a);
                c = 0;
                a = 0;
            }
            SamplerState::Sampled
        })
        .await;
}
```

Co-authored-by: huntc <huntchr@gmail.com>
2021-10-18 00:51:19 +00:00
d7b768992e examples/std: fix warning 2021-10-18 01:37:35 +02:00
785030df96 Use types to strengthen the buffer dimensioning 2021-10-18 10:26:11 +11:00
cb56f52b99 Removed the Mode enum and factored out into two functions so that we can assert channel limits 2021-10-18 10:26:11 +11:00
fa82913bc3 We have to reduce the buffer size to cater for the number of channels to scan 2021-10-18 10:26:11 +11:00
3be274dc2a We must allow the run handler to mutate state
The handler may well need to close over and mutate state
2021-10-18 10:26:11 +11:00
103a3305e2 Implements continuous sampling for the nRF SAADC
Implements continuous sampling for the nRF SAADC and also renames `OneShot` to `Saadc`. The one-shot behaviour is retained with the `sample` method and a new `run_sampler` method is provided for efficiently (i.e. zero copying) sampler processing. A double buffer is used for continuously sampling, which wlll be swapped once sampling has taken place.

A sample frequency is provided and will set the internal timer of the SAADC when there is just the one channel being sampled. Otherwise, PPI will be used to hook up the TIMER peripheral to drive the sampling task.
2021-10-18 10:26:11 +11:00
f5e251fc81 Update clap 2021-10-18 01:19:01 +02:00
5ae276fe50 Update to newer revision of async lorawan stack 2021-10-11 13:51:00 +02:00
902f566b9a Merge pull request #417 from huntc/extend-saadc
Extend SAADC one shot support
2021-10-11 00:45:49 +02:00
1c4c813255 Merge pull request #410 from lulf/embassy-lora
Add embassy-lora crate
2021-10-10 21:23:02 +02:00
cef6158c31 Extend SAADC one shot support
One-shot mode now permits the sampling of differential pins, and the sampling of multiple pins simultaneously.

A new ChannelConfig structure has been introduced so that multiple channels can be configured individually. Further, the `sample` method now accepts a buffer into which samples are written.

Along the way, I've reset some default configuration to align with Nordic's settings in their nrfx saadc driver. Specifically, the channel gain defaults to 6 (from 4) and the time defaults to 10us (from 20us).
2021-10-09 11:25:18 +11:00
0e05ba688d nrf/saadc: remove Sample trait. 2021-10-07 02:10:22 +02:00
16a47a0ad9 Add embassy-lora crate
This crate contains async radio drivers for various lora drivers that
work with embassy timers. The code is imported from Drogue Device (
https://github.com/drogue-iot/drogue-device)

The radio drivers integrate with the async LoRaWAN MAC layer in the
lorawan-device crate.

Also added is an example for the STM32WL55 and for STM32L0 (requires
the LoRa Discovery board) for LoRaWAN. Future work is to make the
underlying radio drivers using fully async SPI when communicating
with the peripheral.
2021-09-30 10:32:24 +02:00
bce909ec1e Initial STM32F1 family support with two examples for STM32F103C8 (Blue Pill) 2021-09-28 18:31:04 +02:00
c79485c286 Support for STM32L1
* Add RCC
* Fix more issues with dash in chip names
* Update stm32-data version
* Add blinky and spi example
2021-09-21 14:50:23 +02:00
99a94f1d50 Update version of critical-section 2021-09-13 17:05:17 +02:00
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
70e5877d68 embassy/channel: switch to use MutexKind 2021-09-13 00:08:41 +02:00