You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/gpio.rs
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,26 @@
1
1
//! General Purpose Input / Output
2
+
//!
3
+
//! To use the GPIO pins, you first need to configure the GPIO bank (GPIOA, GPIOB, ...) that you
4
+
//! are interested in. This is done using the [GpioExt::split](trait.GpioExt.html#tymethod.split) function.
5
+
//!
6
+
//! ```
7
+
//! let dp = pac::Peripherals::take().unwrap();
8
+
//! let rcc = dp.RCC.constrain();
9
+
//!
10
+
//! let mut gpioa = dp.GPIOA.split(&mut rcc.ahb);
11
+
//! ```
12
+
//!
13
+
//! The resulting [Parts](gpioa/struct.Parts.html) struct contains one field for each
14
+
//! pin, as well as some shared register.
15
+
//!
16
+
//! To use a pin, first use the relevant `into_...` function in the [pin](gpioa/struct.PA0.html).
17
+
//!
18
+
//! ```rust
19
+
//! let pa0 = gpioa.pa0.into_push_pull_output(&mut gpioa.moder, &mut gpioa.otyper);
20
+
//! ```
21
+
//!
22
+
//! And finally, you can use the functions from the [InputPin](../prelude/trait._embedded_hal_digital_InputPin.html) or [OutputPin](../prelude/trait._embedded_hal_digital_OutputPin.html) traits in
Copy file name to clipboardExpand all lines: src/rcc.rs
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,13 @@ impl RccExt for RCC {
32
32
}
33
33
34
34
/// Constrained RCC peripheral
35
+
///
36
+
/// An instance of this struct is aquired by calling the [constrain](trait.RccExt.html#tymethod.constrain) function on the [pac::RCC](../pac/struct.RCC.html) struct.
37
+
///
38
+
/// ```
39
+
/// let dp = pac::Peripherals::take().unwrap();
40
+
/// let rcc = dp.RCC.constrain();
41
+
/// ```
35
42
pubstructRcc{
36
43
/// AMBA High-performance Bus (AHB) registers
37
44
pubahb:AHB,
@@ -44,6 +51,14 @@ pub struct Rcc {
44
51
}
45
52
46
53
/// AMBA High-performance Bus (AHB) registers
54
+
///
55
+
/// An instance of this struct is aquired from the [Rcc](../struct.Rcc.html) struct.
56
+
///
57
+
/// ```
58
+
/// let dp = pac::Peripherals::take().unwrap();
59
+
/// let rcc = dp.RCC.constrain();
60
+
/// use_ahb(&mut rcc.ahb)
61
+
/// ```
47
62
pubstructAHB{
48
63
_0:(),
49
64
}
@@ -61,6 +76,14 @@ impl AHB {
61
76
}
62
77
63
78
/// Advanced Peripheral Bus 1 (APB1) registers
79
+
///
80
+
/// An instance of this struct is aquired from the [Rcc](../struct.Rcc.html) struct.
81
+
///
82
+
/// ```
83
+
/// let dp = pac::Peripherals::take().unwrap();
84
+
/// let rcc = dp.RCC.constrain();
85
+
/// use_ahb(&mut rcc.apb1)
86
+
/// ```
64
87
pubstructAPB1{
65
88
_0:(),
66
89
}
@@ -78,6 +101,14 @@ impl APB1 {
78
101
}
79
102
80
103
/// Advanced Peripheral Bus 2 (APB2) registers
104
+
///
105
+
/// An instance of this struct is aquired from the [Rcc](../struct.Rcc.html) struct.
106
+
///
107
+
/// ```
108
+
/// let dp = pac::Peripherals::take().unwrap();
109
+
/// let rcc = dp.RCC.constrain();
110
+
/// use_ahb(&mut rcc.apb2)
111
+
/// ```
81
112
pubstructAPB2{
82
113
_0:(),
83
114
}
@@ -159,6 +190,14 @@ mod usb_clocking {
159
190
}
160
191
161
192
/// Clock configuration
193
+
///
194
+
/// An instance of this struct is aquired from the [Rcc](../struct.Rcc.html) struct.
0 commit comments