Commit Graph

896 Commits

Author SHA1 Message Date
f0ba79059e Add v1c ethernet driver for the STM32F7 family. 2021-11-10 10:16:46 +01:00
5f124ec49f Update U5 to init RCC. 2021-11-08 14:20:51 -05:00
2221e1fa93 Replace rustflags with build.rs extra-link-args.
Rustflags apply to ALL the crates in the graph, while we only need
them for the toplevel crate which is the only one getting linked.

Rustflags are not equal for all crates, this caused cargo to re-build the
same dependency crate multiple times uselessly. After this change, deps
are reused more, making builds faster.

Note that this only applies when sharing the target/ dir for multiple crates
in the repo which is not the default.
2021-11-07 23:52:11 +01:00
9b5d9fbfca Fix v2 ethernet pin definitions. Fix ethernet example for H7 nucleos. 2021-11-04 16:25:30 +01:00
b726ef1886 make SequenceConfig struct is consistent with other Config structs, that are always non_exhaustive and have a Default 2021-11-03 18:37:54 -07:00
d961fd1015 rename to SimplePwm and SequencePwm 2021-11-03 18:25:44 -07:00
44375b427c restore example and add set_time_stretch api 2021-11-03 15:29:09 -07:00
1bf6e646c9 Merge #465
465: Adjust for STM32U5. r=lulf a=bobmcwhirter



Co-authored-by: Bob McWhirter <bmcwhirt@redhat.com>
2021-11-02 20:42:41 +00:00
f9c266bc10 Omg. More formatting. 2021-11-02 16:06:49 -04:00
16c88e3094 Need to include a bit of embassy for the NVIC. 2021-11-02 15:58:40 -04:00
9deafa8bab Remove unused imports. 2021-11-02 15:56:04 -04:00
eaaaa2460a Formatting, per usual. 2021-11-02 14:53:53 -04:00
3ab1775820 Add STM32U5 example. 2021-11-02 14:43:42 -04:00
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