@@ -416,46 +416,64 @@ impl Clocks {
416
416
}
417
417
}
418
418
419
- pub trait GetBusFreq {
420
- fn get_frequency ( clocks : & Clocks ) -> Hertz ;
421
- fn get_timer_frequency ( clocks : & Clocks ) -> Hertz {
422
- Self :: get_frequency ( clocks)
423
- }
419
+ /// Frequency on bus that peripheral is connected in
420
+ pub trait BusClock {
421
+ /// Calculates frequency depending on `Clock` state
422
+ fn clock ( clocks : & Clocks ) -> Hertz ;
423
+ }
424
+
425
+ /// Frequency on bus that timer is connected in
426
+ pub trait BusTimerClock {
427
+ /// Calculates base frequency of timer depending on `Clock` state
428
+ fn timer_clock ( clocks : & Clocks ) -> Hertz ;
424
429
}
425
430
426
- impl < T > GetBusFreq for T
431
+ impl < T > BusClock for T
427
432
where
428
433
T : RccBus ,
429
- T :: Bus : GetBusFreq ,
434
+ T :: Bus : BusClock ,
430
435
{
431
- fn get_frequency ( clocks : & Clocks ) -> Hertz {
432
- T :: Bus :: get_frequency ( clocks)
436
+ fn clock ( clocks : & Clocks ) -> Hertz {
437
+ T :: Bus :: clock ( clocks)
433
438
}
434
- fn get_timer_frequency ( clocks : & Clocks ) -> Hertz {
435
- T :: Bus :: get_timer_frequency ( clocks)
439
+ }
440
+
441
+ impl < T > BusTimerClock for T
442
+ where
443
+ T : RccBus ,
444
+ T :: Bus : BusTimerClock ,
445
+ {
446
+ fn timer_clock ( clocks : & Clocks ) -> Hertz {
447
+ T :: Bus :: timer_clock ( clocks)
436
448
}
437
449
}
438
450
439
- impl GetBusFreq for AHB {
440
- fn get_frequency ( clocks : & Clocks ) -> Hertz {
451
+ impl BusClock for AHB {
452
+ fn clock ( clocks : & Clocks ) -> Hertz {
441
453
clocks. hclk
442
454
}
443
455
}
444
456
445
- impl GetBusFreq for APB1 {
446
- fn get_frequency ( clocks : & Clocks ) -> Hertz {
457
+ impl BusClock for APB1 {
458
+ fn clock ( clocks : & Clocks ) -> Hertz {
447
459
clocks. pclk1
448
460
}
449
- fn get_timer_frequency ( clocks : & Clocks ) -> Hertz {
450
- clocks. pclk1_tim ( )
451
- }
452
461
}
453
462
454
- impl GetBusFreq for APB2 {
455
- fn get_frequency ( clocks : & Clocks ) -> Hertz {
463
+ impl BusClock for APB2 {
464
+ fn clock ( clocks : & Clocks ) -> Hertz {
456
465
clocks. pclk2
457
466
}
458
- fn get_timer_frequency ( clocks : & Clocks ) -> Hertz {
467
+ }
468
+
469
+ impl BusTimerClock for APB1 {
470
+ fn timer_clock ( clocks : & Clocks ) -> Hertz {
471
+ clocks. pclk1_tim ( )
472
+ }
473
+ }
474
+
475
+ impl BusTimerClock for APB2 {
476
+ fn timer_clock ( clocks : & Clocks ) -> Hertz {
459
477
clocks. pclk2_tim ( )
460
478
}
461
479
}
0 commit comments