Skip to content

Commit 86d3a65

Browse files
committed
Add AF10
1 parent c1e1feb commit 86d3a65

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/gpio.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ macro_rules! gpio {
112112
use crate::rcc::AHB2;
113113
use super::{
114114
Alternate,
115-
AF1, AF4, AF5, AF6, AF7, AF8, AF9,
115+
AF1, AF4, AF5, AF6, AF7, AF8, AF9, AF10,
116116
Floating, GpioExt, Input, OpenDrain, Output,
117117
PullDown, PullUp, PushPull, State,
118118
};
@@ -402,6 +402,30 @@ macro_rules! gpio {
402402
$PXi { _mode: PhantomData }
403403
}
404404

405+
/// Configures the pin to serve as alternate function 10 (AF10)
406+
pub fn into_af10(
407+
self,
408+
moder: &mut MODER,
409+
afr: &mut $AFR,
410+
) -> $PXi<Alternate<AF10, MODE>> {
411+
let offset = 2 * $i;
412+
413+
// alternate function mode
414+
let mode = 0b10;
415+
moder.moder().modify(|r, w| unsafe {
416+
w.bits((r.bits() & !(0b11 << offset)) | (mode << offset))
417+
});
418+
419+
let af = 10;
420+
let offset = 4 * ($i % 8);
421+
422+
afr.afr().modify(|r, w| unsafe {
423+
w.bits((r.bits() & !(0b1111 << offset)) | (af << offset))
424+
});
425+
426+
$PXi { _mode: PhantomData }
427+
}
428+
405429
/// Configures the pin to operate as a floating input pin
406430
pub fn into_floating_input(
407431
self,

0 commit comments

Comments
 (0)