From bc4e0d101b11c24abc54d4b6beb19d94179e7e02 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Tue, 18 Dec 2018 19:45:35 -0800 Subject: [PATCH] Implement Serial for the STM32F070 --- src/serial.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/serial.rs b/src/serial.rs index 2a5b672..81599a4 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -6,7 +6,7 @@ use embedded_hal::prelude::*; use nb::block; use void::Void; -#[cfg(any(feature = "stm32f042", feature = "stm32f030"))] +#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))] use crate::stm32::{RCC, USART1, USART2}; use crate::gpio::*; @@ -38,13 +38,13 @@ pub enum Error { pub trait Pins {} -#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f070"))] impl Pins for (gpioa::PA9>, gpioa::PA10>) {} -#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f070"))] impl Pins for (gpiob::PB6>, gpiob::PB7>) {} -#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f070"))] impl Pins for (gpioa::PA9>, gpiob::PB7>) {} -#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f070"))] impl Pins for (gpiob::PB6>, gpioa::PA10>) {} #[cfg(feature = "stm32f030x6")] @@ -60,18 +60,21 @@ impl Pins for (gpioa::PA2>, gpioa::PA3>) { feature = "stm32f042", feature = "stm32f030x8", feature = "stm32f030xc", + feature = "stm32f070", ))] impl Pins for (gpioa::PA2>, gpioa::PA15>) {} #[cfg(any( feature = "stm32f042", feature = "stm32f030x8", feature = "stm32f030xc", + feature = "stm32f070", ))] impl Pins for (gpioa::PA14>, gpioa::PA15>) {} #[cfg(any( feature = "stm32f042", feature = "stm32f030x8", feature = "stm32f030xc", + feature = "stm32f070", ))] impl Pins for (gpioa::PA14>, gpioa::PA3>) {} @@ -92,7 +95,7 @@ pub struct Tx { } /// USART1 -#[cfg(any(feature = "stm32f042", feature = "stm32f030"))] +#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))] impl Serial { pub fn usart1(usart: USART1, pins: PINS, baud_rate: Bps, clocks: Clocks) -> Self where @@ -133,7 +136,7 @@ impl Serial { } } -#[cfg(any(feature = "stm32f042", feature = "stm32f030"))] +#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))] impl embedded_hal::serial::Read for Rx { type Error = Error; @@ -158,7 +161,7 @@ impl embedded_hal::serial::Read for Rx { } } -#[cfg(any(feature = "stm32f042", feature = "stm32f030"))] +#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))] impl embedded_hal::serial::Write for Tx { type Error = Void; @@ -192,7 +195,8 @@ impl embedded_hal::serial::Write for Tx { #[cfg(any( feature = "stm32f042", feature = "stm32f030x8", - feature = "stm32f030x8" + feature = "stm32f030x8", + feature = "stm32f070", ))] impl Serial { pub fn usart2(usart: USART2, pins: PINS, baud_rate: Bps, clocks: Clocks) -> Self @@ -237,7 +241,8 @@ impl Serial { #[cfg(any( feature = "stm32f042", feature = "stm32f030x8", - feature = "stm32f030x8" + feature = "stm32f030x8", + feature = "stm32f070", ))] impl embedded_hal::serial::Read for Rx { type Error = Error; @@ -266,7 +271,8 @@ impl embedded_hal::serial::Read for Rx { #[cfg(any( feature = "stm32f042", feature = "stm32f030x8", - feature = "stm32f030x8" + feature = "stm32f030x8", + feature = "stm32f070", ))] impl embedded_hal::serial::Write for Tx { type Error = Void;