diff options
| author | Ulf Lilleengen <[email protected]> | 2024-07-03 07:22:03 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-03 07:22:03 +0000 |
| commit | 3e70601fc78c86a8dd02155278a2dd068280208f (patch) | |
| tree | decd6d938246c986714118e54337f51c9f7c113c /embassy-stm32 | |
| parent | 5223923bd2f8d02d53f02329836a42f2d5ccc746 (diff) | |
| parent | a0799bf270010f4e91b0c3eebe487d8bc6fb54fc (diff) | |
Merge pull request #3124 from Adancurusul/dev
Add adc oversampling support
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/adc/v3.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs index 398c57a92..bf7ad242b 100644 --- a/embassy-stm32/src/adc/v3.rs +++ b/embassy-stm32/src/adc/v3.rs | |||
| @@ -277,6 +277,21 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 277 | val | 277 | val |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | #[cfg(any(adc_g0, adc_u0))] | ||
| 281 | pub fn set_oversampling_shift(&mut self, shift: u8) { | ||
| 282 | T::regs().cfgr2().modify(|reg| reg.set_ovss(shift)); | ||
| 283 | } | ||
| 284 | |||
| 285 | #[cfg(any(adc_g0, adc_u0))] | ||
| 286 | pub fn set_oversampling_ratio(&mut self, ratio: u8) { | ||
| 287 | T::regs().cfgr2().modify(|reg| reg.set_ovsr(ratio)); | ||
| 288 | } | ||
| 289 | |||
| 290 | #[cfg(any(adc_g0, adc_u0))] | ||
| 291 | pub fn oversampling_enable(&mut self, enable: bool) { | ||
| 292 | T::regs().cfgr2().modify(|reg| reg.set_ovse(enable)); | ||
| 293 | } | ||
| 294 | |||
| 280 | fn set_channel_sample_time(_ch: u8, sample_time: SampleTime) { | 295 | fn set_channel_sample_time(_ch: u8, sample_time: SampleTime) { |
| 281 | cfg_if! { | 296 | cfg_if! { |
| 282 | if #[cfg(any(adc_g0, adc_u0))] { | 297 | if #[cfg(any(adc_g0, adc_u0))] { |
