|
17 | 17 | //! let rcc = ctx.device.RCC.constrain();
|
18 | 18 | //! let clocks = rcc
|
19 | 19 | //! .cfgr
|
20 |
| -//! .use_hse(8.mhz()) |
21 |
| -//! .saia_clk(172.mhz()) |
22 |
| -//! .saib_clk(172.mhz()) |
| 20 | +//! .use_hse(8.MHz()) |
| 21 | +//! .saia_clk(172.MHz()) |
| 22 | +//! .saib_clk(172.MHz()) |
23 | 23 | //! .freeze();
|
24 | 24 | //! // Test that the SAI clock is suitable for 48000KHz audio.
|
25 |
| -//! assert!(clocks.saia_clk().unwrap() == 172.mhz().into()); |
26 |
| -//! assert!(clocks.saib_clk().unwrap() == 172.mhz().into()); |
| 25 | +//! assert!(clocks.saia_clk().unwrap() == 172.MHz().into()); |
| 26 | +//! assert!(clocks.saib_clk().unwrap() == 172.MHz().into()); |
27 | 27 | //!
|
28 | 28 | //! let gpioe = ctx.device.GPIOE.split();
|
29 | 29 | //! // SAIB is made synchronous to A.
|
|
36 | 36 | //! };
|
37 | 37 | //! let tx = saia.master_tx(
|
38 | 38 | //! (
|
39 |
| -//! gpioe.pe2.into_alternate_af6(), |
40 |
| -//! gpioe.pe4.into_alternate_af6(), |
41 |
| -//! gpioe.pe5.into_alternate_af6(), |
42 |
| -//! gpioe.pe6.into_alternate_af6(), |
| 39 | +//! gpioe.pe2.into_alternate(), |
| 40 | +//! gpioe.pe4.into_alternate(), |
| 41 | +//! gpioe.pe5.into_alternate(), |
| 42 | +//! gpioe.pe6.into_alternate(), |
43 | 43 | //! ),
|
44 | 44 | //! protocol,
|
45 |
| -//! 48000.hz(), |
| 45 | +//! 48.kHz(), |
46 | 46 | //! clocks,
|
47 | 47 | //! );
|
48 |
| -//! let rx = saib.slave_rx(gpioe.pe3.into_alternate_af6(), protocol); |
| 48 | +//! let rx = saib.slave_rx(gpioe.pe3.into_alternate(), protocol); |
49 | 49 | //!
|
50 | 50 | //! let mut duplex = Duplex::new(rx, tx);
|
51 | 51 | //! duplex.start();
|
|
63 | 63 | //! let rcc = ctx.device.RCC.constrain();
|
64 | 64 | //! let clocks = rcc
|
65 | 65 | //! .cfgr
|
66 |
| -//! .use_hse(8.mhz()) |
67 |
| -//! .saia_clk(172.mhz()) |
| 66 | +//! .use_hse(8.MHz()) |
| 67 | +//! .saia_clk(172.MHz()) |
68 | 68 | //! .freeze();
|
69 | 69 | //! // Test that the SAI clock is suitable for 48000KHz audio.
|
70 |
| -//! assert!(clocks.saia_clk().unwrap() == 172.mhz().into()); |
| 70 | +//! assert!(clocks.saia_clk().unwrap() == 172.MHz()); |
71 | 71 | //!
|
72 | 72 | //! let gpioe = ctx.device.GPIOE.split();
|
73 | 73 | //! let (saia, _) = ctx.device.SAI.split();
|
|
80 | 80 | //! };
|
81 | 81 | //! let mut tx = saia.master_tx(
|
82 | 82 | //! (
|
83 |
| -//! gpioe.pe2.into_alternate_af6(), |
84 |
| -//! gpioe.pe4.into_alternate_af6(), |
85 |
| -//! gpioe.pe5.into_alternate_af6(), |
86 |
| -//! gpioe.pe6.into_alternate_af6(), |
| 83 | +//! gpioe.pe2.into_alternate(), |
| 84 | +//! gpioe.pe4.into_alternate(), |
| 85 | +//! gpioe.pe5.into_alternate(), |
| 86 | +//! gpioe.pe6.into_alternate(), |
87 | 87 | //! ),
|
88 | 88 | //! protocol,
|
89 |
| -//! 48000.hz(), |
| 89 | +//! 48.kHz(), |
90 | 90 | //! clocks,
|
91 | 91 | //! );
|
92 | 92 | //! tx.start();
|
|
106 | 106 | use core::marker::PhantomData;
|
107 | 107 | use core::ops::Deref;
|
108 | 108 |
|
109 |
| -use crate::gpio::gpiod::PD6; |
110 |
| -use crate::gpio::gpioe::{PE2, PE3, PE4, PE5, PE6}; |
111 |
| -use crate::gpio::gpiof::{PF6, PF7, PF8, PF9}; |
112 |
| -use crate::gpio::{Alternate, AF6}; |
| 109 | +use crate::gpio::{self, AF6, NoPin}; |
113 | 110 | use crate::rcc::Clocks;
|
114 |
| -use crate::stm32::RCC; |
| 111 | +use crate::pac::RCC; |
115 | 112 | #[cfg(not(feature = "stm32f446"))]
|
116 |
| -use crate::stm32::{sai, SAI}; |
| 113 | +use crate::pac::{sai, SAI}; |
117 | 114 | #[cfg(feature = "stm32f446")]
|
118 |
| -use crate::stm32::{SAI1, SAI2}; |
| 115 | +use crate::pac::{SAI1, SAI2}; |
119 | 116 | use crate::time::Hertz;
|
120 | 117 |
|
121 | 118 | /// SAI A sub-block.
|
@@ -175,7 +172,7 @@ where
|
175 | 172 | }
|
176 | 173 |
|
177 | 174 | /// A filler type for when the MCK pin is unnecessary
|
178 |
| -pub struct NoMck; |
| 175 | +pub type NoMck = NoPin; |
179 | 176 |
|
180 | 177 | macro_rules! pins {
|
181 | 178 | ($($CH:ty: MCK: [$($MCK:ty),*] FS: [$($FS:ty),*] SCK: [$($SCK:ty),*] SD: [$($SD:ty),*])+) => {
|
@@ -206,32 +203,32 @@ pins! {
|
206 | 203 | SAI1A:
|
207 | 204 | MCK: [
|
208 | 205 | NoMck,
|
209 |
| - PE2<Alternate<AF6>> |
| 206 | + gpio::PE2<AF6> |
210 | 207 | ]
|
211 | 208 | FS: [
|
212 |
| - PE4<Alternate<AF6>> |
| 209 | + gpio::PE4<AF6> |
213 | 210 | ]
|
214 | 211 | SCK: [
|
215 |
| - PE5<Alternate<AF6>> |
| 212 | + gpio::PE5<AF6> |
216 | 213 | ]
|
217 | 214 | SD: [
|
218 |
| - PD6<Alternate<AF6>>, |
219 |
| - PE6<Alternate<AF6>> |
| 215 | + gpio::PD6<AF6>, |
| 216 | + gpio::PE6<AF6> |
220 | 217 | ]
|
221 | 218 | SAI1B:
|
222 | 219 | MCK: [
|
223 | 220 | NoMck,
|
224 |
| - PF7<Alternate<AF6>> |
| 221 | + gpio::PF7<AF6> |
225 | 222 | ]
|
226 | 223 | FS: [
|
227 |
| - PF9<Alternate<AF6>> |
| 224 | + gpio::PF9<AF6> |
228 | 225 | ]
|
229 | 226 | SCK: [
|
230 |
| - PF8<Alternate<AF6>> |
| 227 | + gpio::PF8<AF6> |
231 | 228 | ]
|
232 | 229 | SD: [
|
233 |
| - PE3<Alternate<AF6>>, |
234 |
| - PF6<Alternate<AF6>> |
| 230 | + gpio::PE3<AF6>, |
| 231 | + gpio::PF6<AF6> |
235 | 232 | ]
|
236 | 233 | }
|
237 | 234 |
|
@@ -336,15 +333,15 @@ impl Deref for SAIA<SAI> {
|
336 | 333 | type Target = sai::CH;
|
337 | 334 |
|
338 | 335 | fn deref(&self) -> &Self::Target {
|
339 |
| - unsafe { &(*SAI::ptr()).cha } |
| 336 | + unsafe { &(*SAI::ptr()).cha() } |
340 | 337 | }
|
341 | 338 | }
|
342 | 339 |
|
343 | 340 | impl Deref for SAIB<SAI> {
|
344 | 341 | type Target = sai::CH;
|
345 | 342 |
|
346 | 343 | fn deref(&self) -> &Self::Target {
|
347 |
| - unsafe { &(*SAI::ptr()).chb } |
| 344 | + unsafe { &(*SAI::ptr()).chb() } |
348 | 345 | }
|
349 | 346 | }
|
350 | 347 |
|
@@ -400,17 +397,17 @@ where
|
400 | 397 | }
|
401 | 398 |
|
402 | 399 | fn set_clock_gen(&self, sample_freq: Hertz, clocks: Clocks) {
|
403 |
| - let mclk = sample_freq.0 * 256; |
| 400 | + let mclk = sample_freq.raw() * 256; |
404 | 401 | // TODO: Use saib_clock for SAIB.
|
405 |
| - let sai_clock = clocks.saia_clk().expect("no SAI clock available").0; |
| 402 | + let sai_clock = clocks.saia_clk().expect("no SAI clock available").raw(); |
406 | 403 | if (sai_clock + (mclk >> 1)) / mclk == 1 {
|
407 | 404 | // TODO: Typo in stm32f4
|
408 |
| - self.cr1.modify(|_, w| unsafe { w.mcjdiv().bits(0) }); |
| 405 | + self.cr1.modify(|_, w| unsafe { w.mckdiv().bits(0) }); |
409 | 406 | } else {
|
410 | 407 | let best_divider = (sai_clock + mclk) / (mclk << 1);
|
411 | 408 | assert!(best_divider < 16);
|
412 | 409 | self.cr1
|
413 |
| - .modify(|_, w| unsafe { w.mcjdiv().bits(best_divider as u8) }); |
| 410 | + .modify(|_, w| unsafe { w.mckdiv().bits(best_divider as u8) }); |
414 | 411 | }
|
415 | 412 | }
|
416 | 413 |
|
@@ -503,7 +500,7 @@ where
|
503 | 500 | }
|
504 | 501 |
|
505 | 502 | fn start(&self) {
|
506 |
| - self.clrfr.modify(|_, w| { |
| 503 | + self.clrfr.write(|w| { |
507 | 504 | w.clfsdet().set_bit();
|
508 | 505 | w.cafsdet().set_bit();
|
509 | 506 | w.ccnrdy().set_bit();
|
|
0 commit comments