|
4 | 4 | //!
|
5 | 5 | //! Check out [examples/adc.rs].
|
6 | 6 | //!
|
7 |
| -//! It can be built for the STM32F3Discovery running |
| 7 | +//! It can be built for the `STM32F3Discovery` running |
8 | 8 | //! `cargo build --example adc --features=stm32f303xc`
|
9 | 9 | //!
|
10 | 10 | //! [examples/adc.rs]: https://github.com/stm32-rs/stm32f3xx-hal/blob/v0.9.1/examples/adc.rs
|
@@ -97,6 +97,7 @@ pub struct TemperatureSensor<ADC> {
|
97 | 97 | ///
|
98 | 98 | /// This peripheral can control different parts, like enabling internal sensors (like temperature sensor)
|
99 | 99 | /// or enable dual channel mode (which is not supported yet.)
|
| 100 | +#[allow(clippy::module_name_repetitions)] |
100 | 101 | pub struct CommonAdc<ADC> {
|
101 | 102 | reg: ADC,
|
102 | 103 | }
|
@@ -348,7 +349,7 @@ where
|
348 | 349 | // TODO(Sh3Rm4n): Check against and integrate to DMA
|
349 | 350 | #[inline]
|
350 | 351 | pub fn data_register_address(&self) -> u32 {
|
351 |
| - &self.reg.dr as *const _ as u32 |
| 352 | + core::ptr::addr_of!(self.reg.dr) as u32 |
352 | 353 | }
|
353 | 354 |
|
354 | 355 | /// Manually start a conversion sequence.
|
@@ -629,8 +630,9 @@ where
|
629 | 630 | /// Get the current configured DMA mode.
|
630 | 631 | #[inline]
|
631 | 632 | pub fn dma_mode(&self) -> config::DmaMode {
|
632 |
| - let cfgr = self.reg.cfgr.read(); |
633 | 633 | use adc1::cfgr::{DMACFG_A, DMAEN_A};
|
| 634 | + |
| 635 | + let cfgr = self.reg.cfgr.read(); |
634 | 636 | match (cfgr.dmaen().variant(), cfgr.dmacfg().variant()) {
|
635 | 637 | (DMAEN_A::Disabled, _) => config::DmaMode::Disabled,
|
636 | 638 | (DMAEN_A::Enabled, DMACFG_A::OneShot) => config::DmaMode::OneShot,
|
@@ -872,7 +874,7 @@ where
|
872 | 874 | /// Set the overrun mode
|
873 | 875 | #[inline]
|
874 | 876 | pub fn set_overrun_mode(&mut self, mode: config::OverrunMode) {
|
875 |
| - self.reg.cfgr.modify(|_, w| w.ovrmod().variant(mode.into())) |
| 877 | + self.reg.cfgr.modify(|_, w| w.ovrmod().variant(mode.into())); |
876 | 878 | }
|
877 | 879 |
|
878 | 880 | /// Sets the sampling resolution.
|
@@ -1090,7 +1092,7 @@ where
|
1090 | 1092 | /// the end of a single conversion of a "slot" is notfied via [`Event::EndOfConversion`].
|
1091 | 1093 | #[inline]
|
1092 | 1094 | pub fn set_sequence_length(&mut self, sequence: config::Sequence) {
|
1093 |
| - self.reg.sqr1.modify(|_, w| w.l().bits(sequence.into())) |
| 1095 | + self.reg.sqr1.modify(|_, w| w.l().bits(sequence.into())); |
1094 | 1096 | }
|
1095 | 1097 |
|
1096 | 1098 | // TODO(Sh3Rm4n): Implement, when injection mode is implemented.
|
@@ -1125,16 +1127,16 @@ where
|
1125 | 1127 | Event::EndOfSequence => self.reg.ier.modify(|_, w| w.eosie().bit(enable)),
|
1126 | 1128 | Event::Overrun => self.reg.ier.modify(|_, w| w.ovrie().bit(enable)),
|
1127 | 1129 | Event::InjectedChannelEndOfConversion => {
|
1128 |
| - self.reg.ier.modify(|_, w| w.jeocie().bit(enable)) |
| 1130 | + self.reg.ier.modify(|_, w| w.jeocie().bit(enable)); |
1129 | 1131 | }
|
1130 | 1132 | Event::InjectedChannelEndOfSequence => {
|
1131 |
| - self.reg.ier.modify(|_, w| w.jeosie().bit(enable)) |
| 1133 | + self.reg.ier.modify(|_, w| w.jeosie().bit(enable)); |
1132 | 1134 | }
|
1133 | 1135 | Event::AnalogWatchdog1 => self.reg.ier.modify(|_, w| w.awd1ie().bit(enable)),
|
1134 | 1136 | Event::AnalogWatchdog2 => self.reg.ier.modify(|_, w| w.awd2ie().bit(enable)),
|
1135 | 1137 | Event::AnalogWatchdog3 => self.reg.ier.modify(|_, w| w.awd3ie().bit(enable)),
|
1136 | 1138 | Event::InjectedContextQueueOverfow => {
|
1137 |
| - self.reg.ier.modify(|_, w| w.jqovfie().bit(enable)) |
| 1139 | + self.reg.ier.modify(|_, w| w.jqovfie().bit(enable)); |
1138 | 1140 | }
|
1139 | 1141 | };
|
1140 | 1142 | }
|
@@ -1266,8 +1268,8 @@ where
|
1266 | 1268 | #[cfg(feature = "svd-f373")]
|
1267 | 1269 | self.set_scan(config::Scan::Disabled);
|
1268 | 1270 |
|
1269 |
| - let is_eoc_enabled = self.is_interrupt_configured(Event::EndOfConversion); |
1270 |
| - let is_eos_enabled = self.is_interrupt_configured(Event::EndOfSequence); |
| 1271 | + let is_end_of_conversion_enabled = self.is_interrupt_configured(Event::EndOfConversion); |
| 1272 | + let is_end_of_sequence_enabled = self.is_interrupt_configured(Event::EndOfSequence); |
1271 | 1273 | self.disable_interrupt(Event::EndOfConversion);
|
1272 | 1274 | self.disable_interrupt(Event::EndOfSequence);
|
1273 | 1275 |
|
@@ -1297,8 +1299,8 @@ where
|
1297 | 1299 | }
|
1298 | 1300 | self.set_sequence_length(seq_len);
|
1299 | 1301 |
|
1300 |
| - self.configure_interrupt(Event::EndOfSequence, is_eos_enabled); |
1301 |
| - self.configure_interrupt(Event::EndOfConversion, is_eoc_enabled); |
| 1302 | + self.configure_interrupt(Event::EndOfSequence, is_end_of_sequence_enabled); |
| 1303 | + self.configure_interrupt(Event::EndOfConversion, is_end_of_conversion_enabled); |
1302 | 1304 |
|
1303 | 1305 | #[cfg(feature = "svd-f373")]
|
1304 | 1306 | self.set_scan(config::Scan::Disabled);
|
|
0 commit comments