Skip to content

Commit 85d83a4

Browse files
committed
Added compatibility constants to keep Alternate<AFx> working just as before
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
1 parent a1935a3 commit 85d83a4

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12-
- Instead of `Alternate<AF1>` use just `Alternate<1>`.
12+
- Instead of `Alternate<AF1>` you can just use `Alternate<1>`.
1313
- `PinState` and `get/set_state`.
1414
- Inherent methods for infallible digital operations.
1515
- Generic `into_alternate` and `into_alternate_open_drain`. Non-generic ones are deprecated
16-
- Internal implementation of GPIO Pin API changed to use Const Generics
1716
- `PinExt` trait. Make `ExtiPin` implementation generic
1817
- `Enable`, `LPEnable` and `Reset` traits in `rcc`. Implemented for all used peripherals
1918
- Features corresponding to peripherals
@@ -39,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3938

4039
### Changed
4140

41+
- Internal implementation of GPIO Pin API changed to use Const Generics
4242
- Update the sdio driver to match the changes in the PAC
4343
- Update README.md with current information
4444
- Updated serial driver to use 32-bit reads and writes when accessing the USART data register [#299]

examples/i2s-audio-out-dma.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ use stm32f4xx_hal::dma::{Channel0, Stream5, StreamsTuple, Transfer};
5555
use stm32f4xx_hal::gpio::gpioa::PA4;
5656
use stm32f4xx_hal::gpio::gpioc::{PC10, PC12, PC7};
5757
use stm32f4xx_hal::gpio::Alternate;
58+
use stm32f4xx_hal::gpio::AF6;
5859
use stm32f4xx_hal::i2c::I2c;
5960
use stm32f4xx_hal::i2s::I2s;
6061
use stm32f4xx_hal::pac::{interrupt, Interrupt};
@@ -216,10 +217,10 @@ type I2sDmaTransfer = Transfer<
216217
I2s<
217218
SPI3,
218219
(
219-
PA4<Alternate<6>>,
220-
PC10<Alternate<6>>,
221-
PC7<Alternate<6>>,
222-
PC12<Alternate<6>>,
220+
PA4<Alternate<AF6>>,
221+
PC10<Alternate<AF6>>,
222+
PC7<Alternate<AF6>>,
223+
PC12<Alternate<AF6>>,
223224
),
224225
>,
225226
TransmitMode<Data16Frame16>,

src/gpio.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ pub struct Alternate<const A: u8>;
3333
/// Some alternate mode in open drain configuration (type state)
3434
pub struct AlternateOD<const A: u8>;
3535

36+
// Compatibility constants
37+
pub const AF0: u8 = 0;
38+
pub const AF1: u8 = 1;
39+
pub const AF2: u8 = 2;
40+
pub const AF3: u8 = 3;
41+
pub const AF4: u8 = 4;
42+
pub const AF5: u8 = 5;
43+
pub const AF6: u8 = 6;
44+
pub const AF7: u8 = 7;
45+
pub const AF8: u8 = 8;
46+
pub const AF9: u8 = 9;
47+
pub const AF10: u8 = 10;
48+
pub const AF11: u8 = 11;
49+
pub const AF12: u8 = 12;
50+
pub const AF13: u8 = 13;
51+
pub const AF14: u8 = 14;
52+
pub const AF15: u8 = 15;
53+
3654
/// Input mode (type state)
3755
pub struct Input<MODE> {
3856
_mode: PhantomData<MODE>,

0 commit comments

Comments
 (0)