mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-24 13:11:30 +11:00
cf86e08749
* Add the Pimoroni Plasma 2040 board This PR adds the board support package and a simple example. The example just blinks the on-board RGB LED. An example should be added for using the board to control an LED strip. This should probably use smart-leds with the associated PIO driver. An example or functionality should be added for the current sensor. * Rename LED data line from dat to data to match schematic * Add an example for driving WS2812 LEDs This is pretty much a copy-paste of the awesome pico_ws2812_led example. * Remove reference in README to rp-pico * Remove reference to pico board clock speed I have removed this in the Plasma 2040 repository and where I copied it from, tiny2040_blinky. * Remove redundant namespace * Add self-reference in README to the current board's GitHub README Fix the erroneous link in the pimoroni-tiny2040 README from which I copied.
71 lines
1.7 KiB
Rust
71 lines
1.7 KiB
Rust
//! Blinks the 3 colour LEDs on a Pimoroni Plasma 2040 in sequence
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use cortex_m_rt::entry;
|
|
use defmt::*;
|
|
use defmt_rtt as _;
|
|
use embedded_hal::digital::v2::OutputPin;
|
|
use embedded_time::fixed_point::FixedPoint;
|
|
use panic_halt as _;
|
|
|
|
use pimoroni_plasma_2040 as bsp;
|
|
|
|
use bsp::hal::{
|
|
clocks::{init_clocks_and_plls, Clock},
|
|
pac,
|
|
sio::Sio,
|
|
watchdog::Watchdog,
|
|
};
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
info!("Program start");
|
|
let mut pac = pac::Peripherals::take().unwrap();
|
|
let core = pac::CorePeripherals::take().unwrap();
|
|
let mut watchdog = Watchdog::new(pac.WATCHDOG);
|
|
let sio = Sio::new(pac.SIO);
|
|
|
|
let clocks = init_clocks_and_plls(
|
|
bsp::XOSC_CRYSTAL_FREQ,
|
|
pac.XOSC,
|
|
pac.CLOCKS,
|
|
pac.PLL_SYS,
|
|
pac.PLL_USB,
|
|
&mut pac.RESETS,
|
|
&mut watchdog,
|
|
)
|
|
.ok()
|
|
.unwrap();
|
|
|
|
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
|
|
|
|
let pins = bsp::Pins::new(
|
|
pac.IO_BANK0,
|
|
pac.PADS_BANK0,
|
|
sio.gpio_bank0,
|
|
&mut pac.RESETS,
|
|
);
|
|
|
|
let mut led_green = pins.led_green.into_push_pull_output();
|
|
let mut led_red = pins.led_red.into_push_pull_output();
|
|
let mut led_blue = pins.led_blue.into_push_pull_output();
|
|
led_green.set_high().unwrap();
|
|
led_red.set_high().unwrap();
|
|
led_blue.set_high().unwrap();
|
|
|
|
loop {
|
|
led_green.set_low().unwrap();
|
|
delay.delay_ms(500);
|
|
led_green.set_high().unwrap();
|
|
led_blue.set_low().unwrap();
|
|
delay.delay_ms(500);
|
|
led_blue.set_high().unwrap();
|
|
led_red.set_low().unwrap();
|
|
delay.delay_ms(500);
|
|
led_red.set_high().unwrap();
|
|
}
|
|
}
|
|
|
|
// End of file
|