@@ -48,6 +48,14 @@ pub struct Rcc {
48
48
}
49
49
50
50
/// AMBA High-performance Bus (AHB) registers
51
+ ///
52
+ /// Aquired through the `Rcc` registers:
53
+ ///
54
+ /// ```rust
55
+ /// let dp = pac::Peripherals::take().unwrap();
56
+ /// let mut rcc = dp.RCC.constrain();
57
+ /// function_that_uses_ahb(&mut rcc.ahb)
58
+ /// ```
51
59
pub struct AHB {
52
60
_0 : ( ) ,
53
61
}
@@ -62,6 +70,14 @@ impl AHB {
62
70
}
63
71
64
72
/// Advanced Peripheral Bus 1 (APB1) registers
73
+ ///
74
+ /// Aquired through the `Rcc` registers:
75
+ ///
76
+ /// ```rust
77
+ /// let dp = pac::Peripherals::take().unwrap();
78
+ /// let mut rcc = dp.RCC.constrain();
79
+ /// function_that_uses_apb1(&mut rcc.apb1)
80
+ /// ```
65
81
pub struct APB1 {
66
82
_0 : ( ) ,
67
83
}
@@ -86,6 +102,14 @@ impl APB1 {
86
102
}
87
103
88
104
/// Advanced Peripheral Bus 2 (APB2) registers
105
+ ///
106
+ /// Aquired through the `Rcc` registers:
107
+ ///
108
+ /// ```rust
109
+ /// let dp = pac::Peripherals::take().unwrap();
110
+ /// let mut rcc = dp.RCC.constrain();
111
+ /// function_that_uses_apb2(&mut rcc.apb2);
112
+ /// ```
89
113
pub struct APB2 {
90
114
_0 : ( ) ,
91
115
}
@@ -104,6 +128,15 @@ impl APB2 {
104
128
105
129
const HSI : u32 = 8_000_000 ; // Hz
106
130
131
+ /// Clock configuration register (CFGR)
132
+ ///
133
+ /// Used to configure the frequencies of the clocks present in the processor.
134
+ ///
135
+ /// After setting all frequencies, call the [freeze](#method.freeze) function to
136
+ /// apply the configuration.
137
+ ///
138
+ /// **NOTE**: Currently, it is not guaranteed that the exact frequencies selected will be
139
+ /// used, only frequencies close to it.
107
140
pub struct CFGR {
108
141
hse : Option < u32 > ,
109
142
hclk : Option < u32 > ,
@@ -116,6 +149,7 @@ pub struct CFGR {
116
149
impl CFGR {
117
150
/// Uses HSE (external oscillator) instead of HSI (internal RC oscillator) as the clock source.
118
151
/// Will result in a hang if an external oscillator is not connected or it fails to start.
152
+ /// The frequency specified must be the frequency of the external oscillator
119
153
pub fn use_hse < F > ( mut self , freq : F ) -> Self
120
154
where
121
155
F : Into < Hertz > ,
@@ -415,6 +449,16 @@ impl BKP {
415
449
/// Frozen clock frequencies
416
450
///
417
451
/// The existence of this value indicates that the clock configuration can no longer be changed
452
+ ///
453
+ /// To acquire it, use the freeze function on the `rcc.cfgr` register. If desired, you can adjust
454
+ /// the frequencies using the methods on [cfgr](struct.CFGR.html) before calling freeze.
455
+ ///
456
+ /// ```rust
457
+ /// let dp = pac::Peripherals::take().unwrap();
458
+ /// let mut rcc = dp.RCC.constrain();
459
+ ///
460
+ /// let clocks = rcc.cfgr.freeze(&mut flash.acr);
461
+ /// ```
418
462
#[ derive( Clone , Copy ) ]
419
463
pub struct Clocks {
420
464
hclk : Hertz ,
0 commit comments