Skip to content

Commit 787766d

Browse files
authored
Merge pull request #52 from stm32-rs/tsc-spread-spectrum-option-remove-bb
TSC spread spectrum configuration
2 parents 2fb7418 + d80681d commit 787766d

File tree

3 files changed

+8
-50
lines changed

3 files changed

+8
-50
lines changed

src/bb.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,4 @@ pub mod tsc;
172172
feature = "stm32l4x5",
173173
feature = "stm32l4x6"
174174
))]
175-
pub mod bb;
176-
#[cfg(any(
177-
feature = "stm32l4x1",
178-
feature = "stm32l4x2",
179-
feature = "stm32l4x3",
180-
feature = "stm32l4x5",
181-
feature = "stm32l4x6"
182-
))]
183175
pub mod pwm;

src/tsc.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ pub struct Config {
8181
pub max_count_error: Option<MaxCountError>,
8282
pub charge_transfer_high: Option<ChargeDischargeTime>,
8383
pub charge_transfer_low: Option<ChargeDischargeTime>,
84+
/// Spread spectrum deviation - a value between 0 and 128
85+
pub spread_spectrum_deviation: Option<u8>,
8486
}
8587

8688
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -147,23 +149,23 @@ impl<SPIN> Tsc<SPIN> {
147149
clock_prescale: None,
148150
max_count_error: None,
149151
charge_transfer_high: None,
150-
charge_transfer_low: None
152+
charge_transfer_low: None,
153+
spread_spectrum_deviation: None
151154
});
152155

153156
tsc.cr.write(|w| unsafe {
154157
w.ctph()
155158
.bits(config.charge_transfer_high.unwrap_or(ChargeDischargeTime::C2) as u8)
156159
.ctpl()
157160
.bits(config.charge_transfer_low.unwrap_or(ChargeDischargeTime::C2) as u8)
158-
// TODO configure sse?
159-
.sse()
160-
.set_bit()
161-
.ssd()
162-
.bits(16)
163161
.pgpsc()
164162
.bits(config.clock_prescale.unwrap_or(ClockPrescaler::Hclk) as u8)
165163
.mcv()
166164
.bits(config.max_count_error.unwrap_or(MaxCountError::U8191) as u8)
165+
.sse()
166+
.bit(config.spread_spectrum_deviation.is_some())
167+
.ssd()
168+
.bits(config.spread_spectrum_deviation.unwrap_or(0u8))
167169
.tsce()
168170
.set_bit()
169171
});

0 commit comments

Comments
 (0)