Skip to content

Commit 9337048

Browse files
committed
Update for new pac
1 parent 3b12307 commit 9337048

21 files changed

+907
-958
lines changed

examples/flash_with_rtic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mod app {
7373

7474
unsafe {
7575
let mut flash = &(*stm32g4xx_hal::stm32::FLASH::ptr());
76-
flash.acr.modify(|_, w| {
76+
flash.acr().modify(|_, w| {
7777
w.latency().bits(0b1000) // 8 wait states
7878
});
7979
}

src/adc.rs

Lines changed: 116 additions & 106 deletions
Large diffs are not rendered by default.

src/can.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ where
5555
{
5656
Self::enable(&rcc.rb);
5757

58-
if rcc.rb.ccipr.read().fdcansel().is_hse() {
58+
if rcc.rb.ccipr().read().fdcansel().is_hse() {
5959
// Select P clock as FDCAN clock source
60-
rcc.rb.ccipr.modify(|_, w| {
60+
rcc.rb.ccipr().modify(|_, w| {
6161
// This is sound, as `FdCanClockSource` only contains valid values for this field.
6262
unsafe {
6363
w.fdcansel().bits(FdCanClockSource::PCLK as u8);

src/comparator.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@ impl EnabledState for Enabled {}
5555
impl EnabledState for Locked {}
5656

5757
macro_rules! impl_comp {
58-
($($t:ident: $reg_t:ident, $reg:ident,)+) => {$(
58+
($($t:ident: $reg:ident,)+) => {$(
5959
pub struct $t {
6060
_rb: PhantomData<()>,
6161
}
6262

6363
impl $t {
64-
pub fn csr(&self) -> &$crate::stm32::comp::$reg_t {
64+
pub fn csr(&self) -> &$crate::stm32::comp::CCSR {
6565
// SAFETY: The COMP1 type is only constructed with logical ownership of
6666
// these registers.
67-
&unsafe { &*COMP::ptr() }.$reg
67+
&unsafe { &*COMP::ptr() }.$reg()
6868
}
6969
}
7070
)+};
7171
}
7272

7373
impl_comp! {
74-
COMP1: C1CSR, c1csr,
75-
COMP2: C2CSR, c2csr,
76-
COMP3: C3CSR, c3csr,
77-
COMP4: C4CSR, c4csr,
74+
COMP1: c1csr,
75+
COMP2: c2csr,
76+
COMP3: c3csr,
77+
COMP4: c4csr,
7878
}
7979
#[cfg(any(
8080
feature = "stm32g473",
@@ -83,9 +83,9 @@ impl_comp! {
8383
feature = "stm32g484"
8484
))]
8585
impl_comp! {
86-
COMP5: C5CSR, c5csr,
87-
COMP6: C6CSR, c6csr,
88-
COMP7: C7CSR, c7csr,
86+
COMP5: c5csr,
87+
COMP6: c6csr,
88+
COMP7: c7csr,
8989
}
9090

9191
// TODO: Split COMP in PAC
@@ -541,11 +541,11 @@ type Comparators = (COMP1, COMP2, COMP3, COMP4, COMP5, COMP6, COMP7);
541541
/// Enables the comparator peripheral, and splits the [`COMP`] into independent [`COMP1`] and [`COMP2`]
542542
pub fn split(_comp: COMP, rcc: &mut Rcc) -> Comparators {
543543
// Enable COMP, SYSCFG, VREFBUF clocks
544-
rcc.rb.apb2enr.modify(|_, w| w.syscfgen().set_bit());
544+
rcc.rb.apb2enr().modify(|_, w| w.syscfgen().set_bit());
545545

546546
// Reset COMP, SYSCFG, VREFBUF
547-
rcc.rb.apb2rstr.modify(|_, w| w.syscfgrst().set_bit());
548-
rcc.rb.apb2rstr.modify(|_, w| w.syscfgrst().clear_bit());
547+
rcc.rb.apb2rstr().modify(|_, w| w.syscfgrst().set_bit());
548+
rcc.rb.apb2rstr().modify(|_, w| w.syscfgrst().clear_bit());
549549

550550
(
551551
COMP1 { _rb: PhantomData },

src/dac.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ macro_rules! dac_helper {
179179
$trim:ident,
180180
$mode:ident,
181181
$dhrx:ident,
182-
$dac_dor:ident,
182+
$dor:ident,
183183
$daccxdhr:ident,
184184
$wave:ident,
185185
$mamp:ident,
@@ -193,8 +193,8 @@ macro_rules! dac_helper {
193193
pub fn enable(self) -> $CX<MODE_BITS, Enabled> {
194194
let dac = unsafe { &(*<$DAC>::ptr()) };
195195

196-
dac.dac_mcr.modify(|_, w| unsafe { w.$mode().bits(MODE_BITS) });
197-
dac.dac_cr.modify(|_, w| w.$en().set_bit());
196+
dac.mcr().modify(|_, w| unsafe { w.$mode().bits(MODE_BITS) });
197+
dac.cr().modify(|_, w| w.$en().set_bit());
198198

199199
$CX {
200200
_enabled: PhantomData,
@@ -204,8 +204,8 @@ macro_rules! dac_helper {
204204
pub fn enable_generator(self, config: GeneratorConfig) -> $CX<MODE_BITS, WaveGenerator> {
205205
let dac = unsafe { &(*<$DAC>::ptr()) };
206206

207-
dac.dac_mcr.modify(|_, w| unsafe { w.$mode().bits(MODE_BITS) });
208-
dac.dac_cr.modify(|_, w| unsafe {
207+
dac.mcr().modify(|_, w| unsafe { w.$mode().bits(MODE_BITS) });
208+
dac.cr().modify(|_, w| unsafe {
209209
w.$wave().bits(config.mode);
210210
w.$ten().set_bit();
211211
w.$mamp().bits(config.amp);
@@ -235,19 +235,19 @@ macro_rules! dac_helper {
235235
T: DelayUs<u32>,
236236
{
237237
let dac = unsafe { &(*<$DAC>::ptr()) };
238-
dac.dac_cr.modify(|_, w| w.$en().clear_bit());
239-
dac.dac_mcr.modify(|_, w| unsafe { w.$mode().bits(0) });
240-
dac.dac_cr.modify(|_, w| w.$cen().set_bit());
238+
dac.cr().modify(|_, w| w.$en().clear_bit());
239+
dac.mcr().modify(|_, w| unsafe { w.$mode().bits(0) });
240+
dac.cr().modify(|_, w| w.$cen().set_bit());
241241
let mut trim = 0;
242242
while true {
243-
dac.dac_ccr.modify(|_, w| unsafe { w.$trim().bits(trim) });
243+
dac.ccr().modify(|_, w| unsafe { w.$trim().bits(trim) });
244244
delay.delay_us(64_u32);
245-
if dac.dac_sr.read().$cal_flag().bit() {
245+
if dac.sr().read().$cal_flag().bit() {
246246
break;
247247
}
248248
trim += 1;
249249
}
250-
dac.dac_cr.modify(|_, w| w.$cen().clear_bit());
250+
dac.cr().modify(|_, w| w.$cen().clear_bit());
251251

252252
$CX {
253253
_enabled: PhantomData,
@@ -257,7 +257,7 @@ macro_rules! dac_helper {
257257
/// Disable the DAC channel
258258
pub fn disable(self) -> $CX<MODE_BITS, Disabled> {
259259
let dac = unsafe { &(*<$DAC>::ptr()) };
260-
dac.dac_cr.modify(|_, w| unsafe {
260+
dac.cr().modify(|_, w| unsafe {
261261
w.$en().clear_bit().$wave().bits(0).$ten().clear_bit()
262262
});
263263

@@ -272,20 +272,20 @@ macro_rules! dac_helper {
272272
impl<const MODE_BITS: u8, ED> DacOut<u16> for $CX<MODE_BITS, ED> {
273273
fn set_value(&mut self, val: u16) {
274274
let dac = unsafe { &(*<$DAC>::ptr()) };
275-
dac.$dhrx.write(|w| unsafe { w.bits(val as u32) });
275+
dac.$dhrx().write(|w| unsafe { w.bits(val as u32) });
276276
}
277277

278278
fn get_value(&mut self) -> u16 {
279279
let dac = unsafe { &(*<$DAC>::ptr()) };
280-
dac.$dac_dor.read().bits() as u16
280+
dac.$dor().read().bits() as u16
281281
}
282282
}
283283

284284
/// Wave generator state implementation
285285
impl<const MODE_BITS: u8> $CX<MODE_BITS, WaveGenerator> {
286286
pub fn trigger(&mut self) {
287287
let dac = unsafe { &(*<$DAC>::ptr()) };
288-
dac.dac_swtrgr.write(|w| { w.$swtrig().set_bit() });
288+
dac.swtrgr().write(|w| { w.$swtrig().set_bit() });
289289
}
290290
}
291291
)+
@@ -300,8 +300,8 @@ macro_rules! dac {
300300
cal_flag1,
301301
otrim1,
302302
mode1,
303-
dac_dhr12r1,
304-
dac_dor1,
303+
dhr12r1,
304+
dor1,
305305
dacc1dhr,
306306
wave1,
307307
mamp1,
@@ -314,8 +314,8 @@ macro_rules! dac {
314314
cal_flag2,
315315
otrim2,
316316
mode2,
317-
dac_dhr12r2,
318-
dac_dor2,
317+
dhr12r2,
318+
dor2,
319319
dacc2dhr,
320320
wave2,
321321
mamp2,

0 commit comments

Comments
 (0)