Skip to content

Commit 75bee83

Browse files
committed
Some fixes after rebasing
1 parent 83742a1 commit 75bee83

File tree

7 files changed

+13
-24
lines changed

7 files changed

+13
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- Added DMA support for ADC1.
1213
- Added type aliases `Tx1` for `Tx<USART1>`, `RxDma1` for `RxDma<USART1, dma1::C5>`, etc.
1314
- Add ADC1 reading functions for channels 16 (temperature) and 17 (internal reference voltage)
1415
- Update existing ADC example according to ADC API changes

examples/adc-dma-circ.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ fn main() -> ! {
2727
// clock is configurable. So its frequency may be tweaked to meet certain
2828
// practical needs. User specified value is be approximated using supported
2929
// prescaler values 2/4/6/8.
30-
let _clocks = rcc.cfgr.adcclk(2.mhz()).freeze(&mut flash.acr);
30+
let clocks = rcc.cfgr.adcclk(2.mhz()).freeze(&mut flash.acr);
3131

3232
let dma_ch1 = p.DMA1.split(&mut rcc.ahb).1;
3333

3434
// Setup ADC
35-
let adc1 = adc::Adc::adc1(p.ADC1, &mut rcc.apb2);
35+
let adc1 = adc::Adc::adc1(p.ADC1, &mut rcc.apb2, clocks.adcclk());
3636

3737
// Setup GPIOA
3838
let mut gpioa = p.GPIOA.split(&mut rcc.apb2);

examples/adc-dma-rx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ fn main() -> ! {
2626
// clock is configurable. So its frequency may be tweaked to meet certain
2727
// practical needs. User specified value is be approximated using supported
2828
// prescaler values 2/4/6/8.
29-
let _clocks = rcc.cfgr.adcclk(2.mhz()).freeze(&mut flash.acr);
29+
let clocks = rcc.cfgr.adcclk(2.mhz()).freeze(&mut flash.acr);
3030

3131
let dma_ch1 = p.DMA1.split(&mut rcc.ahb).1;
3232

3333
// Setup ADC
34-
let adc1 = adc::Adc::adc1(p.ADC1, &mut rcc.apb2);
34+
let adc1 = adc::Adc::adc1(p.ADC1, &mut rcc.apb2, clocks.adcclk());
3535

3636
// Setup GPIOA
3737
let mut gpioa = p.GPIOA.split(&mut rcc.apb2);

src/adc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ impl<PIN> AdcDma<PIN> where PIN: Channel<ADC1> {
551551
}
552552
}
553553

554-
impl<B, PIN> crate::dma::CircReadDma<B, u16> for AdcDma<PIN>
555-
where
554+
impl<B, PIN> crate::dma::CircReadDma<B, u16> for AdcDma<PIN>
555+
where
556556
B: AsMut<[u16]>,
557557
PIN: Channel<ADC1>,
558558
{
@@ -582,7 +582,7 @@ where
582582
}
583583

584584
impl<B, PIN> crate::dma::ReadDma<B, u16> for AdcDma<PIN>
585-
where
585+
where
586586
B: AsMut<[u16]>,
587587
PIN: Channel<ADC1>,
588588
{

src/dma.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,9 @@ macro_rules! dma {
286286
})
287287
}
288288

289-
/// Pauses the transfer
290-
pub fn pause(&mut self) {
291-
self.payload.stop();
292-
}
293-
294-
/// Resumes the transfer
295-
pub fn resume(&mut self) {
296-
self.payload.start();
297-
}
298-
299289
/// Stops the transfer and returns the underlying buffer and RxDma
300290
pub fn stop(mut self) -> (&'static mut [B; 2], RxDma<PAYLOAD, $CX>) {
301291
self.payload.stop();
302-
self.payload.channel.ifcr().write(|w| w.$ctcifX().set_bit());
303-
self.payload.channel.ifcr().write(|w| w.$chtifX().set_bit());
304292

305293
(self.buffer, self.payload)
306294
}
@@ -332,7 +320,7 @@ macro_rules! dma {
332320
}
333321
}
334322

335-
impl<BUFFER, PAYLOAD, MODE> Transfer<MODE, BUFFER, TxDma<PAYLOAD, $CX>>
323+
impl<BUFFER, PAYLOAD, MODE> Transfer<MODE, BUFFER, TxDma<PAYLOAD, $CX>>
336324
where
337325
TxDma<PAYLOAD, $CX>: TransferPayload,
338326
{
@@ -358,7 +346,7 @@ macro_rules! dma {
358346
}
359347
}
360348

361-
impl<BUFFER, PAYLOAD> Transfer<W, &'static mut BUFFER, RxDma<PAYLOAD, $CX>>
349+
impl<BUFFER, PAYLOAD> Transfer<W, &'static mut BUFFER, RxDma<PAYLOAD, $CX>>
362350
where
363351
RxDma<PAYLOAD, $CX>: TransferPayload,
364352
{
@@ -518,4 +506,4 @@ where
518506
Self: core::marker::Sized,
519507
{
520508
fn write(self, buffer: B) -> Transfer<R, B, Self>;
521-
}
509+
}

src/rcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl CFGR {
258258

259259
// the USB clock is only valid if an external crystal is used, the PLL is enabled, and the
260260
// PLL output frequency is a supported one.
261-
// usbpre == true: divide clock by 1.5, otherwise no division
261+
// usbpre == false: divide clock by 1.5, otherwise no division
262262
let (usbpre, usbclk_valid) = match (self.hse, pllmul_bits, sysclk) {
263263
(Some(_), Some(_), 72_000_000) => (false, true),
264264
(Some(_), Some(_), 48_000_000) => (true, true),

src/serial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,4 +655,4 @@ serialdma! {
655655
dma1::C3,
656656
dma1::C2,
657657
),
658-
}
658+
}

0 commit comments

Comments
 (0)