aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan McIntyre <ianpmcintyre@gmail.com>2022-10-29 15:47:16 -0400
committerIan McIntyre <ianpmcintyre@gmail.com>2022-12-01 20:21:05 -0500
commit8ba6242484308959bc24e84a8a77a28101679e1e (patch)
treefdd847ec15b52de2f882a0e60940acc10e2b84b8 /src
parentc7a9b9f3d4b9e71303c7b988d2bd916c2e4df9bc (diff)
Explicitly match family variants in host impl
Might help the next person who wants to add a new family. There's a way to defeat this lint when the enum is (Partial)Eq: use if / else to emulate a fallthrough. I can't find _another_ lint that would prevent that pattern, so I'll try to be vigilent here.
Diffstat (limited to 'src')
-rw-r--r--src/host.rs35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/host.rs b/src/host.rs
index f0fa512..2e47e50 100644
--- a/src/host.rs
+++ b/src/host.rs
@@ -3,6 +3,11 @@
//! See [`RuntimeBuilder::build`] to understand the linker script generation
//! steps.
+// Please explicitly match all `Family` variants. If someone wants to add
+// a new `Family`, this will show help them find all the settings they need
+// to consider.
+#![warn(clippy::wildcard_enum_match_arm)]
+
use std::{
env,
fmt::Display,
@@ -54,10 +59,14 @@ pub enum FlexSpi {
impl FlexSpi {
fn family_default(family: Family) -> Self {
- if Family::Imxrt1064 == family {
- FlexSpi::FlexSpi2
- } else {
- FlexSpi::FlexSpi1
+ match family {
+ Family::Imxrt1064 => FlexSpi::FlexSpi2,
+ Family::Imxrt1010
+ | Family::Imxrt1015
+ | Family::Imxrt1020
+ | Family::Imxrt1050
+ | Family::Imxrt1060
+ | Family::Imxrt1170 => FlexSpi::FlexSpi1,
}
}
fn start_address(self, family: Family) -> Option<u32> {
@@ -593,7 +602,11 @@ impl Family {
fn fcb_offset(self) -> usize {
match self {
Family::Imxrt1010 | Family::Imxrt1170 => 0x400,
- _ => 0x000,
+ Family::Imxrt1015
+ | Family::Imxrt1020
+ | Family::Imxrt1050
+ | Family::Imxrt1060
+ | Family::Imxrt1064 => 0x000,
}
}
@@ -601,13 +614,17 @@ impl Family {
///
/// This includes dedicated any OCRAM regions, if any exist for the chip.
fn ocram_start(self) -> u32 {
- if Family::Imxrt1170 == self {
+ match self {
// 256 KiB offset from the OCRAM M4 backdoor.
- 0x2024_0000
- } else {
+ Family::Imxrt1170 => 0x2024_0000,
// Either starts the FlexRAM OCRAM banks, or the
// dedicated OCRAM regions (for supported devices).
- 0x2020_0000
+ Family::Imxrt1010
+ | Family::Imxrt1015
+ | Family::Imxrt1020
+ | Family::Imxrt1050
+ | Family::Imxrt1060
+ | Family::Imxrt1064 => 0x2020_0000,
}
}