rp-hal-boards/boards
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
..
adafruit-feather-rp2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
adafruit-itsy-bitsy-rp2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
adafruit-kb2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
adafruit-macropad Fix incorrect pin for speaker 2022-07-10 14:29:10 +10:00
adafruit-qt-py-rp2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
adafruit-trinkey-qt2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
arduino_nano_connect BSP fixes (#362) 2022-06-21 16:36:02 +10:00
pimoroni-badger2040 Initial BSP for Pimoroni Badger2040 (#334) 2022-07-11 19:45:44 +10:00
pimoroni-pico-explorer Explorer base improvements (#363) 2022-06-23 19:19:32 +10:00
pimoroni-pico-lipo-16mb BSP fixes (#362) 2022-06-21 16:36:02 +10:00
pimoroni-plasma-2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
pimoroni-tiny2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
rp-pico Implement conversion from Clock to Hertz using reference 2022-07-22 20:17:26 +00:00
seeeduino-xiao-rp2040 Add BSP for Seeeduino XIAO RP2040 (#369) 2022-07-06 20:41:47 +10:00
solderparty-rp2040-stamp BSP fixes (#362) 2022-06-21 16:36:02 +10:00
sparkfun-pro-micro-rp2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00
sparkfun-thing-plus-rp2040 BSP fixes (#362) 2022-06-21 16:36:02 +10:00