Commit graph

9 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
9names 895bae90b5
Merge pull request #324 from 9names/bsp_use_hal_entry_macro
Add reexport of rp2040::entry to BSPs
2022-05-31 23:41:45 +10:00
mqy 623457a498 fixed typos 2022-04-30 12:51:45 +10:00
9names 12cbab967c Update all BSP examples to use the BSP's re-exported entry macro 2022-04-10 21:54:56 +10:00
Weird Constructor 3f9535cc1f Cleaned up the code and made it more idiomatic. 2022-01-12 21:48:22 +01:00
Weird Constructor e22540be20 Mention the assumed display size of 128x64. 2022-01-12 19:28:51 +01:00
Weird Constructor 2f1e77d0b2 Added documentation for the OLED example and fixed formatting. 2022-01-12 19:25:06 +01:00
Weird Constructor 2f418bbf8f Add an example for using the SSD1306 I2C display driver crate with the Raspberry Pi Pico 2022-01-12 19:25:06 +01:00