Commit graph

18 commits

Author SHA1 Message Date
Wilfried Chauveau
93ec18be07 migrate rp2040-hal from embedded_time to fugit 2022-08-24 22:46:34 +01:00
Jan Niehusmann
f8984a9eac Implement conversion from Clock to Hertz using reference
Implementing `impl From<SystemClock> for Hertz` is a footgun, as
SystemClock is not Copy, so the automatic conversion consumes the
owned clock.

This is visible in the example i2c.rs:

```
    let mut i2c = hal::I2C::i2c1(
        pac.I2C1,
        sda_pin,
        scl_pin, // Try `not_an_scl_pin` here
        400.kHz(),
        &mut pac.RESETS,
        clocks.peripheral_clock,
    );
```

If the user wants to use both `i2c0` and `i2c1` at the same time,
copying from this example won't work:

```
error[E0382]: use of moved value: `clocks.peripheral_clock`
   --> rp2040-hal/examples/i2c.rs:106:9
    |
97  |         clocks.peripheral_clock,
    |         ----------------------- value moved here
...
106 |         clocks.peripheral_clock,
    |         ^^^^^^^^^^^^^^^^^^^^^^^ value used here after move
    |
    = note: move occurs because `clocks.peripheral_clock` has type
`PeripheralClock`, which does not implement the `Copy` trait
```

As getting the frequency from a clock doesn't really need ownership,
changing it to `impl From<&SystemClock> for Hertz` is both more
logical and provides better usability.

This is, however, a breaking change: Code relying on this trait
implementation needs to be changed by adding a `&`.
2022-07-22 20:17:26 +00:00
Jan Niehusmann
f67b650bb3
Remove some unused fields from UartPeripheral and Reader (#315)
* Remove unused field `effective_baudrate` from uart code

* Remove unused field `config` from uart code
2022-03-18 20:57:45 +11:00
Marius Meißner
990085948a
Using thread send safe UART* marker, as suggested by @danielzfranklin in #Issue-284 (#314) 2022-03-18 20:56:27 +11:00
Jan Niehusmann
7750781650
Implement embedded-hal 1.0.0-alpha.7 traits (#298)
* embedded-hal v1.0.0-alpha.7 removed several traits

* bump dependency to embedded-hal 1.0.0-alpha.7

* Mention embedded-hal alpha changes in changelog
2022-02-26 21:06:55 +11:00
Victor Koenders
d6e3c7b615
Set the uart config default baud rate to 115200 2022-01-18 17:28:13 +01:00
Victor Koenders
b3b4d9ff6f
Fixed doc test 2022-01-18 11:32:48 +01:00
Victor Koenders
9e75cec551
Added impl Default for UartConfig 2022-01-18 11:17:01 +01:00
Jonathan Pallant
67d9da85e6 Fix docs for SerialInfallible. 2021-12-26 20:57:04 +00:00
Jonathan Pallant
55acbdb1b0 Fix build errors in eh_1.0 mode. 2021-12-26 20:56:48 +00:00
Jonathan Pallant (Ferrous Systems)
d3bd232885 Added two UART IRQ examples.
They are in the pico BSP as they need the 'rt' feature. Also includes
changes to the UART driver for enabling/disabling interrupts.
2021-12-26 19:33:23 +00:00
Victor Koenders
8f63be0f22
Fixed failing doctest 2021-12-25 09:49:32 +01:00
Victor Koenders
86444448a4
Migrated examples to the new uart system 2021-12-25 09:46:40 +01:00
Victor Koenders
c41c273131
Added reader/writer split to UartPeripheral 2021-12-25 09:46:38 +01:00
Victor Koenders
84b8fb05b0
Fixed compile errors on eh1_0_alpha feature 2021-12-25 09:46:34 +01:00
Victor Koenders
a8a27672b8
Constraint the uart::pin:: traits to UartDevice 2021-12-25 09:45:57 +01:00
Victor Koenders
a4a0bcf987
Added pins to the uart constructor functions 2021-12-25 09:45:54 +01:00
Victor Koenders
bdfb4d82c9
Split uart in separate files, introduced a typesystem constraint for valid UART pin configurations 2021-12-25 09:45:45 +01:00