forked from M-Labs/kirdy
squash all warnings, add RTT support
This commit is contained in:
parent
6867a293e5
commit
6a76536248
|
@ -264,6 +264,7 @@ dependencies = [
|
||||||
"nb 1.0.0",
|
"nb 1.0.0",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"panic-halt",
|
"panic-halt",
|
||||||
|
"rtt-target",
|
||||||
"smoltcp",
|
"smoltcp",
|
||||||
"stm32-eth",
|
"stm32-eth",
|
||||||
"stm32f4xx-hal",
|
"stm32f4xx-hal",
|
||||||
|
@ -368,6 +369,16 @@ version = "0.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rtt-target"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "065d6058bb1204f51a562a67209e1817cf714759d5cf845aa45c75fa7b0b9d9b"
|
||||||
|
dependencies = [
|
||||||
|
"cortex-m 0.7.6",
|
||||||
|
"ufmt-write",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
|
@ -496,6 +507,12 @@ version = "1.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt-write"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
|
|
@ -29,10 +29,12 @@ num-traits = { version = "0.2.15", default-features = false, features = ["libm"]
|
||||||
usb-device = "0.2.9"
|
usb-device = "0.2.9"
|
||||||
usbd-serial = "0.1.1"
|
usbd-serial = "0.1.1"
|
||||||
fugit = "0.3.6"
|
fugit = "0.3.6"
|
||||||
|
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
semihosting = ["cortex-m-log/semihosting"]
|
semihosting = ["cortex-m-log/semihosting"]
|
||||||
|
RTT = []
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub fn bootup(mut core_perif: CorePeripherals, perif: Peripherals) -> Independen
|
||||||
|
|
||||||
sys_timer::setup(core_perif.SYST, clocks);
|
sys_timer::setup(core_perif.SYST, clocks);
|
||||||
|
|
||||||
let (eth_pins, usb, current_source_phy) = gpio::setup(
|
let (_eth_pins, usb, current_source_phy) = gpio::setup(
|
||||||
clocks,
|
clocks,
|
||||||
perif.GPIOA,
|
perif.GPIOA,
|
||||||
perif.GPIOB,
|
perif.GPIOB,
|
||||||
|
@ -57,7 +57,7 @@ pub fn bootup(mut core_perif: CorePeripherals, perif: Peripherals) -> Independen
|
||||||
};
|
};
|
||||||
|
|
||||||
laser.setup();
|
laser.setup();
|
||||||
laser.set_current(0.1);
|
laser.set_current(0.1).unwrap();
|
||||||
|
|
||||||
let mut wd = IndependentWatchdog::new(perif.IWDG);
|
let mut wd = IndependentWatchdog::new(perif.IWDG);
|
||||||
wd.start(WATCHDOG_PERIOD.millis());
|
wd.start(WATCHDOG_PERIOD.millis());
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
#[cfg(not(feature = "semihosting"))]
|
#[cfg(not(any(feature = "semihosting", feature = "RTT")))]
|
||||||
use super::usb;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "semihosting"))]
|
|
||||||
pub fn init_log() {
|
pub fn init_log() {
|
||||||
|
use super::usb;
|
||||||
static USB_LOGGER: usb::Logger = usb::Logger;
|
static USB_LOGGER: usb::Logger = usb::Logger;
|
||||||
let _ = log::set_logger(&USB_LOGGER);
|
let _ = log::set_logger(&USB_LOGGER);
|
||||||
log::set_max_level(log::LevelFilter::Debug);
|
log::set_max_level(log::LevelFilter::Debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "RTT")]
|
||||||
|
pub fn init_log() {
|
||||||
|
use super::rtt_logger;
|
||||||
|
use rtt_target::rtt_init_print;
|
||||||
|
static RTT_LOGGER: rtt_logger::Logger = rtt_logger::Logger;
|
||||||
|
rtt_init_print!();
|
||||||
|
let _ = log::set_logger(&RTT_LOGGER);
|
||||||
|
log::set_max_level(log::LevelFilter::Debug);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "semihosting")]
|
#[cfg(feature = "semihosting")]
|
||||||
pub fn init_log() {
|
pub fn init_log() {
|
||||||
use cortex_m_log::log::{init, Logger};
|
use cortex_m_log::log::{init, Logger};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod boot;
|
pub mod boot;
|
||||||
pub mod gpio;
|
pub mod gpio;
|
||||||
pub mod log_setup;
|
pub mod log_setup;
|
||||||
|
pub mod rtt_logger;
|
||||||
pub mod sys_timer;
|
pub mod sys_timer;
|
||||||
pub mod usb;
|
pub mod usb;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
use log::{Log, Metadata, Record};
|
||||||
|
use rtt_target::rprintln;
|
||||||
|
|
||||||
|
pub struct Logger;
|
||||||
|
|
||||||
|
impl Log for Logger {
|
||||||
|
fn enabled(&self, _: &Metadata) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log(&self, record: &Record) {
|
||||||
|
if self.enabled(record.metadata()) {
|
||||||
|
rprintln!("{} - {}", record.level(), record.args());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flush(&self) {}
|
||||||
|
}
|
Loading…
Reference in New Issue