rp-hal-boards/rp2040-hal/src
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
..
clocks Implement conversion from Clock to Hertz using reference 2022-07-22 20:17:26 +00:00
float Use direct assembler calls for the divider 2022-04-12 10:17:44 -06:00
gpio Fix unmatched parens in bsp_pins doc macro 2022-06-28 22:00:58 +10:00
i2c Remove unmaintained implementation async i2c. 2022-04-30 11:46:30 +10:00
pwm Implement embedded-hal 1.0.0-alpha.7 traits (#298) 2022-02-26 21:06:55 +11:00
rtc Added RtcClock DateTime and alarms (#213) 2021-11-29 21:15:20 +11:00
uart Implement conversion from Clock to Hertz using reference 2022-07-22 20:17:26 +00:00
adc.rs Implement embedded-hal 1.0.0-alpha.8 traits (#366) 2022-06-24 08:19:41 +10:00
atomic_register_access.rs Use volatile register access for gpio interrupts (#170) 2021-10-22 23:30:30 +11:00
critical_section_impl.rs Clean up critical-section impl. 2022-01-30 16:07:40 +00:00
dma.rs Resolve review comments. 2021-11-16 21:45:52 +00:00
i2c.rs Add missing GPIO I2C trait implmentations (#344) 2022-05-25 09:03:29 +10:00
intrinsics.rs Use ignore instead of text (#378) 2022-07-08 20:58:09 +10:00
lib.rs Remove unmaintained implementation async i2c. 2022-04-30 11:46:30 +10:00
multicore.rs Add a fence after writing the arguments to the stack 2022-06-01 17:33:37 +10:00
pio.rs Fix PIO rx fifo status (#367) 2022-06-24 08:24:27 +10:00
pll.rs Update embedded time 2021-07-27 09:41:03 +10:00
prelude.rs pio: Improve documentation and add an example that uses pio_proc::pio!(). 2021-09-28 21:48:05 +02:00
resets.rs Spi (#50) 2021-07-06 09:42:05 +10:00
rom_data.rs Add basic ROM intrinsics 2022-02-12 11:56:24 -07:00
rosc.rs Implement RngCore for RingOscillator (#135) 2021-09-26 20:51:01 +10:00
sio.rs Provide an unsafe function for resetting all spinlocks 2022-04-30 11:33:22 +10:00
spi.rs Implement embedded-hal 1.0.0-alpha.7 traits (#298) 2022-02-26 21:06:55 +11:00
ssi.rs Added skeleton for HAL and updated readme 2021-01-25 15:42:43 -05:00
time.rs Added skeleton for HAL and updated readme 2021-01-25 15:42:43 -05:00
timer.rs Explorer base improvements (#363) 2022-06-23 19:19:32 +10:00
typelevel.rs Massive GPIO refactor 2021-07-03 10:32:43 +10:00
usb.rs Fix clippy warnings 2022-02-27 09:29:54 +11:00
watchdog.rs Implement embedded-hal 1.0.0-alpha.7 traits (#298) 2022-02-26 21:06:55 +11:00
xosc.rs Update embedded time 2021-07-27 09:41:03 +10:00