Skip to content
Snippets Groups Projects
Commit c089e7e5 authored by Jorge Aparicio's avatar Jorge Aparicio
Browse files

rename Buffer.free to Buffer.release

parent 8e0b5333
Branches
No related tags found
No related merge requests found
......@@ -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::*;
......
......@@ -100,11 +100,9 @@ fn idle(ref prio: P0, ref thr: T0) -> ! {
}
})();
let mut loopback = (|| {
loop {
let mut loopback = (|| loop {
let byte = await!(serial.read()).unwrap();
await!(serial.write()).unwrap();
}
})();
// Resume the timer count
......
......@@ -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};
......
......@@ -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};
......
//! 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();
}
//! 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();
}
......@@ -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 {
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment