diff --git a/lib/io/hyped_adc/hyped_adc_derive/src/lib.rs b/lib/io/hyped_adc/hyped_adc_derive/src/lib.rs index 41d15543..d4621e1c 100644 --- a/lib/io/hyped_adc/hyped_adc_derive/src/lib.rs +++ b/lib/io/hyped_adc/hyped_adc_derive/src/lib.rs @@ -16,10 +16,14 @@ fn impl_hyped_adc(ast: &syn::DeriveInput) -> TokenStream { let (impl_generics, ty_generics, _) = generics.split_for_impl(); let gen = quote! { impl #impl_generics HypedAdc for #name #ty_generics { - /// Read a value from the ADC channel fn read_value(&mut self) -> u16 { self.adc.blocking_read(&mut self.channel) } + + fn get_resolution(&self) -> u16 { + /// STM32 boards have a resolution of 12 bits + 4096 + } } impl #impl_generics #name #ty_generics { diff --git a/lib/io/hyped_adc/src/lib.rs b/lib/io/hyped_adc/src/lib.rs index ab564e43..b6e60ca4 100644 --- a/lib/io/hyped_adc/src/lib.rs +++ b/lib/io/hyped_adc/src/lib.rs @@ -2,7 +2,10 @@ /// ADC trait used to abstract the ADC peripheral pub trait HypedAdc { + /// Read value from the ADC channel fn read_value(&mut self) -> u16; + /// Get resolution of ADC + fn get_resolution(&self) -> u16; } pub mod mock_adc { @@ -16,12 +19,15 @@ pub mod mock_adc { } impl crate::HypedAdc for MockAdc { - /// Reads a value from the ADC fn read_value(&mut self) -> u16 { let next_value: u16 = self.next_values.pop().unwrap_or(self.current_value); self.current_value = next_value; self.current_value } + + fn get_resolution(&self) -> u16 { + 4096 + } } impl MockAdc {