forked from M-Labs/humpback-dds
scpi: refine clock src cmd
This commit is contained in:
parent
7665a23896
commit
6616489a5e
10
Cargo.toml
10
Cargo.toml
|
@ -12,12 +12,8 @@ cortex-m = "0.6.2"
|
||||||
cortex-m-rt = "0.6.12"
|
cortex-m-rt = "0.6.12"
|
||||||
embedded-hal = "0.2.4"
|
embedded-hal = "0.2.4"
|
||||||
stm32h7xx-hal = {version = "0.7.1", features = [ "stm32h743v", "rt", "unproven", "ethernet", "phy_lan8742a" ] }
|
stm32h7xx-hal = {version = "0.7.1", features = [ "stm32h743v", "rt", "unproven", "ethernet", "phy_lan8742a" ] }
|
||||||
# stm32h7-ethernet = { version = "0.2.0", features = [ "phy_lan8742a", "stm32h743v" ] }
|
|
||||||
smoltcp = { version = "0.6.0", default-features = false, features = [ "ethernet", "proto-ipv4", "proto-ipv6", "socket-tcp" ] }
|
smoltcp = { version = "0.6.0", default-features = false, features = [ "ethernet", "proto-ipv4", "proto-ipv6", "socket-tcp" ] }
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
# scpi = { path = "../scpi-fork/scpi", version = "0.3.4" }
|
|
||||||
scpi = { git = "https://github.com/occheung/scpi-rs", branch = "issue-4" }
|
|
||||||
mashup = "0.1.12"
|
|
||||||
|
|
||||||
lexical-core = { version="0.7.1", features=["radix"], default-features=false }
|
lexical-core = { version="0.7.1", features=["radix"], default-features=false }
|
||||||
libm = "0.2.0"
|
libm = "0.2.0"
|
||||||
|
@ -33,6 +29,12 @@ panic-semihosting = { version = "0.5.3", features = [ "exit" ] }
|
||||||
cortex-m-rtic = "0.5.3"
|
cortex-m-rtic = "0.5.3"
|
||||||
cortex-m-log = { version = "~0.6", features = [ "itm" ] }
|
cortex-m-log = { version = "~0.6", features = [ "itm" ] }
|
||||||
|
|
||||||
|
[dependencies.scpi]
|
||||||
|
git = "https://github.com/occheung/scpi-rs"
|
||||||
|
branch = "issue-4"
|
||||||
|
default-features = false
|
||||||
|
features = [ "build-info", "unit-frequency" ]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "ethernet"
|
name = "ethernet"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
use smoltcp as net;
|
use smoltcp as net;
|
||||||
use stm32h7xx_hal::ethernet;
|
use stm32h7xx_hal::ethernet;
|
||||||
use stm32h7xx_hal::{gpio::Speed, prelude::*, spi, pac};
|
use stm32h7xx_hal::{gpio::Speed, prelude::*, spi, pac};
|
||||||
use embedded_hal::{blocking::spi::Transfer};
|
use embedded_hal::{
|
||||||
|
blocking::spi::Transfer,
|
||||||
|
digital::v2::OutputPin,
|
||||||
|
};
|
||||||
|
|
||||||
use heapless::{consts, String};
|
use heapless::{consts, String};
|
||||||
|
|
||||||
|
@ -87,6 +90,11 @@ fn main() -> ! {
|
||||||
let gpiof = dp.GPIOF.split(ccdr.peripheral.GPIOF);
|
let gpiof = dp.GPIOF.split(ccdr.peripheral.GPIOF);
|
||||||
let gpiog = dp.GPIOG.split(ccdr.peripheral.GPIOG);
|
let gpiog = dp.GPIOG.split(ccdr.peripheral.GPIOG);
|
||||||
|
|
||||||
|
let mut yellow_led = gpioe.pe1.into_push_pull_output();
|
||||||
|
yellow_led.set_low().unwrap();
|
||||||
|
let mut red_led = gpiob.pb14.into_push_pull_output();
|
||||||
|
red_led.set_high().unwrap();
|
||||||
|
|
||||||
// Configure ethernet IO
|
// Configure ethernet IO
|
||||||
{
|
{
|
||||||
let _rmii_refclk = gpioa.pa1.into_alternate_af11().set_speed(Speed::VeryHigh);
|
let _rmii_refclk = gpioa.pa1.into_alternate_af11().set_speed(Speed::VeryHigh);
|
||||||
|
@ -167,12 +175,13 @@ fn main() -> ! {
|
||||||
[25_000_000, 25_000_000, 25_000_000, 25_000_000]
|
[25_000_000, 25_000_000, 25_000_000, 25_000_000]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cp.SCB.invalidate_icache();
|
||||||
cp.SCB.enable_icache();
|
cp.SCB.enable_icache();
|
||||||
|
|
||||||
let mut time: u32 = 0;
|
let mut time: u32 = 0;
|
||||||
let mut next_ms = Instant::now();
|
let mut next_ms = Instant::now();
|
||||||
|
|
||||||
next_ms += 400_00.cycles();
|
next_ms += 400_000.cycles();
|
||||||
|
|
||||||
let mut socket_set_entries: [_; 8] = Default::default();
|
let mut socket_set_entries: [_; 8] = Default::default();
|
||||||
let mut sockets = net::socket::SocketSet::new(&mut socket_set_entries[..]);
|
let mut sockets = net::socket::SocketSet::new(&mut socket_set_entries[..]);
|
||||||
|
@ -187,6 +196,23 @@ fn main() -> ! {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
match client.is_connected() {
|
||||||
|
true => {
|
||||||
|
yellow_led.set_high().unwrap();
|
||||||
|
red_led.set_low().unwrap();
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
yellow_led.set_low().unwrap();
|
||||||
|
red_led.set_high().unwrap();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
client
|
||||||
|
.poll(|_client, topic, message, _properties| match topic {
|
||||||
|
_ => hprintln!("On '{:?}', received: {:?}", topic, message).unwrap(),
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let tick = Instant::now() > next_ms;
|
let tick = Instant::now() > next_ms;
|
||||||
|
|
||||||
if tick {
|
if tick {
|
||||||
|
@ -200,12 +226,6 @@ fn main() -> ! {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
client
|
|
||||||
.poll(|_client, topic, message, _properties| match topic {
|
|
||||||
_ => hprintln!("On '{:?}', received: {:?}", topic, message).unwrap(),
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Update the TCP stack.
|
// Update the TCP stack.
|
||||||
let sleep = client.network_stack.update(time);
|
let sleep = client.network_stack.update(time);
|
||||||
if sleep {
|
if sleep {
|
||||||
|
|
|
@ -12,9 +12,6 @@ use core::{
|
||||||
use cortex_m;
|
use cortex_m;
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate mashup;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod bitmask_macro;
|
pub mod bitmask_macro;
|
||||||
|
|
||||||
|
|
25
src/scpi.rs
25
src/scpi.rs
|
@ -28,6 +28,7 @@ use scpi::{
|
||||||
scpi_status,
|
scpi_status,
|
||||||
scpi_system,
|
scpi_system,
|
||||||
};
|
};
|
||||||
|
// use scpi::suffix::{Frequency};
|
||||||
|
|
||||||
use embedded_hal::blocking::spi::Transfer;
|
use embedded_hal::blocking::spi::Transfer;
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
|
@ -236,19 +237,29 @@ impl<T:Device + UrukulTraits> Command<T> for ClockSourceCommand {
|
||||||
Some(Token::CharacterProgramData(s)) => s,
|
Some(Token::CharacterProgramData(s)) => s,
|
||||||
_ => return Err(ErrorCode::IllegalParameterValue.into()),
|
_ => return Err(ErrorCode::IllegalParameterValue.into()),
|
||||||
};
|
};
|
||||||
let result = match str::from_utf8(data) {
|
// let max_value = f64::Frequency::new::<hertz>(1_000_000_000_000.0);
|
||||||
Ok(str_param) => match str_param {
|
// let min_value = f64::Frequency::new::<hertz>(0.0);
|
||||||
|
|
||||||
|
// let freq: f64::Frequency = args.next_data(true)?
|
||||||
|
// .map_or(Ok(f64::Frequency::new::<hertz>(0.0)),
|
||||||
|
// |t| {
|
||||||
|
// t.numeric(|s| match s {
|
||||||
|
// NumericValues::Maximum => Ok(f64::Frequency::new::<hertz>(max_value)),
|
||||||
|
// NumericValues::Minimum => Ok(f64::Frequency::new::<hertz>(min_value)),
|
||||||
|
// _ => Err(ErrorCode::IllegalParameterValue.into()),
|
||||||
|
// })
|
||||||
|
// })?;
|
||||||
|
if let Ok(str_param) = str::from_utf8(data) {
|
||||||
|
if let Ok(cmd) = match str_param {
|
||||||
"OSC" => context.device.set_clock_source(ClockSource::OSC),
|
"OSC" => context.device.set_clock_source(ClockSource::OSC),
|
||||||
"MMCX" => context.device.set_clock_source(ClockSource::MMCX),
|
"MMCX" => context.device.set_clock_source(ClockSource::MMCX),
|
||||||
"SMA" => context.device.set_clock_source(ClockSource::SMA),
|
"SMA" => context.device.set_clock_source(ClockSource::SMA),
|
||||||
_ => return Err(ErrorCode::IllegalParameterValue.into()),
|
_ => return Err(ErrorCode::IllegalParameterValue.into()),
|
||||||
|
} {
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
_ => return Err(ErrorCode::IllegalParameterValue.into()),
|
|
||||||
};
|
};
|
||||||
match result {
|
Err(ErrorCode::IllegalParameterValue.into())
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(_) => Err(Error::new(ErrorCode::HardwareError)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue