stm32_hrtim/
ext.rs

1#[cfg(feature = "stm32f3")]
2pub use stm32f3::*;
3#[cfg(feature = "stm32g4")]
4pub use stm32g4::*;
5#[cfg(feature = "stm32h7")]
6pub use stm32h7::*;
7
8use crate::pac;
9use pac::hrtim_master as master;
10use pac::hrtim_tima as tima;
11use pac::hrtim_timb as timb;
12use pac::hrtim_timc as timc;
13use pac::hrtim_timd as timd;
14use pac::hrtim_time as time;
15#[cfg(feature = "hrtim_v2")]
16use pac::hrtim_timf as timf;
17
18#[cfg_attr(feature = "defmt", derive(defmt::Format))]
19#[derive(Clone, Copy, Debug, PartialEq, Eq)]
20#[repr(u8)]
21pub enum Chan {
22    Ch1 = 0,
23    Ch2 = 1,
24}
25
26#[cfg_attr(feature = "defmt", derive(defmt::Format))]
27#[derive(Clone, Copy, Debug, PartialEq, Eq)]
28#[repr(u8)]
29pub enum Cmp {
30    Cmp1 = 0,
31    Cmp2 = 1,
32    Cmp3 = 2,
33    Cmp4 = 3,
34}
35
36#[cfg_attr(feature = "defmt", derive(defmt::Format))]
37#[derive(Clone, Copy, Debug, PartialEq, Eq)]
38#[repr(u8)]
39pub enum ExtEvnt {
40    ExtEvnt1 = 0,
41    ExtEvnt2 = 1,
42    ExtEvnt3 = 2,
43    ExtEvnt4 = 3,
44    ExtEvnt5 = 4,
45    ExtEvnt6 = 5,
46    ExtEvnt7 = 6,
47    ExtEvnt8 = 7,
48    ExtEvnt9 = 8,
49    ExtEvnt10 = 9,
50}
51
52pub trait MasterExt {
53    type CRrs: reg::MasterCrR + reg::MasterCrW;
54    fn cr(&self) -> &Reg<Self::CRrs>;
55    type ISRrs: reg::MasterIsr;
56    fn isr(&self) -> &Reg<Self::ISRrs>;
57    type ICRrs: reg::MasterIcr;
58    fn icr(&self) -> &Reg<Self::ICRrs>;
59    type DIERrs: reg::MasterDierR + reg::MasterDierW;
60    fn dier(&self) -> &Reg<Self::DIERrs>;
61    fn cntr(&self) -> &master::CNTR;
62    fn perr(&self) -> &master::PERR;
63    fn repr(&self) -> &master::REPR;
64    fn cmp1r(&self) -> &master::CMP1R;
65    fn cmp2r(&self) -> &master::CMP1R;
66    fn cmp3r(&self) -> &master::CMP1R;
67    fn cmp4r(&self) -> &master::CMP1R;
68    fn cmpr(&self, c: Cmp) -> &master::CMP1R {
69        match c {
70            Cmp::Cmp1 => self.cmp1r(),
71            Cmp::Cmp2 => self.cmp2r(),
72            Cmp::Cmp3 => self.cmp3r(),
73            Cmp::Cmp4 => self.cmp4r(),
74        }
75    }
76}
77
78pub trait TimExt:
79    MasterExt<ISRrs = tima::isr::ISRrs, ICRrs = tima::icr::ICRrs, DIERrs = tima::dier::DIERrs>
80{
81    fn cmp1cr(&self) -> &tima::CMP1CR;
82    fn cpt1r(&self) -> &tima::CPT1R;
83    fn cpt2r(&self) -> &tima::CPT1R;
84    fn cptr(&self, c: Chan) -> &tima::CPT1R {
85        match c {
86            Chan::Ch1 => self.cpt1r(),
87            Chan::Ch2 => self.cpt2r(),
88        }
89    }
90    fn dtr(&self) -> &tima::DTR;
91    fn eefr1(&self) -> &tima::EEFR1;
92    fn eefr2(&self) -> &tima::EEFR2;
93    type SET1Rrs: reg::Set1rR + reg::Set1rW;
94    type RST1Rrs: reg::Rst1rR + reg::Rst1rW;
95    fn set1r(&self) -> &Reg<Self::SET1Rrs>;
96    fn rst1r(&self) -> &Reg<Self::RST1Rrs>;
97    fn set2r(&self) -> &Reg<Self::SET1Rrs>;
98    fn rst2r(&self) -> &Reg<Self::RST1Rrs>;
99    fn set_r(&self, c: Chan) -> &Reg<Self::SET1Rrs> {
100        match c {
101            Chan::Ch1 => self.set1r(),
102            Chan::Ch2 => self.set2r(),
103        }
104    }
105    fn rst_r(&self, c: Chan) -> &Reg<Self::RST1Rrs> {
106        match c {
107            Chan::Ch1 => self.rst1r(),
108            Chan::Ch2 => self.rst2r(),
109        }
110    }
111    type RSTRrs: reg::RstrR + reg::RstrW;
112    fn rstr(&self) -> &Reg<Self::RSTRrs>;
113    fn chpr(&self) -> &tima::CHPR;
114    type CPT1CRrs: reg::CptcrW + Readable;
115    fn cpt1cr(&self) -> &Reg<Self::CPT1CRrs>;
116    fn cpt2cr(&self) -> &Reg<Self::CPT1CRrs>;
117    fn cptcr(&self, c: Chan) -> &Reg<Self::CPT1CRrs> {
118        match c {
119            Chan::Ch1 => self.cpt1cr(),
120            Chan::Ch2 => self.cpt2cr(),
121        }
122    }
123    fn outr(&self) -> &tima::OUTR;
124    fn fltr(&self) -> &tima::FLTR;
125    #[cfg(feature = "hrtim_v2")]
126    fn cr2(&self) -> &tima::CR2;
127    #[cfg(feature = "hrtim_v2")]
128    fn eefr3(&self) -> &tima::EEFR3;
129}
130
131macro_rules! wrap_r {
132    (pub trait $TrR:ident {
133        $(fn $f:ident(&self $(, $n:ident: $e:ty)?) -> $fr:path;)*
134    }) => {
135        pub trait $TrR {
136            $(fn $f(&self $(, $n: $e)?) -> $fr;)*
137        }
138        impl<REG: reg::$TrR> $TrR for R<REG> {
139            $(
140                #[inline(always)]
141                fn $f(&self $(, $n: $e)?) -> $fr {
142                    REG::$f(self $(, $n as u8)?)
143                }
144            )*
145        }
146    };
147}
148
149macro_rules! wrap_w {
150    (pub trait $TrR:ident {
151        $(fn $f:ident(&mut self $(, $n:ident: $e:ty)?) -> $fr:path;)*
152    }) => {
153        pub trait $TrR<REG: reg::$TrR> {
154            $(fn $f(&mut self $(, $n: $e)?) -> $fr;)*
155        }
156
157        impl<REG: reg::$TrR> $TrR<REG> for W<REG> {
158            $(
159                #[inline(always)]
160                fn $f(&mut self $(, $n: $e)?) -> $fr {
161                    REG::$f(self $(, $n as u8)?)
162                }
163            )*
164        }
165    };
166}
167
168wrap_r! {
169    pub trait MasterCrR {
170        fn ckpsc(&self) -> master::cr::CKPSC_R;
171        fn cont(&self) -> master::cr::CONT_R;
172        fn retrig(&self) -> master::cr::RETRIG_R;
173        fn half(&self) -> master::cr::HALF_R;
174        fn syncrst(&self) -> master::cr::SYNCRST_R;
175        fn syncstrt(&self) -> master::cr::SYNCSTRT_R;
176        fn dacsync(&self) -> master::cr::DACSYNC_R;
177        fn preen(&self) -> master::cr::PREEN_R;
178    }
179}
180
181wrap_w! {
182    pub trait MasterCrW {
183        fn ckpsc(&mut self) -> master::cr::CKPSC_W<REG>;
184        fn cont(&mut self) -> master::cr::CONT_W<REG>;
185        fn retrig(&mut self) -> master::cr::RETRIG_W<REG>;
186        fn half(&mut self) -> master::cr::HALF_W<REG>;
187        fn syncrst(&mut self) -> master::cr::SYNCRST_W<REG>;
188        fn syncstrt(&mut self) -> master::cr::SYNCSTRT_W<REG>;
189        fn dacsync(&mut self) -> master::cr::DACSYNC_W<REG>;
190        fn preen(&mut self) -> master::cr::PREEN_W<REG>;
191    }
192}
193
194wrap_r! {
195pub trait TimCrR {
196        fn pshpll(&self) -> tima::cr::PSHPLL_R;
197        fn delcmp2(&self) -> tima::cr::DELCMP2_R;
198        fn delcmp4(&self) -> tima::cr::DELCMP4_R;
199        fn mstu(&self) -> tima::cr::MSTU_R;
200        fn trepu(&self) -> tima::cr::TREPU_R;
201        fn trstu(&self) -> tima::cr::TRSTU_R;
202        fn updgat(&self) -> tima::cr::UPDGAT_R;
203    }
204}
205wrap_w! {
206    pub trait TimCrW {
207        fn pshpll(&mut self) -> tima::cr::PSHPLL_W<REG>;
208        fn delcmp2(&mut self) -> tima::cr::DELCMP2_W<REG>;
209        fn delcmp4(&mut self) -> tima::cr::DELCMP4_W<REG>;
210        fn mstu(&mut self) -> tima::cr::MSTU_W<REG>;
211        fn trepu(&mut self) -> tima::cr::TREPU_W<REG>;
212        fn trstu(&mut self) -> tima::cr::TRSTU_W<REG>;
213        fn updgat(&mut self) -> tima::cr::UPDGAT_W<REG>;
214    }
215}
216
217pub trait CptcrW<REG: reg::CptcrW> {
218    fn set_swcpt(&mut self) -> &mut Self;
219}
220impl<REG: reg::CptcrW> CptcrW<REG> for W<REG> {
221    #[inline(always)]
222    fn set_swcpt(&mut self) -> &mut Self {
223        REG::set_swcpt(self)
224    }
225}
226
227wrap_r! {
228    pub trait MasterIsr {
229        fn cmp(&self, cmp: Cmp) -> master::isr::CMP_R;
230        fn rep(&self) -> master::isr::REP_R;
231        fn upd(&self) -> master::isr::UPD_R;
232    }
233}
234wrap_w! {
235    pub trait MasterIcr {
236        fn cmpc(&mut self, cmp: Cmp) -> master::icr::CMPC_W<REG>;
237        fn repc(&mut self) -> master::icr::CMPC_W<REG>;
238        fn updc(&mut self) -> master::icr::CMPC_W<REG>;
239    }
240}
241
242wrap_r! {
243    pub trait MasterDierR {
244        fn cmpie(&self, cmp: Cmp) -> master::dier::CMPIE_R;
245        fn repie(&self) -> master::dier::REPIE_R;
246        fn updie(&self) -> master::dier::UPDIE_R;
247    }
248}
249
250wrap_w! {
251    pub trait MasterDierW {
252        fn cmpie(&mut self, cmp: Cmp) -> master::dier::CMPIE_W<REG>;
253        fn repie(&mut self) -> master::dier::REPIE_W<REG>;
254        fn updie(&mut self) -> master::dier::UPDIE_W<REG>;
255    }
256}
257
258wrap_r! {
259    pub trait Set1rR {
260        fn sst(&self) -> tima::set1r::SST_R;
261        fn resync(&self) -> tima::set1r::RESYNC_R;
262        fn per(&self) -> tima::set1r::PER_R;
263        fn cmp(&self, cmp: Cmp) -> tima::set1r::CMP_R;
264        fn mstper(&self) -> tima::set1r::MSTPER_R;
265        fn mstcmp(&self, cmp: Cmp) -> tima::set1r::MSTCMP_R;
266        fn extevnt(&self, e: ExtEvnt) -> tima::set1r::EXTEVNT_R;
267        fn update(&self) -> tima::set1r::UPDATE_R;
268    }
269}
270
271wrap_w! {
272    pub trait Set1rW {
273        fn sst(&mut self) -> tima::set1r::SST_W<REG>;
274        fn resync(&mut self) -> tima::set1r::RESYNC_W<REG>;
275        fn per(&mut self) -> tima::set1r::PER_W<REG>;
276        fn cmp(&mut self, cmp: Cmp) -> tima::set1r::CMP_W<REG>;
277        fn mstper(&mut self) -> tima::set1r::MSTPER_W<REG>;
278        fn mstcmp(&mut self, cmp: Cmp) -> tima::set1r::MSTCMP_W<REG>;
279        fn extevnt(&mut self, e: ExtEvnt) -> tima::set1r::EXTEVNT_W<REG>;
280        fn update(&mut self) -> tima::set1r::UPDATE_W<REG>;
281    }
282}
283
284wrap_r! {
285    pub trait Rst1rR {
286        fn srt(&self) -> tima::rst1r::SRT_R;
287        fn resync(&self) -> tima::rst1r::RESYNC_R;
288        fn per(&self) -> tima::rst1r::PER_R;
289        fn cmp(&self, cmp: Cmp) -> tima::rst1r::CMP_R;
290        fn mstper(&self) -> tima::rst1r::MSTPER_R;
291        fn mstcmp(&self, cmp: Cmp) -> tima::rst1r::MSTCMP_R;
292        fn extevnt(&self, e: ExtEvnt) -> tima::rst1r::EXTEVNT_R;
293        fn update(&self) -> tima::rst1r::UPDATE_R;
294    }
295}
296
297wrap_w! {
298    pub trait Rst1rW {
299        fn srt(&mut self) -> tima::rst1r::SRT_W<REG>;
300        fn resync(&mut self) -> tima::rst1r::RESYNC_W<REG>;
301        fn per(&mut self) -> tima::rst1r::PER_W<REG>;
302        fn cmp(&mut self, cmp: Cmp) -> tima::rst1r::CMP_W<REG>;
303        fn mstper(&mut self) -> tima::rst1r::MSTPER_W<REG>;
304        fn mstcmp(&mut self, cmp: Cmp) -> tima::rst1r::MSTCMP_W<REG>;
305        fn extevnt(&mut self, e: ExtEvnt) -> tima::rst1r::EXTEVNT_W<REG>;
306        fn update(&mut self) -> tima::rst1r::UPDATE_W<REG>;
307    }
308}
309
310wrap_r! {
311    pub trait RstrR {
312        fn updt(&self) -> tima::rstr::UPDT_R;
313        fn cmp2(&self) -> tima::rstr::CMP2_R;
314        fn cmp4(&self) -> tima::rstr::CMP2_R;
315        fn mstper(&self) -> tima::rstr::MSTPER_R;
316        fn mstcmp(&self, cmp: Cmp) -> tima::rstr::MSTCMP_R;
317        fn extevnt(&self, e: ExtEvnt) -> tima::rstr::EXTEVNT_R;
318    }
319}
320
321wrap_w! {
322    pub trait RstrW {
323        fn updt(&mut self) -> tima::rstr::UPDT_W<REG>;
324        fn cmp2(&mut self) -> tima::rstr::CMP2_W<REG>;
325        fn cmp4(&mut self) -> tima::rstr::CMP2_W<REG>;
326        fn mstper(&mut self) -> tima::rstr::MSTPER_W<REG>;
327        fn mstcmp(&mut self, cmp: Cmp) -> tima::rstr::MSTCMP_W<REG>;
328        fn extevnt(&mut self, e: ExtEvnt) -> tima::rstr::EXTEVNT_W<REG>;
329    }
330}
331
332mod reg {
333    use super::*;
334    pub trait MasterCrR: RegisterSpec<Ux = u32> + Readable + Sized {
335        fn ckpsc(r: &R<Self>) -> master::cr::CKPSC_R;
336        fn cont(r: &R<Self>) -> master::cr::CONT_R;
337        fn retrig(r: &R<Self>) -> master::cr::RETRIG_R;
338        fn half(r: &R<Self>) -> master::cr::HALF_R;
339        fn syncrst(r: &R<Self>) -> master::cr::SYNCRST_R;
340        fn syncstrt(r: &R<Self>) -> master::cr::SYNCSTRT_R;
341        fn dacsync(r: &R<Self>) -> master::cr::DACSYNC_R;
342        fn preen(r: &R<Self>) -> master::cr::PREEN_R;
343    }
344    pub trait MasterCrW: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
345        fn ckpsc(w: &mut W<Self>) -> master::cr::CKPSC_W<Self>;
346        fn cont(w: &mut W<Self>) -> master::cr::CONT_W<Self>;
347        fn retrig(w: &mut W<Self>) -> master::cr::RETRIG_W<Self>;
348        fn half(w: &mut W<Self>) -> master::cr::HALF_W<Self>;
349        fn syncrst(w: &mut W<Self>) -> master::cr::SYNCRST_W<Self>;
350        fn syncstrt(w: &mut W<Self>) -> master::cr::SYNCSTRT_W<Self>;
351        fn dacsync(w: &mut W<Self>) -> master::cr::DACSYNC_W<Self>;
352        fn preen(w: &mut W<Self>) -> master::cr::PREEN_W<Self>;
353    }
354
355    pub trait TimCrR: MasterCrR {
356        fn pshpll(r: &R<Self>) -> tima::cr::PSHPLL_R;
357        fn delcmp2(r: &R<Self>) -> tima::cr::DELCMP2_R;
358        fn delcmp4(r: &R<Self>) -> tima::cr::DELCMP4_R;
359        fn mstu(r: &R<Self>) -> tima::cr::MSTU_R;
360        fn trepu(r: &R<Self>) -> tima::cr::TREPU_R;
361        fn trstu(r: &R<Self>) -> tima::cr::TRSTU_R;
362        fn updgat(r: &R<Self>) -> tima::cr::UPDGAT_R;
363    }
364    pub trait TimCrW: MasterCrW {
365        fn pshpll(w: &mut W<Self>) -> tima::cr::PSHPLL_W<Self>;
366        fn delcmp2(w: &mut W<Self>) -> tima::cr::DELCMP2_W<Self>;
367        fn delcmp4(w: &mut W<Self>) -> tima::cr::DELCMP4_W<Self>;
368        fn mstu(w: &mut W<Self>) -> tima::cr::MSTU_W<Self>;
369        fn trepu(w: &mut W<Self>) -> tima::cr::TREPU_W<Self>;
370        fn trstu(w: &mut W<Self>) -> tima::cr::TRSTU_W<Self>;
371        fn updgat(w: &mut W<Self>) -> tima::cr::UPDGAT_W<Self>;
372    }
373
374    pub trait CptcrW: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
375        // TODO: replace this
376        fn set_swcpt(w: &mut W<Self>) -> &mut W<Self>;
377    }
378
379    pub trait MasterIsr: RegisterSpec<Ux = u32> + Readable + Sized {
380        fn cmp(r: &R<Self>, n: u8) -> master::isr::CMP_R;
381        fn rep(r: &R<Self>) -> master::isr::REP_R;
382        fn upd(r: &R<Self>) -> master::isr::UPD_R;
383    }
384    pub trait MasterIcr: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
385        fn cmpc(w: &mut W<Self>, n: u8) -> master::icr::CMPC_W<Self>;
386        fn repc(w: &mut W<Self>) -> master::icr::CMPC_W<Self>;
387        fn updc(w: &mut W<Self>) -> master::icr::CMPC_W<Self>;
388    }
389    pub trait MasterDierR: RegisterSpec<Ux = u32> + Readable + Sized {
390        fn cmpie(r: &R<Self>, n: u8) -> master::dier::CMPIE_R;
391        fn repie(r: &R<Self>) -> master::dier::REPIE_R;
392        fn updie(r: &R<Self>) -> master::dier::UPDIE_R;
393    }
394
395    pub trait MasterDierW: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
396        fn cmpie(w: &mut W<Self>, n: u8) -> master::dier::CMPIE_W<Self>;
397        fn repie(w: &mut W<Self>) -> master::dier::REPIE_W<Self>;
398        fn updie(w: &mut W<Self>) -> master::dier::UPDIE_W<Self>;
399    }
400
401    pub trait Set1rR: RegisterSpec<Ux = u32> + Readable + Sized {
402        fn sst(r: &R<Self>) -> tima::set1r::SST_R;
403        fn resync(r: &R<Self>) -> tima::set1r::RESYNC_R;
404        fn per(r: &R<Self>) -> tima::set1r::PER_R;
405        fn cmp(r: &R<Self>, n: u8) -> tima::set1r::CMP_R;
406        fn mstper(r: &R<Self>) -> tima::set1r::MSTPER_R;
407        fn mstcmp(r: &R<Self>, n: u8) -> tima::set1r::MSTCMP_R;
408        fn extevnt(r: &R<Self>, n: u8) -> tima::set1r::EXTEVNT_R;
409        fn update(r: &R<Self>) -> tima::set1r::UPDATE_R;
410    }
411    pub trait Set1rW: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
412        fn sst(w: &mut W<Self>) -> tima::set1r::SST_W<Self>;
413        fn resync(w: &mut W<Self>) -> tima::set1r::RESYNC_W<Self>;
414        fn per(w: &mut W<Self>) -> tima::set1r::PER_W<Self>;
415        fn cmp(w: &mut W<Self>, n: u8) -> tima::set1r::CMP_W<Self>;
416        fn mstper(w: &mut W<Self>) -> tima::set1r::MSTPER_W<Self>;
417        fn mstcmp(w: &mut W<Self>, n: u8) -> tima::set1r::MSTCMP_W<Self>;
418        fn extevnt(w: &mut W<Self>, n: u8) -> tima::set1r::EXTEVNT_W<Self>;
419        fn update(w: &mut W<Self>) -> tima::set1r::UPDATE_W<Self>;
420    }
421
422    pub trait Rst1rR: RegisterSpec<Ux = u32> + Readable + Sized {
423        fn srt(r: &R<Self>) -> tima::rst1r::SRT_R;
424        fn resync(r: &R<Self>) -> tima::rst1r::RESYNC_R;
425        fn per(r: &R<Self>) -> tima::rst1r::PER_R;
426        fn cmp(r: &R<Self>, n: u8) -> tima::rst1r::CMP_R;
427        fn mstper(r: &R<Self>) -> tima::rst1r::MSTPER_R;
428        fn mstcmp(r: &R<Self>, n: u8) -> tima::rst1r::MSTCMP_R;
429        fn extevnt(r: &R<Self>, n: u8) -> tima::rst1r::EXTEVNT_R;
430        fn update(r: &R<Self>) -> tima::rst1r::UPDATE_R;
431    }
432    pub trait Rst1rW: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
433        fn srt(w: &mut W<Self>) -> tima::rst1r::SRT_W<Self>;
434        fn resync(w: &mut W<Self>) -> tima::rst1r::RESYNC_W<Self>;
435        fn per(w: &mut W<Self>) -> tima::rst1r::PER_W<Self>;
436        fn cmp(w: &mut W<Self>, n: u8) -> tima::rst1r::CMP_W<Self>;
437        fn mstper(w: &mut W<Self>) -> tima::rst1r::MSTPER_W<Self>;
438        fn mstcmp(w: &mut W<Self>, n: u8) -> tima::rst1r::MSTCMP_W<Self>;
439        fn extevnt(w: &mut W<Self>, n: u8) -> tima::rst1r::EXTEVNT_W<Self>;
440        fn update(w: &mut W<Self>) -> tima::rst1r::UPDATE_W<Self>;
441    }
442
443    pub trait RstrR: RegisterSpec<Ux = u32> + Readable + Sized {
444        fn updt(r: &R<Self>) -> tima::rstr::UPDT_R;
445        fn cmp2(r: &R<Self>) -> tima::rstr::CMP2_R;
446        fn cmp4(r: &R<Self>) -> tima::rstr::CMP2_R;
447        fn mstper(r: &R<Self>) -> tima::rstr::MSTPER_R;
448        fn mstcmp(r: &R<Self>, n: u8) -> tima::rstr::MSTCMP_R;
449        fn extevnt(r: &R<Self>, n: u8) -> tima::rstr::EXTEVNT_R;
450    }
451    pub trait RstrW: RegisterSpec<Ux = u32> + Writable + Resettable + Sized {
452        fn updt(w: &mut W<Self>) -> tima::rstr::UPDT_W<Self>;
453        fn cmp2(w: &mut W<Self>) -> tima::rstr::CMP2_W<Self>;
454        fn cmp4(w: &mut W<Self>) -> tima::rstr::CMP2_W<Self>;
455        fn mstper(w: &mut W<Self>) -> tima::rstr::MSTPER_W<Self>;
456        fn mstcmp(w: &mut W<Self>, n: u8) -> tima::rstr::MSTCMP_W<Self>;
457        fn extevnt(w: &mut W<Self>, n: u8) -> tima::rstr::EXTEVNT_W<Self>;
458    }
459}
460
461macro_rules! impl_reg {
462    ($($r:ident -> &$rty:path;)*) => {
463        $(
464            #[inline(always)]
465            fn $r(&self) -> &$rty {
466                self.$r()
467            }
468        )*
469    };
470}
471
472macro_rules! impl_read {
473    ($($f:ident $(: $n:ident)? -> $fty:path;)*) => {
474        $(
475            #[inline(always)]
476            fn $f(r: &R<Self> $(, $n: u8)?) -> $fty {
477                r.$f($($n)?)
478            }
479        )*
480    };
481}
482macro_rules! impl_write {
483    ($($f:ident $(: $n:ident)? -> $fty:path;)*) => {
484        $(
485            #[inline(always)]
486            fn $f(w: &mut W<Self> $(, $n: u8)?) -> $fty {
487                w.$f($($n)?)
488            }
489        )*
490    };
491}
492
493macro_rules! impl_master_ext {
494    ($tim:ident) => {
495        impl MasterExt for $tim::RegisterBlock {
496            type CRrs = $tim::cr::CRrs;
497            type ISRrs = $tim::isr::ISRrs;
498            type ICRrs = $tim::icr::ICRrs;
499            type DIERrs = $tim::dier::DIERrs;
500            impl_reg! {
501                isr -> &Reg<Self::ISRrs>;
502                icr -> &Reg<Self::ICRrs>;
503                dier -> &Reg<Self::DIERrs>;
504                cr -> &Reg<Self::CRrs>;
505                cntr -> &master::CNTR;
506                perr -> &master::PERR;
507                repr -> &master::REPR;
508                cmp1r -> &master::CMP1R;
509                cmp2r -> &master::CMP1R;
510                cmp3r -> &master::CMP1R;
511                cmp4r -> &master::CMP1R;
512            }
513        }
514
515        impl reg::MasterCrR for $tim::cr::CRrs {
516            impl_read! {
517                ckpsc -> master::cr::CKPSC_R;
518                cont -> master::cr::CONT_R;
519                retrig -> master::cr::RETRIG_R;
520                half -> master::cr::HALF_R;
521                syncrst -> master::cr::SYNCRST_R;
522                syncstrt -> master::cr::SYNCSTRT_R;
523                dacsync -> master::cr::DACSYNC_R;
524                preen -> master::cr::PREEN_R;
525            }
526        }
527        impl reg::MasterCrW for $tim::cr::CRrs {
528            impl_write! {
529                ckpsc -> master::cr::CKPSC_W<Self>;
530                cont -> master::cr::CONT_W<Self>;
531                retrig -> master::cr::RETRIG_W<Self>;
532                half -> master::cr::HALF_W<Self>;
533                syncrst -> master::cr::SYNCRST_W<Self>;
534                syncstrt -> master::cr::SYNCSTRT_W<Self>;
535                dacsync -> master::cr::DACSYNC_W<Self>;
536                preen -> master::cr::PREEN_W<Self>;
537            }
538        }
539    };
540}
541
542impl_master_ext!(master);
543impl_master_ext!(tima);
544impl_master_ext!(timb);
545impl_master_ext!(timc);
546impl_master_ext!(timd);
547impl_master_ext!(time);
548#[cfg(feature = "hrtim_v2")]
549impl_master_ext!(timf);
550
551macro_rules! impl_tim_ext {
552    ($tim:ident) => {
553        impl TimExt for $tim::RegisterBlock {
554            type SET1Rrs = $tim::set1r::SET1Rrs;
555            type RST1Rrs = $tim::rst1r::RST1Rrs;
556            type RSTRrs = $tim::rstr::RSTRrs;
557            type CPT1CRrs = $tim::cpt1cr::CPT1CRrs;
558            impl_reg! {
559                cmp1cr -> &tima::CMP1CR;
560                cpt1r -> &tima::CPT1R;
561                cpt2r -> &tima::CPT1R;
562                dtr -> &tima::DTR;
563                eefr1 -> &tima::EEFR1;
564                eefr2 -> &tima::EEFR2;
565                set1r -> &Reg<Self::SET1Rrs>;
566                rst1r -> &Reg<Self::RST1Rrs>;
567                set2r -> &Reg<Self::SET1Rrs>;
568                rst2r -> &Reg<Self::RST1Rrs>;
569                rstr -> &Reg<Self::RSTRrs>;
570                chpr -> &tima::CHPR;
571                cpt1cr -> &Reg<Self::CPT1CRrs>;
572                cpt2cr -> &Reg<Self::CPT1CRrs>;
573                outr -> &tima::OUTR;
574                fltr -> &tima::FLTR;
575            }
576            #[cfg(feature = "hrtim_v2")]
577            impl_reg! {
578                cr2 -> &tima::CR2;
579                eefr3 -> &tima::EEFR3;
580            }
581        }
582
583        impl reg::TimCrR for $tim::cr::CRrs {
584            impl_read! {
585                pshpll -> tima::cr::PSHPLL_R;
586                delcmp2 -> tima::cr::DELCMP2_R;
587                delcmp4 -> tima::cr::DELCMP4_R;
588                mstu -> tima::cr::MSTU_R;
589                trepu -> tima::cr::TREPU_R;
590                trstu -> tima::cr::TRSTU_R;
591                updgat -> tima::cr::UPDGAT_R;
592            }
593        }
594        impl reg::TimCrW for $tim::cr::CRrs {
595            impl_write! {
596                pshpll -> tima::cr::PSHPLL_W<Self>;
597                delcmp2 -> tima::cr::DELCMP2_W<Self>;
598                delcmp4 -> tima::cr::DELCMP4_W<Self>;
599                mstu -> tima::cr::MSTU_W<Self>;
600                trepu -> tima::cr::TREPU_W<Self>;
601                trstu -> tima::cr::TRSTU_W<Self>;
602                updgat -> tima::cr::UPDGAT_W<Self>;
603            }
604        }
605
606        impl reg::CptcrW for $tim::cpt1cr::CPT1CRrs {
607            #[inline(always)]
608            fn set_swcpt(w: &mut W<Self>) -> &mut W<Self> {
609                w.swcpt().set_bit()
610            }
611        }
612
613        impl reg::Set1rR for $tim::set1r::SET1Rrs {
614            impl_read! {
615                sst -> tima::set1r::SST_R;
616                resync -> tima::set1r::RESYNC_R;
617                per -> tima::set1r::PER_R;
618                cmp: n -> tima::set1r::CMP_R;
619                mstper -> tima::set1r::MSTPER_R;
620                mstcmp: n -> tima::set1r::MSTCMP_R;
621                extevnt: n -> tima::set1r::EXTEVNT_R;
622                update -> tima::set1r::UPDATE_R;
623            }
624        }
625        impl reg::Set1rW for $tim::set1r::SET1Rrs {
626            impl_write! {
627                sst -> tima::set1r::SST_W<Self>;
628                resync -> tima::set1r::RESYNC_W<Self>;
629                per -> tima::set1r::PER_W<Self>;
630                cmp: n -> tima::set1r::CMP_W<Self>;
631                mstper -> tima::set1r::MSTPER_W<Self>;
632                mstcmp: n -> tima::set1r::MSTCMP_W<Self>;
633                extevnt: n -> tima::set1r::EXTEVNT_W<Self>;
634                update -> tima::set1r::UPDATE_W<Self>;
635            }
636        }
637
638        impl reg::Rst1rR for $tim::rst1r::RST1Rrs {
639            impl_read! {
640                srt -> tima::rst1r::SRT_R;
641                resync -> tima::rst1r::RESYNC_R;
642                per -> tima::rst1r::PER_R;
643                cmp: n -> tima::rst1r::CMP_R;
644                mstper -> tima::rst1r::MSTPER_R;
645                mstcmp: n -> tima::rst1r::MSTCMP_R;
646                extevnt: n -> tima::rst1r::EXTEVNT_R;
647                update -> tima::rst1r::UPDATE_R;
648            }
649        }
650        impl reg::Rst1rW for $tim::rst1r::RST1Rrs {
651            impl_write! {
652                srt -> tima::rst1r::SRT_W<Self>;
653                resync -> tima::rst1r::RESYNC_W<Self>;
654                per -> tima::rst1r::PER_W<Self>;
655                cmp: n -> tima::rst1r::CMP_W<Self>;
656                mstper -> tima::rst1r::MSTPER_W<Self>;
657                mstcmp: n -> tima::rst1r::MSTCMP_W<Self>;
658                extevnt: n -> tima::rst1r::EXTEVNT_W<Self>;
659                update -> tima::rst1r::UPDATE_W<Self>;
660            }
661        }
662
663        impl reg::RstrR for $tim::rstr::RSTRrs {
664            impl_read! {
665                updt -> tima::rstr::UPDT_R;
666                cmp2 -> tima::rstr::CMP2_R;
667                cmp4 -> tima::rstr::CMP2_R;
668                mstper -> tima::rstr::MSTPER_R;
669                mstcmp: n -> tima::rstr::MSTCMP_R;
670                extevnt: n -> tima::rstr::EXTEVNT_R;
671            }
672        }
673        impl reg::RstrW for $tim::rstr::RSTRrs {
674            impl_write! {
675                updt -> tima::rstr::UPDT_W<Self>;
676                cmp2 -> tima::rstr::CMP2_W<Self>;
677                cmp4 -> tima::rstr::CMP2_W<Self>;
678                mstper -> tima::rstr::MSTPER_W<Self>;
679                mstcmp: n -> tima::rstr::MSTCMP_W<Self>;
680                extevnt: n -> tima::rstr::EXTEVNT_W<Self>;
681            }
682        }
683    };
684}
685
686impl_tim_ext!(tima);
687impl_tim_ext!(timb);
688impl_tim_ext!(timc);
689impl_tim_ext!(timd);
690impl_tim_ext!(time);
691#[cfg(feature = "hrtim_v2")]
692impl_tim_ext!(timf);
693
694macro_rules! impl_irq_ext {
695    ($tim:ident) => {
696        impl reg::MasterIsr for $tim::isr::ISRrs {
697            impl_read! {
698                cmp: n -> master::isr::CMP_R;
699                rep -> master::isr::REP_R;
700                upd -> master::isr::UPD_R;
701            }
702        }
703
704        impl reg::MasterIcr for $tim::icr::ICRrs {
705            impl_write! {
706                cmpc: n -> master::icr::CMPC_W<Self>;
707                repc -> master::icr::CMPC_W<Self>;
708                updc -> master::icr::CMPC_W<Self>;
709            }
710        }
711
712        impl reg::MasterDierR for $tim::dier::DIERrs {
713            impl_read! {
714                cmpie: n -> master::dier::CMPIE_R;
715                repie -> master::dier::REPIE_R;
716                updie -> master::dier::UPDIE_R;
717            }
718        }
719        impl reg::MasterDierW for $tim::dier::DIERrs {
720            impl_write! {
721                cmpie: n -> master::dier::CMPIE_W<Self>;
722                repie -> master::dier::REPIE_W<Self>;
723                updie -> master::dier::UPDIE_W<Self>;
724            }
725        }
726    };
727}
728
729impl_irq_ext!(master);
730impl_irq_ext!(tima);