hal: upgrade to 0.7.1

This commit is contained in:
occheung 2020-09-07 14:05:13 +08:00
parent c740386d6b
commit 60c8215059
5 changed files with 45 additions and 45 deletions

View File

@ -11,12 +11,13 @@ panic-halt = "0.2.0"
cortex-m = "0.6.2"
cortex-m-rt = "0.6.12"
embedded-hal = "0.2.4"
stm32h7xx-hal = {version = "0.6.0", features = [ "stm32h743v", "rt", "unproven" ] }
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-raw" ] }
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" ] }
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 }
libm = "0.2.0"

View File

@ -21,8 +21,9 @@ use cortex_m_semihosting::hprintln;
extern crate smoltcp;
// Ethernet crate for STM32H7 has been merged into HAL in the latest commit
extern crate stm32h7_ethernet as ethernet;
// extern crate stm32h7_ethernet as ethernet;
use stm32h7xx_hal::ethernet;
use stm32h7xx_hal::gpio::Speed;
use stm32h7xx_hal::hal::digital::v2::{
OutputPin,
@ -34,16 +35,6 @@ use Speed::*;
use libm::round;
/*
#[cfg(feature = "itm")]
use cortex_m_log::log::{trick_init, Logger};
#[cfg(feature = "itm")]
use cortex_m_log::{
destination::Itm, printer::itm::InterruptSync as InterruptSyncItm,
};
*/
use core::{
str,
fmt::Write
@ -76,7 +67,15 @@ use firmware::{
cpld::{
CPLD,
},
scpi::{ HelloWorldCommand, Channel1SwitchCommand},
scpi::{
HelloWorldCommand,
Channel0SwitchCommand,
Channel1SwitchCommand,
Channel2SwitchCommand,
Channel3SwitchCommand,
ClockSourceCommand,
ClockDivisionCommand,
},
Urukul,
scpi_root, recursive_scpi_tree
};
@ -246,7 +245,7 @@ fn main() -> ! {
let mac_addr = smoltcp::wire::EthernetAddress::from_bytes(&MAC_ADDRESS);
let (_eth_dma, mut eth_mac) = unsafe {
ethernet::ethernet_init(
ethernet::new_unchecked(
dp.ETHERNET_MAC,
dp.ETHERNET_MTL,
dp.ETHERNET_DMA,
@ -296,8 +295,27 @@ fn main() -> ! {
// SCPI configs
let tree = scpi_root!(
["EXAMple"] => {"HELLO" => {"WORLD" => HelloWorldCommand}};
"CHANNEL1" => {"SWitch" => Channel1SwitchCommand}
["EXAMple"] => {
"HELLO" => {
"WORLD" => HelloWorldCommand
}
},
"CHANNEL0" => {
"SWitch" => Channel0SwitchCommand
},
"CHANNEL1" => {
"SWitch" => Channel1SwitchCommand
},
"CHANNEL2" => {
"SWitch" => Channel2SwitchCommand
},
"CHANNEL3" => {
"SWitch" => Channel3SwitchCommand
},
"CLOCK" => {
"SOURCE" => ClockSourceCommand,
"DIVision" => ClockDivisionCommand
}
);
// Device was declared in prior
@ -351,23 +369,6 @@ fn main() -> ! {
},
};
// Float rounding test socket (:6969)
{
let mut socket = sockets.get::<TcpSocket>(tcp1_handle);
if !socket.is_open() {
socket.listen(6969).unwrap();
socket.set_timeout(Some(Duration::from_millis(5000)));
}
if socket.can_recv() {
let data = socket.recv(|buffer| {
(buffer.len(), buffer)
}).unwrap();
hprintln!("{:?}", data).unwrap();
let result = lexical_core::parse_partial::<f64>(data).unwrap();
writeln!(socket, "{}", round(result.0 * 2.0));
}
}
// SCPI interaction socket (:7000)
{
let mut socket = sockets.get::<TcpSocket>(silent_handle);

View File

@ -2,7 +2,7 @@
#![no_main]
use smoltcp as net;
use stm32h7_ethernet as ethernet;
use stm32h7xx_hal::ethernet;
use stm32h7xx_hal::{gpio::Speed, prelude::*, spi, pac};
use embedded_hal::{blocking::spi::Transfer};
@ -103,7 +103,7 @@ fn main() -> ! {
// Configure ethernet
let mac_addr = net::wire::EthernetAddress([0xAC, 0x6F, 0x7A, 0xDE, 0xD6, 0xC8]);
let (eth_dma, _eth_mac) = unsafe {
ethernet::ethernet_init(
ethernet::new_unchecked(
dp.ETHERNET_MAC,
dp.ETHERNET_MTL,
dp.ETHERNET_DMA,

View File

@ -16,9 +16,7 @@ use cortex_m_semihosting::hprintln;
extern crate smoltcp;
// Ethernet crate for STM32H7 has been merged into HAL in the latest commit
extern crate stm32h7_ethernet as ethernet;
use stm32h7xx_hal::ethernet;
use stm32h7xx_hal::gpio::Speed;
use stm32h7xx_hal::hal::digital::v2::{
OutputPin,
@ -207,7 +205,7 @@ fn main() -> ! {
let mac_addr = smoltcp::wire::EthernetAddress::from_bytes(&MAC_ADDRESS);
let (_eth_dma, mut eth_mac) = unsafe {
ethernet::ethernet_init(
ethernet::new_unchecked(
dp.ETHERNET_MAC,
dp.ETHERNET_MTL,
dp.ETHERNET_DMA,
@ -321,13 +319,13 @@ fn main() -> ! {
{
let mut socket = socket_set.get::<TcpSocket>(client_handle);
if !socket.is_open() || !socket.can_send() {
if !socket.is_open() {
socket.abort();
socket.close();
// hprintln!("reset state: {}", socket.state()).unwrap();
hprintln!("reset state: {}", socket.state()).unwrap();
socket.connect((IpAddress::v4(192, 168, 1, 200), 1883),
(IpAddress::Unspecified, 45000)).unwrap();
// hprintln!("post connect state: {}", socket.state()).unwrap();
hprintln!("post connect state: {}", socket.state()).unwrap();
}
// hprintln!("client state: {}", socket.state()).unwrap();

View File

@ -3,7 +3,7 @@ use nb;
use heapless::{consts, Vec};
use stm32h7_ethernet as ethernet;
use stm32h7xx_hal::ethernet;
use smoltcp as net;
use cortex_m_semihosting::hprintln;