Skip to content

Commit

Permalink
Split up A4910 config into a tuple of two types
Browse files Browse the repository at this point in the history
  • Loading branch information
johngigantic committed Oct 27, 2023
1 parent 84f2a5d commit fe57f7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions drivers/src/a4910/regs/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ impl AllegroRegister<u13> for Config1 {
impl ConstantAddress<A4910Reg> for Config1 {
const ADDRESS: A4910Reg = A4910Reg::Config1;
}

pub type Config = (Config0, Config1);
13 changes: 6 additions & 7 deletions drivers/src/a4910/regs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod diagnostic;
pub mod mask;
pub mod run;

use config::{Config0, Config1};
use config::Config;
use mask::Mask;
use run::Run;

Expand All @@ -32,8 +32,7 @@ impl From<A4910Reg> for u2 {

#[derive(Debug, Default)]
pub struct RegisterSettings {
pub cfg0: Config0,
pub cfg1: Config1,
pub cfg: Config,
pub mask: Mask,
pub run: Run,
}
Expand All @@ -43,8 +42,8 @@ impl Index<A4910Reg> for RegisterSettings {

fn index(&self, index: A4910Reg) -> &Self::Output {
match index {
A4910Reg::Config0 => &self.cfg0,
A4910Reg::Config1 => &self.cfg1,
A4910Reg::Config0 => &self.cfg.0,
A4910Reg::Config1 => &self.cfg.1,
A4910Reg::Mask => &self.mask,
A4910Reg::Run => &self.run,
}
Expand All @@ -54,8 +53,8 @@ impl Index<A4910Reg> for RegisterSettings {
impl IndexMut<A4910Reg> for RegisterSettings {
fn index_mut(&mut self, index: A4910Reg) -> &mut Self::Output {
match index {
A4910Reg::Config0 => &mut self.cfg0,
A4910Reg::Config1 => &mut self.cfg1,
A4910Reg::Config0 => &mut self.cfg.0,
A4910Reg::Config1 => &mut self.cfg.1,
A4910Reg::Mask => &mut self.mask,
A4910Reg::Run => &mut self.run,
}
Expand Down

0 comments on commit fe57f7a

Please sign in to comment.