From 5b74e326e5da8214eec9360e67f42ff2ca3905e8 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 29 Mar 2021 00:55:05 +0200 Subject: [PATCH] nrf/qpsi: make config non_exhaustive --- embassy-nrf-examples/src/bin/qspi.rs | 9 +-------- embassy-nrf/src/qspi.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/embassy-nrf-examples/src/bin/qspi.rs b/embassy-nrf-examples/src/bin/qspi.rs index 4e24a13d..2005b997 100644 --- a/embassy-nrf-examples/src/bin/qspi.rs +++ b/embassy-nrf-examples/src/bin/qspi.rs @@ -36,14 +36,7 @@ async fn run() { let io2 = p.P0_22; let io3 = p.P0_23; - let config = qspi::Config { - read_opcode: qspi::ReadOpcode::READ4IO, - write_opcode: qspi::WriteOpcode::PP4IO, - xip_offset: 0, - write_page_size: qspi::WritePageSize::_256BYTES, - deep_power_down: None, - }; - + let config = qspi::Config::default(); let irq = interrupt::take!(QSPI); let q = qspi::Qspi::new(p.QSPI, irq, sck, csn, io0, io1, io2, io3, config); pin_mut!(q); diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index e05186ab..033c9e01 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs @@ -36,6 +36,7 @@ pub struct DeepPowerDownConfig { pub exit_time: u16, } +#[non_exhaustive] pub struct Config { pub xip_offset: u32, pub read_opcode: ReadOpcode, @@ -44,6 +45,18 @@ pub struct Config { pub deep_power_down: Option, } +impl Default for Config { + fn default() -> Self { + Self { + read_opcode: ReadOpcode::READ4IO, + write_opcode: WriteOpcode::PP4IO, + xip_offset: 0, + write_page_size: WritePageSize::_256BYTES, + deep_power_down: None, + } + } +} + pub struct Qspi<'d, T: Instance> { peri: T, irq: T::Interrupt,