mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-24 05:01:31 +11:00
ffa97842e2
* Improve clock frequency stuff for uninitialized clocks - Made clocks singletons so the frequency handling actually works as expected - Added initial frequencies - Improved the docs - Added a Clock trait * Add pico examples. These have the benefit of knowing which external crystal is attached. Even though it always should be a 12 MHz crystal. Thus we can setup the clocks properly I also changed the rp2040 examples to work out of the box for pico boards since that will probably be used most of the time
40 lines
906 B
Rust
40 lines
906 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use cortex_m_rt::entry;
|
|
use embedded_hal::PwmPin;
|
|
use panic_halt as _;
|
|
use rp2040_hal::pwm::*;
|
|
|
|
#[link_section = ".boot2"]
|
|
#[used]
|
|
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER;
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let mut pac = rp2040_pac::Peripherals::take().unwrap();
|
|
|
|
let mut pwm_pin = Pwm4::new(25);
|
|
|
|
//Instead of having it take references to all of these pac objects, eventually this should just
|
|
//take ownership of a GPIO pin.
|
|
pwm_pin.default_config(
|
|
&mut pac.PWM,
|
|
&mut pac.PADS_BANK0,
|
|
&mut pac.IO_BANK0,
|
|
&mut pac.RESETS,
|
|
);
|
|
|
|
pwm_pin.set_ph_correct();
|
|
|
|
pwm_pin.enable();
|
|
|
|
loop {
|
|
pwm_pin.set_duty(15000);
|
|
// TODO: Replace with proper delays once we have clocks working
|
|
cortex_m::asm::delay(5_000_000);
|
|
pwm_pin.set_duty(30000);
|
|
cortex_m::asm::delay(5_000_000);
|
|
}
|
|
}
|