From b9efeb8b88fbd223e5fa948b50e4b9ba78c54540 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 8 Nov 2018 18:57:50 +0100 Subject: Create macro for IC markers --- src/devices/ic.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/devices') diff --git a/src/devices/ic.rs b/src/devices/ic.rs index 9795de6..81c8e44 100644 --- a/src/devices/ic.rs +++ b/src/devices/ic.rs @@ -9,14 +9,15 @@ pub trait Resolution : super::private::Sealed { const BITS : ResolutionBits; } -/// ADS1013 IC marker -pub struct Ads1013(()); -impl Resolution for Ads1013 { - const BITS: ResolutionBits = ResolutionBits::_12; +macro_rules! ic_marker { + ($name:ident, $resolution:ident) => { + /// IC marker + pub struct $name(()); + impl Resolution for $name { + const BITS: ResolutionBits = ResolutionBits::$resolution; + } + }; } -/// ADS1113 IC marker -pub struct Ads1113(()); -impl Resolution for Ads1113 { - const BITS: ResolutionBits = ResolutionBits::_16; -} \ No newline at end of file +ic_marker!(Ads1013, _12); +ic_marker!(Ads1113, _16); -- cgit v1.2.3-54-g00ecf