Skip to content
Snippets Groups Projects
Commit 14a64be0 authored by Per's avatar Per
Browse files

now using println, deny warnings

parent 7ea82ddd
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,7 @@ ...@@ -25,11 +25,7 @@
"command": "xargo build --example gpio", "command": "xargo build --example gpio",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
], ]
"group": {
"kind": "build",
"isDefault": true
}
}, },
{ {
"taskName": "xargo build --example usart1", "taskName": "xargo build --example usart1",
...@@ -37,7 +33,11 @@ ...@@ -37,7 +33,11 @@
"command": "xargo build --example usart1", "command": "xargo build --example usart1",
"problemMatcher": [ "problemMatcher": [
"$rustc" "$rustc"
] ],
"group": {
"kind": "build",
"isDefault": true
}
}, },
{ {
"type": "shell", "type": "shell",
......
...@@ -5,13 +5,10 @@ ...@@ -5,13 +5,10 @@
#![no_std] #![no_std]
extern crate cortex_m_rtfm as rtfm; extern crate cortex_m_rtfm as rtfm;
extern crate cortex_m_semihosting as semihosting; #[macro_use]
extern crate nucleo_64; extern crate nucleo_64;
use core::fmt::Write;
use rtfm::app; use rtfm::app;
use semihosting::hio;
app! { app! {
device: nucleo_64::stm32f40x, device: nucleo_64::stm32f40x,
...@@ -20,8 +17,9 @@ app! { ...@@ -20,8 +17,9 @@ app! {
fn init(_p: init::Peripherals) {} fn init(_p: init::Peripherals) {}
fn idle() -> ! { fn idle() -> ! {
writeln!(hio::hstdout().unwrap(), "Hello, Sworld!").unwrap(); println!("Hello, world!");
rtfm::bkpt();
loop { loop {
rtfm::wfi(); rtfm::wfi();
} }
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
//! //!
//! PA2 (TX), PA3(RX) on the MCU is connected to the pin header CN3 //! PA2 (TX), PA3(RX) on the MCU is connected to the pin header CN3
//#![deny(unsafe_code)] //#![deny(unsafe_code)]
//#![deny(warnings)] #![deny(warnings)]
#![allow(warnings)] //#![allow(warnings)]
#![feature(proc_macro)] #![feature(proc_macro)]
#![no_std] #![no_std]
...@@ -13,16 +13,13 @@ extern crate cortex_m_rtfm as rtfm; ...@@ -13,16 +13,13 @@ extern crate cortex_m_rtfm as rtfm;
extern crate cortex_m_semihosting as semihosting; extern crate cortex_m_semihosting as semihosting;
#[macro_use] #[macro_use]
extern crate nb; extern crate nb;
#[macro_use]
extern crate nucleo_64; extern crate nucleo_64;
extern crate stm32f40x; extern crate stm32f40x;
//use nucleo_64::Serial;
use nucleo_64::prelude::*;
use nucleo_64::time::Hertz; use nucleo_64::time::Hertz;
use semihosting::hio;
use core::fmt::Write;
use rtfm::app; use rtfm::app;
use core::ops::Deref;
use core::ptr; use core::ptr;
use nucleo_64::apb1; use nucleo_64::apb1;
...@@ -32,12 +29,12 @@ app! { ...@@ -32,12 +29,12 @@ app! {
device: nucleo_64::stm32f40x, device: nucleo_64::stm32f40x,
} }
use stm32f40x::{gpioa, DMA1, USART1, USART2, USART3, usart6, GPIOA, GPIOB, RCC}; use stm32f40x::USART2;
#[inline(never)] #[inline(never)]
fn init(p: init::Peripherals) { fn init(p: init::Peripherals) {
writeln!(hio::hstdout().unwrap(), "Init!").unwrap(); println!("Init!");
// RM0368 6.3.9 // RM0368 6.3.9
// enable clock to GPIOA, USART2 // enable clock to GPIOA, USART2
p.RCC.ahb1enr.modify(|_, w| w.gpioaen().enable()); p.RCC.ahb1enr.modify(|_, w| w.gpioaen().enable());
...@@ -59,7 +56,6 @@ fn init(p: init::Peripherals) { ...@@ -59,7 +56,6 @@ fn init(p: init::Peripherals) {
.variant(stm32f40x::gpioa::moder::MODER15W::ALTERNATEMODE) .variant(stm32f40x::gpioa::moder::MODER15W::ALTERNATEMODE)
}); });
// we don't care about the speed register atm // we don't care about the speed register atm
// DM00102166 // DM00102166
// AF7, Table 9 // AF7, Table 9
...@@ -106,34 +102,10 @@ fn init(p: init::Peripherals) { ...@@ -106,34 +102,10 @@ fn init(p: init::Peripherals) {
.clear_bit() .clear_bit()
}); });
// let serial = Serial(p.USART1);
// serial.init(BAUD_RATE.invert(), p.AFIO, None, p.GPIOA, p.RCC);
// echo incoming
loop { loop {
let b = block!(read(p.USART2)).unwrap(); let b = block!(read(p.USART2)).unwrap();
write(p.USART2, b).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 // Specialized `Result` type
...@@ -190,7 +162,7 @@ fn read(usart2: &USART2) -> Result<u8> { ...@@ -190,7 +162,7 @@ fn read(usart2: &USART2) -> Result<u8> {
} }
fn idle() -> ! { fn idle() -> ! {
// OK // Will never be hit, as
rtfm::bkpt(); rtfm::bkpt();
// Sleep // Sleep
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
//! //!
//! - PA0 - PA15 //! - PA0 - PA15
use stm32f40x::{GPIOA, RCC}; use stm32f40x::GPIOA;
use stm32f40x; use stm32f40x;
macro_rules! pin { macro_rules! pin {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
//! [i]: https://docs.rs/cortex-m-quickstart/0.1.8/cortex_m_quickstart/ //! [i]: https://docs.rs/cortex-m-quickstart/0.1.8/cortex_m_quickstart/
#![deny(missing_docs)] #![deny(missing_docs)]
//#![deny(warnings)] #![deny(warnings)]
#![allow(warnings)] #![allow(warnings)]
#![feature(const_cell_new)] #![feature(const_cell_new)]
#![feature(const_fn)] #![feature(const_fn)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment