Skip to content

Commit 1626954

Browse files
committed
HRTIM: adc trigger impl into
1 parent 0e763b9 commit 1626954

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

examples/hrtim/adc-trigger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn main() -> ! {
116116

117117
adc.set_external_trigger((
118118
adc::config::TriggerMode::RisingEdge,
119-
hr_control.adc_trigger1.as_adc12_trigger(),
119+
&hr_control.adc_trigger1,
120120
));
121121
adc.enable_temperature(&dp.ADC12_COMMON);
122122
adc.set_continuous(Continuous::Discontinuous);

src/adc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,8 +2239,8 @@ macro_rules! adc {
22392239

22402240
/// Sets which external trigger to use and if it is disabled, rising, falling or both
22412241
#[inline(always)]
2242-
pub fn set_external_trigger(&mut self, (edge, extsel): (config::TriggerMode, $trigger_type)) {
2243-
self.adc.set_external_trigger( (edge, extsel) )
2242+
pub fn set_external_trigger<T: Into<$trigger_type>>(&mut self, (edge, extsel): (config::TriggerMode, T)) {
2243+
self.adc.set_external_trigger( (edge, extsel.into()) )
22442244
}
22452245

22462246
/// Sets auto delay to true or false

src/hrtim/control.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,16 @@ macro_rules! impl_adc1234_trigger {
245245
common.$adcXr.modify(|r, w| w.bits(r.bits() | T::BITS));
246246
}
247247
}
248+
}
248249

249-
$(
250-
pub fn as_adc12_trigger(&self) -> crate::adc::config::ExternalTrigger12 {
251-
crate::adc::config::ExternalTrigger12::$variant12
252-
}
253-
)*
250+
$(impl Into<crate::adc::config::ExternalTrigger12> for &$t {
251+
fn into(self) -> crate::adc::config::ExternalTrigger12 {
252+
crate::adc::config::ExternalTrigger12::$variant12
253+
}
254+
})*
254255

255-
pub fn as_adc345_trigger(&self) -> crate::adc::config::ExternalTrigger345 {
256+
impl Into<crate::adc::config::ExternalTrigger345> for &$t {
257+
fn into(self) -> crate::adc::config::ExternalTrigger345 {
256258
crate::adc::config::ExternalTrigger345::$variant345
257259
}
258260
}
@@ -272,15 +274,20 @@ macro_rules! impl_adc5678910_trigger {
272274
.adcer
273275
.modify(|_r, w| w.$adcXtrg().variant(T::BITS as u8));
274276
}
277+
}
275278

276-
pub fn as_adc12_trigger(&self) -> crate::adc::config::ExternalTrigger12 {
279+
impl Into<crate::adc::config::ExternalTrigger12> for &$t {
280+
fn into(self) -> crate::adc::config::ExternalTrigger12 {
277281
crate::adc::config::ExternalTrigger12::$variant12
278282
}
283+
}
279284

280-
pub fn as_adc345_trigger(&self) -> crate::adc::config::ExternalTrigger345 {
285+
impl Into<crate::adc::config::ExternalTrigger345> for &$t {
286+
fn into(self) -> crate::adc::config::ExternalTrigger345 {
281287
crate::adc::config::ExternalTrigger345::$variant345
282288
}
283289
}
290+
284291
)*}
285292
}
286293

0 commit comments

Comments
 (0)