-
Notifications
You must be signed in to change notification settings - Fork 51
Fix SysCfg hardfault, Add I2C Fast Mode Plus enable method #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
ced789f
557637a
033b58a
6abbaef
bac7b62
6c8253a
b9220ed
15f7fab
a6369ca
eb3aef7
18754c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[default.rtt] | ||
enabled = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
use crate::bb; | ||
use crate::stm32::{RCC, SYSCFG}; | ||
use crate::rcc::Rcc; | ||
use crate::stm32::SYSCFG; | ||
use core::ops::Deref; | ||
|
||
/// Extension trait that constrains the `SYSCFG` peripheral | ||
pub trait SysCfgExt { | ||
/// Constrains the `SYSCFG` peripheral so it plays nicely with the other abstractions | ||
fn constrain(self) -> SysCfg; | ||
fn constrain(self, rcc: &mut Rcc) -> SysCfg; | ||
} | ||
|
||
impl SysCfgExt for SYSCFG { | ||
fn constrain(self) -> SysCfg { | ||
unsafe { | ||
// NOTE(unsafe) this reference will only be used for atomic writes with no side effects. | ||
let rcc = &(*RCC::ptr()); | ||
|
||
// Enable clock. | ||
bb::set(&rcc.apb2enr(), 0); | ||
|
||
// Stall the pipeline to work around erratum 2.1.13 (DM00037591) | ||
cortex_m::asm::dsb(); | ||
} | ||
fn constrain(self, rcc: &mut Rcc) -> SysCfg { | ||
// Enable SYSCFG peripheral clock in APB2ENR register | ||
rcc.apb2enr().modify(|_, w| w.syscfgen().set_bit()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not tinkered with the SysCfg, but is there any reason to handle this different from for example how the usarts are enabled. So something like this? SYSCFG::enable(rcc);
SYSCFG::reset(rcc); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a look! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pushed a change to use Enable and Reset traits rather than direct register access |
||
SysCfg(self) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probe-rs
should do it automatically on connect.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@boondocklabs , if the DMA enable thing is enough, then how about we do only that? (Same for #214 i presume)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the DBGMCU modification, and left the DMA enable in the button example. Tested on a G431KB without explicit DGBMCU modification and it does not hardfault as long as the DMA enable workaround is there.