diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2e40660a8b30819144ad6f79069a6c04a6dd0381..a490cda5dae2e78433f2b335578169fc2e3be2a7 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,11 +25,7 @@ "command": "xargo build --example gpio", "problemMatcher": [ "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } + ] }, { "taskName": "xargo build --example usart1", @@ -37,7 +33,11 @@ "command": "xargo build --example usart1", "problemMatcher": [ "$rustc" - ] + ], + "group": { + "kind": "build", + "isDefault": true + } }, { "type": "shell", diff --git a/examples/hello.rs b/examples/hello.rs index 4bce8e270b5249492a3524c2985b6a66957440ce..9ea315ab424d54478b13bd86949df54a397a3872 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -5,13 +5,10 @@ #![no_std] extern crate cortex_m_rtfm as rtfm; -extern crate cortex_m_semihosting as semihosting; +#[macro_use] extern crate nucleo_64; -use core::fmt::Write; - use rtfm::app; -use semihosting::hio; app! { device: nucleo_64::stm32f40x, @@ -20,8 +17,9 @@ app! { fn init(_p: init::Peripherals) {} fn idle() -> ! { - writeln!(hio::hstdout().unwrap(), "Hello, Sworld!").unwrap(); + println!("Hello, world!"); + rtfm::bkpt(); loop { rtfm::wfi(); } diff --git a/examples/usart1.rs b/examples/usart1.rs index 5ba1d25a93ceb58a9e15e63ffb4544ce0d04512a..0b1b245d0ef798fee6da417c678091fb09f4dc81 100644 --- a/examples/usart1.rs +++ b/examples/usart1.rs @@ -4,8 +4,8 @@ //! //! PA2 (TX), PA3(RX) on the MCU is connected to the pin header CN3 //#![deny(unsafe_code)] -//#![deny(warnings)] -#![allow(warnings)] +#![deny(warnings)] +//#![allow(warnings)] #![feature(proc_macro)] #![no_std] @@ -13,16 +13,13 @@ extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_semihosting as semihosting; #[macro_use] extern crate nb; +#[macro_use] extern crate nucleo_64; extern crate stm32f40x; -//use nucleo_64::Serial; -use nucleo_64::prelude::*; use nucleo_64::time::Hertz; -use semihosting::hio; -use core::fmt::Write; + use rtfm::app; -use core::ops::Deref; use core::ptr; use nucleo_64::apb1; @@ -32,12 +29,12 @@ app! { device: nucleo_64::stm32f40x, } -use stm32f40x::{gpioa, DMA1, USART1, USART2, USART3, usart6, GPIOA, GPIOB, RCC}; +use stm32f40x::USART2; #[inline(never)] fn init(p: init::Peripherals) { - writeln!(hio::hstdout().unwrap(), "Init!").unwrap(); + println!("Init!"); // RM0368 6.3.9 // enable clock to GPIOA, USART2 p.RCC.ahb1enr.modify(|_, w| w.gpioaen().enable()); @@ -59,7 +56,6 @@ fn init(p: init::Peripherals) { .variant(stm32f40x::gpioa::moder::MODER15W::ALTERNATEMODE) }); - // we don't care about the speed register atm // DM00102166 // AF7, Table 9 @@ -106,34 +102,10 @@ fn init(p: init::Peripherals) { .clear_bit() }); - // let serial = Serial(p.USART1); - - // serial.init(BAUD_RATE.invert(), p.AFIO, None, p.GPIOA, p.RCC); - - // echo incoming loop { let b = block!(read(p.USART2)).unwrap(); write(p.USART2, b).unwrap(); } - - - - - const BYTE: u8 = b'A'; - - assert!(write(p.USART2, BYTE).is_ok()); - - for _ in 0..1_000 { - match read(p.USART2) { - Ok(byte) => { - assert_eq!(byte, BYTE); - return; - } - Err(nb::Error::Other(e)) => panic!("{:?}", e), - Err(nb::Error::WouldBlock) => continue, - } - } - panic!("Timeout") } // Specialized `Result` type @@ -190,7 +162,7 @@ fn read(usart2: &USART2) -> Result<u8> { } fn idle() -> ! { - // OK + // Will never be hit, as rtfm::bkpt(); // Sleep diff --git a/src/gpio.rs b/src/gpio.rs index 6ae400dd2548decec137e995f5d8e902ab767426..fe15aa5167ceec18952d5d1aa96e616f91ee0be2 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -2,7 +2,7 @@ //! //! - PA0 - PA15 -use stm32f40x::{GPIOA, RCC}; +use stm32f40x::GPIOA; use stm32f40x; macro_rules! pin { diff --git a/src/lib.rs b/src/lib.rs index 443556075f92517808ac1b381952df9b1609dca1..b8ab7b6116fd1d9087cd67c3c6ddcb949c6900e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //! [i]: https://docs.rs/cortex-m-quickstart/0.1.8/cortex_m_quickstart/ #![deny(missing_docs)] -//#![deny(warnings)] +#![deny(warnings)] #![allow(warnings)] #![feature(const_cell_new)] #![feature(const_fn)]