diff --git a/examples/blinky-blocking.rs b/examples/blinky-blocking.rs index f6a59868c458104ac324913c6e37c63cffa1710a..048caa409ae720e7198ff50fe713aa5edebbb110 100644 --- a/examples/blinky-blocking.rs +++ b/examples/blinky-blocking.rs @@ -20,7 +20,7 @@ extern crate cortex_m_rtfm as rtfm; #[macro_use] extern crate nb; -use blue_pill::led::{Green, self}; +use blue_pill::led::{self, Green}; use blue_pill::time::Hertz; use blue_pill::{Timer, stm32f103xx}; use hal::prelude::*; diff --git a/examples/concurrent-await.rs b/examples/concurrent-await.rs index 4e67a9fe598bc36b05ac7300a146b52ffc0f0f9b..991c76c1ea4973db434c5b367e87e6ed461d8ea7 100644 --- a/examples/concurrent-await.rs +++ b/examples/concurrent-await.rs @@ -100,12 +100,10 @@ fn idle(ref prio: P0, ref thr: T0) -> ! { } })(); - let mut loopback = (|| { - loop { - let byte = await!(serial.read()).unwrap(); - await!(serial.write()).unwrap(); - } - })(); + let mut loopback = (|| loop { + let byte = await!(serial.read()).unwrap(); + await!(serial.write()).unwrap(); + })(); // Resume the timer count timer.resume(); diff --git a/examples/gpio.rs b/examples/gpio.rs index 4d2335f2463074696967b35e098daaf4d89eb70f..7afa9d1cd553a964575c05fddbca5306480f1be2 100644 --- a/examples/gpio.rs +++ b/examples/gpio.rs @@ -13,7 +13,7 @@ extern crate cortex_m_rt; #[macro_use] extern crate cortex_m_rtfm as rtfm; -use blue_pill::gpio::{PB12, self}; +use blue_pill::gpio::{self, PB12}; use blue_pill::stm32f103xx; use rtfm::{P0, T0, TMax}; diff --git a/examples/led.rs b/examples/led.rs index a974521dc51be7c02475c0c2507c92a0ba189bef..62a10e87a68092a3e4da9276b73237e4c1da3d62 100644 --- a/examples/led.rs +++ b/examples/led.rs @@ -13,7 +13,7 @@ extern crate cortex_m_rt; #[macro_use] extern crate cortex_m_rtfm as rtfm; -use blue_pill::led::{Green, self}; +use blue_pill::led::{self, Green}; use blue_pill::stm32f103xx; use rtfm::{P0, T0, TMax}; diff --git a/examples/usart1-rx-dma.rs b/examples/usart1-rx-dma.rs index 989e429da880e0c38f5e0a90183ea508bc67874a..d83318cd66a503e5901a8462c2ce7eafa0bf7b66 100644 --- a/examples/usart1-rx-dma.rs +++ b/examples/usart1-rx-dma.rs @@ -1,6 +1,4 @@ -//! Test the USART1 instance -//! -//! Connect the TX and RX pins to run this test +//! Test receiving serial data using the DMA #![feature(const_fn)] #![feature(used)] @@ -87,7 +85,7 @@ fn done(_task: DMA1_CHANNEL5, ref prio: P1, ref thr: T1) { let buffer = BUFFER.access(prio, thr); let dma1 = &DMA1.access(prio, thr); - buffer.free(dma1).unwrap(); + buffer.release(dma1).unwrap(); rtfm::bkpt(); } diff --git a/examples/usart1-tx-dma.rs b/examples/usart1-tx-dma.rs index 58122059bbcfe77e845eeb203953be86b6c1a3fd..42696a465dc712a1cb509f589f1fa12be416edc4 100644 --- a/examples/usart1-tx-dma.rs +++ b/examples/usart1-tx-dma.rs @@ -1,6 +1,4 @@ -//! Test the USART1 instance -//! -//! Connect the TX and RX pins to run this test +//! Test sending serial data using the DMA #![feature(const_fn)] #![feature(used)] @@ -88,7 +86,7 @@ fn done(_task: DMA1_CHANNEL4, ref prio: P1, ref thr: T1) { let buffer = BUFFER.access(prio, thr); let dma1 = &DMA1.access(prio, thr); - buffer.free(dma1).unwrap(); + buffer.release(dma1).unwrap(); rtfm::bkpt(); } diff --git a/src/dma.rs b/src/dma.rs index 2e89db529d5ac6eb375273b956eae33c145d67ef..2df6712bc3b51bfafe412a9129b9f4346b64fb25 100644 --- a/src/dma.rs +++ b/src/dma.rs @@ -178,10 +178,10 @@ impl<T, CHANNEL> Buffer<T, CHANNEL> { } } -// FIXME these `free` methods probably want some of sort of barrier +// FIXME these `release` methods probably want some of sort of barrier impl<T> Buffer<T, Dma1Channel4> { - /// Waits until this buffer is freed by the DMA - pub fn free(&self, dma1: &DMA1) -> nb::Result<(), Error> { + /// Waits until the DMA releases this buffer + pub fn release(&self, dma1: &DMA1) -> nb::Result<(), Error> { let status = self.status.get(); if status == Status::Unlocked { @@ -202,8 +202,8 @@ impl<T> Buffer<T, Dma1Channel4> { } impl<T> Buffer<T, Dma1Channel5> { - /// Waits until this buffer is freed by the DMA - pub fn free(&self, dma1: &DMA1) -> nb::Result<(), Error> { + /// Waits until the DMA releases this buffer + pub fn release(&self, dma1: &DMA1) -> nb::Result<(), Error> { let status = self.status.get(); if status == Status::Unlocked { diff --git a/src/serial.rs b/src/serial.rs index c46badd378b8bff582f418c8744488999f022322..6b7d7c7b7ce6674be1c1626d2ac21f38d4dc6b29 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -383,6 +383,9 @@ where impl<'a> Serial<'a, USART1> { /// Starts a DMA transfer to receive serial data into a `buffer` + /// + /// This will mutably lock the `buffer` preventing borrowing its contents + /// The `buffer` can be `release`d after the DMA transfer finishes // TODO support circular mode + half transfer interrupt as a double // buffering mode pub fn read_exact<B>( @@ -416,6 +419,9 @@ impl<'a> Serial<'a, USART1> { } /// Starts a DMA transfer to send `buffer` through this serial port + /// + /// This will immutably lock the `buffer` preventing mutably borrowing its + /// contents. The `buffer` can be `release`d after the DMA transfer finishes pub fn write_all<B>( &self, dma1: &DMA1,