mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-23 20:51:31 +11:00
Merge pull request #394 from jannic/use-ref-for-clock-to-herz
Implement conversion from Clock to Hertz using reference
This commit is contained in:
commit
32411b8652
|
@ -134,7 +134,7 @@ fn main() -> ! {
|
||||||
scl_pin,
|
scl_pin,
|
||||||
400.kHz(),
|
400.kHz(),
|
||||||
&mut pac.RESETS,
|
&mut pac.RESETS,
|
||||||
clocks.peripheral_clock,
|
&clocks.peripheral_clock,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the I²C display interface:
|
// Create the I²C display interface:
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn main() -> ! {
|
||||||
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
||||||
.enable(
|
.enable(
|
||||||
hal::uart::common_configs::_115200_8_N_1,
|
hal::uart::common_configs::_115200_8_N_1,
|
||||||
clocks.peripheral_clock.into(),
|
clocks.peripheral_clock.freq(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ fn main() -> ! {
|
||||||
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
||||||
.enable(
|
.enable(
|
||||||
hal::uart::common_configs::_9600_8_N_1,
|
hal::uart::common_configs::_9600_8_N_1,
|
||||||
clocks.peripheral_clock.into(),
|
clocks.peripheral_clock.freq(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ fn main() -> ! {
|
||||||
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
||||||
.enable(
|
.enable(
|
||||||
hal::uart::common_configs::_9600_8_N_1,
|
hal::uart::common_configs::_9600_8_N_1,
|
||||||
clocks.peripheral_clock.into(),
|
clocks.peripheral_clock.freq(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Update embedded-hal alpha support to version 1.0.0-alpha.8
|
- Update embedded-hal alpha support to version 1.0.0-alpha.8
|
||||||
|
- Implement `From<&SomeClock> for Hertz` instead of `From<SomeClock> for Hertz`
|
||||||
|
for the clocks in `rp2040_hal::clocks`.
|
||||||
|
|
||||||
## [0.5.0] - 2022-06-13
|
## [0.5.0] - 2022-06-13
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ fn main() -> ! {
|
||||||
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
||||||
.enable(
|
.enable(
|
||||||
hal::uart::common_configs::_9600_8_N_1,
|
hal::uart::common_configs::_9600_8_N_1,
|
||||||
clocks.peripheral_clock.into(),
|
clocks.peripheral_clock.freq(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ fn main() -> ! {
|
||||||
scl_pin, // Try `not_an_scl_pin` here
|
scl_pin, // Try `not_an_scl_pin` here
|
||||||
400.kHz(),
|
400.kHz(),
|
||||||
&mut pac.RESETS,
|
&mut pac.RESETS,
|
||||||
clocks.peripheral_clock,
|
&clocks.system_clock,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Write three bytes to the I²C device with 7-bit address 0x2C
|
// Write three bytes to the I²C device with 7-bit address 0x2C
|
||||||
|
|
|
@ -25,6 +25,7 @@ use hal::pac;
|
||||||
|
|
||||||
// Some traits we need
|
// Some traits we need
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
use hal::Clock;
|
||||||
|
|
||||||
/// The linker will place this boot block at the start of our program image. We
|
/// The linker will place this boot block at the start of our program image. We
|
||||||
/// need this to help the ROM bootloader get our code up and running.
|
/// need this to help the ROM bootloader get our code up and running.
|
||||||
|
@ -89,7 +90,7 @@ fn main() -> ! {
|
||||||
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
let mut uart = hal::uart::UartPeripheral::new(pac.UART0, uart_pins, &mut pac.RESETS)
|
||||||
.enable(
|
.enable(
|
||||||
hal::uart::common_configs::_9600_8_N_1,
|
hal::uart::common_configs::_9600_8_N_1,
|
||||||
clocks.peripheral_clock.into(),
|
clocks.peripheral_clock.freq(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -417,9 +417,9 @@ macro_rules! base_clock {
|
||||||
|
|
||||||
impl Sealed for $name {}
|
impl Sealed for $name {}
|
||||||
|
|
||||||
impl From<$name> for Hertz
|
impl From<&$name> for Hertz
|
||||||
{
|
{
|
||||||
fn from(value: $name) -> Hertz {
|
fn from(value: &$name) -> Hertz {
|
||||||
value.frequency
|
value.frequency
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [examples/uart.rs](https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal/examples/uart.rs) for a more complete example
|
//! See [examples/uart.rs](https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal/examples/uart.rs) for a more complete example
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use rp2040_hal::{clocks::init_clocks_and_plls, gpio::{Pins, FunctionUart}, pac, sio::Sio, uart::{self, UartPeripheral}, watchdog::Watchdog};
|
//! use rp2040_hal::{Clock, clocks::init_clocks_and_plls, gpio::{Pins, FunctionUart}, pac, sio::Sio, uart::{self, UartPeripheral}, watchdog::Watchdog};
|
||||||
//!
|
//!
|
||||||
//! const XOSC_CRYSTAL_FREQ: u32 = 12_000_000; // Typically found in BSP crates
|
//! const XOSC_CRYSTAL_FREQ: u32 = 12_000_000; // Typically found in BSP crates
|
||||||
//!
|
//!
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
//! let uart = UartPeripheral::new(peripherals.UART0, pins, &mut peripherals.RESETS)
|
//! let uart = UartPeripheral::new(peripherals.UART0, pins, &mut peripherals.RESETS)
|
||||||
//! .enable(
|
//! .enable(
|
||||||
//! uart::common_configs::_9600_8_N_1,
|
//! uart::common_configs::_9600_8_N_1,
|
||||||
//! clocks.peripheral_clock.into(),
|
//! clocks.peripheral_clock.freq(),
|
||||||
//! ).unwrap();
|
//! ).unwrap();
|
||||||
//!
|
//!
|
||||||
//! uart.write_full_blocking(b"Hello World!\r\n");
|
//! uart.write_full_blocking(b"Hello World!\r\n");
|
||||||
|
|
Loading…
Reference in a new issue