Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions boards/metro_m4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,32 +267,6 @@ pub fn spi_master(
.enable()
}

/// Convenience for setting up the onboard QSPI flash.
/// Enables the clocks for the QSPI peripheral in single data rate mode
/// assuming 120MHz system clock, for 4MHz QSPI mode 0 operation.
#[allow(clippy::too_many_arguments)]
pub fn qspi_master(
mclk: &mut Mclk,
qspi: pac::Qspi,
sclk: impl Into<FlashSclk>,
cs: impl Into<FlashCs>,
data0: impl Into<FlashD0>,
data1: impl Into<FlashD1>,
data2: impl Into<FlashD2>,
data3: impl Into<FlashD3>,
) -> Qspi<OneShot> {
Qspi::new(
mclk,
qspi,
sclk.into(),
cs.into(),
data0.into(),
data1.into(),
data2.into(),
data3.into(),
)
}

/// I2C pads for the labelled I2C peripheral
///
/// You can use these pads with other, user-defined [`i2c::Config`]urations.
Expand Down
35 changes: 25 additions & 10 deletions boards/pygamer/examples/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#![no_std]
#![no_main]

use atsamd_hal::qspi::QspiBuilder;
use bsp::{entry, hal, pac, Pins};
use hal::clock::v2::{clock_system_at_reset, pclk::Pclk};
#[cfg(not(feature = "panic_led"))]
use panic_halt as _;
use pygamer as bsp;
Expand All @@ -37,18 +39,35 @@ use pac::{CorePeripherals, Peripherals};
fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(

let (mut buses, clocks, tokens) = clock_system_at_reset(
peripherals.oscctrl,
peripherals.osc32kctrl,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
peripherals.mclk,
&mut peripherals.nvmctrl,
);
let mut delay = Delay::new(core.SYST, &mut clocks);

let (mut delay, gclk0) = Delay::new_with_source(core.SYST, clocks.gclk0);

let sets = Pins::new(peripherals.port).split();

let mut flash = sets.flash.init(&mut peripherals.mclk, peripherals.qspi);
let apb_qspi = clocks.apbs.qspi;
let ahb_qspi = clocks.ahbs.qspi;

let (mut flash, gclk0) = QspiBuilder::new(
sets.flash.sclk,
sets.flash.cs,
sets.flash.data0,
sets.flash.data1,
sets.flash.data2,
sets.flash.data3
)
// 48Mhz since this is as fast as the CPU runs after reset,
.with_freq(48_000_000)
.with_mode(qspi::QspiMode::_0)
.build(peripherals.qspi, ahb_qspi, apb_qspi, gclk0)
.unwrap();

// Startup delay. Can't find documented but Adafruit use 5ms
delay.delay_ms(5u8);
Expand All @@ -64,10 +83,6 @@ fn main() -> ! {
flash.read_command(Command::ReadId, &mut read_buf).unwrap();
assert_eq!(read_buf, [0x17, 0x40, 0xc8]);

// 120MHz / 2 = 60mhz
// faster than 104mhz at 3.3v would require High Performance Mode
flash.set_clk_divider(2);

// Enable Quad SPI mode. Requires write enable. Check WIP.
flash.run_command(Command::WriteEnable).unwrap();
flash.write_command(Command::WriteStatus2, &[0x02]).unwrap();
Expand Down
8 changes: 0 additions & 8 deletions boards/pygamer/src/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,14 +883,6 @@ pub struct QSPIFlash {
pub data3: QspiD3Reset,
}

impl QSPIFlash {
pub fn init(self, mclk: &mut pac::Mclk, qspi: pac::Qspi) -> qspi::Qspi<qspi::OneShot> {
qspi::Qspi::new(
mclk, qspi, self.sclk, self.cs, self.data0, self.data1, self.data2, self.data3,
)
}
}

/// Button pins
pub struct Buttons {
/// Button Latch
Expand Down
Loading
Loading