Open murraytodd opened 5 months ago
Hi, I am going to assume that you are talking about the blue-pill example since it showcases the blocking
functionality of the driver and
uses embassy.
The driver relies on the HAL's specific implementation of the embedded-hal-1.0.0 Traits (DelayNs and I2c). In this case, stm32
. At the time of creating the examples, cortex-m did not support embedded-hal-1.0.0 but only embedded-hal-0.2.*. embassy_stm32, on the other hand, did support embedded-hal-1.0.0, and that's why I included it in the examples.
Nonetheless, I'm going to check again if cortex-m has implemented support for embedded-hal-1.0.0 and update the examples accordingly.
It's both of the examples. Essentially, I'm writing a fairly simple rp2040-hal example to start with (using the rp-pico BSP) and I'm trying to follow your example for instantiating the driver via the UninitBMP180 builder. I'm good with creating and passing the i2c device, but for the Delay timer I don't know what to create and pass through.
have you tried?
#![no_std]
#![no_main]
use panic_halt as _;
use rp2040_hal::pac;
#[link_section = ".boot2"]
#[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
const XTAL_FREQ_HZ: u32 = 12_000_000u32;
#[rp2040_hal::entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let mut watchdog = rp2040_hal::Watchdog::new(pac.WATCHDOG);
let clocks = rp2040_hal::clocks::init_clocks_and_plls(
XTAL_FREQ_HZ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
pac.PLL_USB,
&mut pac.RESETS,
&mut watchdog,
)
.unwrap();
let timer = rp2040_hal::Timer::new(pac.TIMER, &mut pac.RESETS, &clocks);
loop {}
}
Thanks for your help. I see now, it's a matter that rp2040-hal
actually hasn't completed its implementation. In their timer.rs
code, there's a comment "There is no Embedded HAL 1.0 equivalent at this time. If all you need is a delay, Timer
does implement embedded_hal::delay::DelayNs
."
Thanks. I really appreciate your taking the time to help give me some more breadcrumbs to follow.
I got it figured out. Your advice was correct, but I had included the async::UninitBMP180Builder
instead of the blocking::UninitBMP180Builder
. Since rp2040-hal
did implement the embedded_hal::delay::DelayNs
trait, it was indeed sufficient for our needs. Thanks again for the help.
Glad to hear that!
Hi, I'm trying to follow the example to use the driver, but the initialization depends on the
embassy_time
's definition of a Delay trait. It would be nice to see how to do it with the lower-levelembedded-hal
API.