-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add embedded-hal 1.0 trait support #129
Changes from 9 commits
2d179f4
429903e
f6e8af4
66ce515
50d3cf7
54c68a5
7676cfc
3c6d61e
4915e78
ef9618e
0d85f3b
9ae512e
6212c61
9462f4c
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 |
---|---|---|
|
@@ -2,14 +2,17 @@ | |
#![no_main] | ||
|
||
mod utils; | ||
use utils::logger::info; | ||
|
||
use crate::hal::{ | ||
adc::{ | ||
config, | ||
config::{Continuous, Dma as AdcDma, SampleTime, Sequence}, | ||
AdcClaim, ClockSource, Temperature, Vref, | ||
}, | ||
delay::SYSTDelayExt, | ||
time::ExtU32, | ||
timer::Timer, | ||
delay::DelayFromCountDownTimer, | ||
dma::{config::DmaConfig, stream::DMAExt, TransferExt}, | ||
gpio::GpioExt, | ||
pwr::PwrExt, | ||
|
@@ -20,7 +23,6 @@ use crate::hal::{ | |
use stm32g4xx_hal as hal; | ||
|
||
use cortex_m_rt::entry; | ||
use utils::logger::info; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
|
@@ -29,7 +31,7 @@ fn main() -> ! { | |
info!("start"); | ||
|
||
let dp = Peripherals::take().unwrap(); | ||
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals"); | ||
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals"); | ||
|
||
info!("rcc"); | ||
let rcc = dp.RCC.constrain(); | ||
|
@@ -47,7 +49,10 @@ fn main() -> ! { | |
let pa0 = gpioa.pa0.into_analog(); | ||
|
||
info!("Setup Adc1"); | ||
let mut delay = cp.SYST.delay(&rcc.clocks); | ||
// let mut delay = cp.SYST.delay(&rcc.clocks); | ||
let mut delay = DelayFromCountDownTimer::new( | ||
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()), | ||
); | ||
Comment on lines
-50
to
+55
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. Why is this needed? :) 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 switched out the SYST delay provider because cortex-m doesn't implement the new delay trait yet, it's probably not necessary though 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. Is there any way to avoid this since I would imagine this would break a lot of users code? 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. Using the old e-hal 0.2 trait should still work, but the function names are in conflict with the new ones which are exported in the prelude 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. Might be a good idea to see how/if this is solved in for example stm32-rs/stm32f4xx-hal 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. DelayNs has been implemented in rust-embedded/cortex-m@ec6b3ba but it hasn't been included in a release yet |
||
let mut adc = dp | ||
.ADC1 | ||
.claim(ClockSource::SystemClock, &rcc, &mut delay, true); | ||
|
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.
Is there any reason we are not using the regular 0.5.0 from crates.io?
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 was using my fork to test the i2c implementation for e-hal 1.
I also thought I hadn't included this example in the new set of changes but I must've re-added it by mistake at some point.