From fc28641466b4cd5f93c1cf4d9ab3ed7b5fc43067 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Tue, 25 Jan 2022 10:38:47 +0800 Subject: [PATCH 1/4] cargo/flake: update package versions --- Cargo.lock | 127 +++++++++++++++++++++++++++++++++++++++-------------- Cargo.toml | 10 ++--- flake.nix | 1 - 3 files changed, 97 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85d8279..b089ee2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,12 +68,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cast" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -dependencies = [ - "rustc_version", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cfg-if" @@ -82,14 +79,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] -name = "cortex-m" -version = "0.6.4" +name = "chrono" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cdafeafba636c00c467ded7f1587210725a1adfab0c24028a7844b87738263" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "cortex-m" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9" dependencies = [ "aligned", "bare-metal 0.2.5", "bitfield", + "cortex-m 0.7.4", + "volatile-register", +] + +[[package]] +name = "cortex-m" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ff967e867ca14eba0c34ac25cd71ea98c678e741e3915d923999bb2fe7c826" +dependencies = [ + "bare-metal 0.2.5", + "bitfield", + "embedded-hal", "volatile-register", ] @@ -99,7 +119,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d63959cb1e003dd97233fee6762351540253237eadf06fcdcb98cbfa3f9be4a" dependencies = [ - "cortex-m", + "cortex-m 0.6.7", "cortex-m-semihosting", "log", ] @@ -110,10 +130,19 @@ version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb" dependencies = [ - "cortex-m-rt-macros", + "cortex-m-rt-macros 0.1.8", "r0", ] +[[package]] +name = "cortex-m-rt" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c433da385b720d5bb9f52362fa2782420798e68d40d67bfe4b0d992aba5dfe7" +dependencies = [ + "cortex-m-rt-macros 0.7.0", +] + [[package]] name = "cortex-m-rt-macros" version = "0.1.8" @@ -125,13 +154,24 @@ dependencies = [ "syn", ] +[[package]] +name = "cortex-m-rt-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "cortex-m-semihosting" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc" dependencies = [ - "cortex-m", + "cortex-m 0.7.4", ] [[package]] @@ -154,9 +194,9 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb" +checksum = "e36cfb62ff156596c892272f3015ef952fe1525e85261fa3a7f327bd6b384ab9" dependencies = [ "nb 0.1.3", "void", @@ -264,6 +304,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.14" @@ -286,7 +336,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec" dependencies = [ - "cortex-m", + "cortex-m 0.7.4", "cortex-m-semihosting", ] @@ -333,9 +383,18 @@ checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" + +[[package]] +name = "rtcc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef35f9dcbf434a34dcc99b3ebba1c1945d49c70832958e932e83dc63a5273994" +dependencies = [ + "chrono", +] [[package]] name = "rustc_version" @@ -404,9 +463,9 @@ dependencies = [ [[package]] name = "smoltcp" -version = "0.6.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe46639fd2ec79eadf8fe719f237a7a0bd4dac5d957f1ca5bbdbc1c3c39e53a" +checksum = "3e4a069bef843d170df47e7c0a8bf8d037f217d9f5b325865acc3e466ffe40d3" dependencies = [ "bitflags", "byteorder", @@ -423,10 +482,10 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stm32-eth" version = "0.2.0" -source = "git+https://github.com/stm32-rs/stm32-eth.git#4d6b29bf1ecdd1f68e5bc304a3d4f170049896c8" +source = "git+https://github.com/stm32-rs/stm32-eth.git?rev=882553d21#882553d21de4357e610505c9dd19d2abdd32c999" dependencies = [ "aligned", - "cortex-m", + "cortex-m 0.7.4", "smoltcp", "stm32f4xx-hal", "volatile-register", @@ -434,29 +493,31 @@ dependencies = [ [[package]] name = "stm32f4" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11460b4de3a84f072e2cf6e76306c64d27f405a0e83bace0a726f555ddf4bf33" +checksum = "da3d56009c8f32e4f208dbea17df72484154d1040a8969b75d8c73eb7b18fe8f" dependencies = [ "bare-metal 0.2.5", - "cortex-m", - "cortex-m-rt", + "cortex-m 0.7.4", + "cortex-m-rt 0.6.13", "vcell", ] [[package]] name = "stm32f4xx-hal" -version = "0.8.3" -source = "git+https://github.com/astro/stm32f4xx-hal.git?branch=flash#9171ef176a90b1177f350fe2bc1eac625769a041" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a06fde2dd27c0ba934c9e69b62af66eb1c20dbb6d741b187a763912e9892d13" dependencies = [ - "bare-metal 0.2.5", + "bare-metal 1.0.0", "cast", - "cortex-m", - "cortex-m-rt", + "cortex-m 0.7.4", + "cortex-m-rt 0.7.1", "embedded-dma", "embedded-hal", - "nb 0.1.3", + "nb 1.0.0", "rand_core", + "rtcc", "stm32f4", "synopsys-usb-otg", "void", @@ -479,7 +540,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "461676dcf123675b3d3b02e2390e6a690cd186aacf2f439af7673c79e2561d53" dependencies = [ - "cortex-m", + "cortex-m 0.6.7", "usb-device", "vcell", ] @@ -491,9 +552,9 @@ dependencies = [ "bare-metal 1.0.0", "bit_field", "byteorder", - "cortex-m", + "cortex-m 0.6.7", "cortex-m-log", - "cortex-m-rt", + "cortex-m-rt 0.6.13", "eeprom24x", "heapless", "log", diff --git a/Cargo.toml b/Cargo.toml index 3c8e91e..c9a2b9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,9 @@ bare-metal = "1" cortex-m = "0.6" cortex-m-rt = { version = "0.6", features = ["device"] } cortex-m-log = { version = "0.6", features = ["log-integration"] } -stm32f4xx-hal = { version = "0.8", features = ["rt", "stm32f427", "usb_fs"] } -stm32-eth = { version = "0.2", features = ["stm32f427", "smoltcp-phy"], git = "https://github.com/stm32-rs/stm32-eth.git" } -smoltcp = { version = "0.6.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "log"] } +stm32f4xx-hal = { version = "=0.10.1", features = ["rt", "stm32f427", "usb_fs"] } +stm32-eth = { rev = "882553d21", features = ["stm32f427", "smoltcp-phy"], git = "https://github.com/stm32-rs/stm32-eth.git" } +smoltcp = { version = "0.7.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "log"] } bit_field = "0.10" byteorder = { version = "1", default-features = false } nom = { version = "5", default-features = false } @@ -38,10 +38,6 @@ heapless = "0.5" serde-json-core = "0.1" sfkv = "0.1" -[patch.crates-io] -# TODO: pending https://github.com/stm32-rs/stm32f4xx-hal/pull/239 -stm32f4xx-hal = { git = "https://github.com/astro/stm32f4xx-hal.git", branch = "flash" } - [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] diff --git a/flake.nix b/flake.nix index b332d7c..6c84438 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,6 @@ lockFile = ./Cargo.lock; outputHashes = { "stm32-eth-0.2.0" = "sha256-HXRr/NDhdIKqyjdA4D8ZmcO1dDpDawdlYPUOwcEbPQk="; - "stm32f4xx-hal-0.8.3" = "sha256-MOv7tVtVMxr3IYMaN0Q8EQWxv3rubmCxjXMXuw/ZKAw="; }; }; -- 2.44.2 From 07a9e71bec42d17b5e668ebec12daf2e40955c85 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Tue, 25 Jan 2022 12:46:29 +0800 Subject: [PATCH 2/4] cargo/nix: update rustc, stm32-eth, smoltcp --- Cargo.lock | 4 +++- Cargo.toml | 4 ++-- flake.nix | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b089ee2..b27f15f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aligned" version = "0.3.4" @@ -482,7 +484,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stm32-eth" version = "0.2.0" -source = "git+https://github.com/stm32-rs/stm32-eth.git?rev=882553d21#882553d21de4357e610505c9dd19d2abdd32c999" +source = "git+https://github.com/stm32-rs/stm32-eth.git?rev=3759c5c9#3759c5c99c0ab69bb71759030766bc0fba0b6cde" dependencies = [ "aligned", "cortex-m 0.7.4", diff --git a/Cargo.toml b/Cargo.toml index c9a2b9a..0a95263 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ cortex-m = "0.6" cortex-m-rt = { version = "0.6", features = ["device"] } cortex-m-log = { version = "0.6", features = ["log-integration"] } stm32f4xx-hal = { version = "=0.10.1", features = ["rt", "stm32f427", "usb_fs"] } -stm32-eth = { rev = "882553d21", features = ["stm32f427", "smoltcp-phy"], git = "https://github.com/stm32-rs/stm32-eth.git" } -smoltcp = { version = "0.7.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "log"] } +stm32-eth = { rev = "3759c5c9", features = ["stm32f427", "smoltcp-phy"], git = "https://github.com/stm32-rs/stm32-eth.git" } +smoltcp = { version = "0.7.5", default-features = false, features = ["proto-ipv4", "socket-tcp", "log"] } bit_field = "0.10" byteorder = { version = "1", default-features = false } nom = { version = "5", default-features = false } diff --git a/flake.nix b/flake.nix index 6c84438..8ed6067 100644 --- a/flake.nix +++ b/flake.nix @@ -8,8 +8,8 @@ let pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; }; rustManifest = pkgs.fetchurl { - url = "https://static.rust-lang.org/dist/2020-10-30/channel-rust-nightly.toml"; - sha256 = "sha256-4NFISQPmGjbz534No4/ZbXaHT5xbjU25WXgj1MTH0TA="; + url = "https://static.rust-lang.org/dist/2021-10-26/channel-rust-nightly.toml"; + sha256 = "sha256-1hLbypXA+nuH7o3AHCokzSBZAvQxvef4x9+XxO3aBao="; }; targets = [ -- 2.44.2 From 867cec05d4ea90d0f32ba49b89edaa4fb49de82f Mon Sep 17 00:00:00 2001 From: mwojcik Date: Tue, 25 Jan 2022 12:47:31 +0800 Subject: [PATCH 3/4] update code to use stm32f4xx-hal 0.10.1 API --- src/flash_store.rs | 2 +- src/main.rs | 2 +- src/net.rs | 5 ++- src/pins.rs | 76 ++++++++++++++++++++++------------------------ src/server.rs | 6 ++-- src/timer.rs | 6 ++-- 6 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/flash_store.rs b/src/flash_store.rs index ef9f651..473f1ea 100644 --- a/src/flash_store.rs +++ b/src/flash_store.rs @@ -41,7 +41,7 @@ impl StoreBackend for FlashBackend { fn program(&mut self, offset: usize, payload: &[u8]) -> Result<(), Self::Error> { self.flash.unlocked() - .program(get_offset() + offset, payload.iter().cloned()) + .program(get_offset() + offset, payload.iter()) } fn backup_space(&self) -> &'static mut [u8] { diff --git a/src/main.rs b/src/main.rs index 246e20d..c1d7267 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_main)] -#![feature(maybe_uninit_extra, maybe_uninit_ref, asm)] +#![feature(maybe_uninit_extra, asm)] #![cfg_attr(test, allow(unused))] // TODO: #![deny(warnings, unused)] diff --git a/src/net.rs b/src/net.rs index 8e41473..13ef2bf 100644 --- a/src/net.rs +++ b/src/net.rs @@ -5,14 +5,14 @@ use core::cell::RefCell; use cortex_m::interrupt::{CriticalSection, Mutex}; use stm32f4xx_hal::{ rcc::Clocks, - stm32::{interrupt, Peripherals, ETHERNET_MAC, ETHERNET_DMA}, + pac::{interrupt, Peripherals, ETHERNET_MAC, ETHERNET_DMA}, }; use smoltcp::wire::{EthernetAddress, Ipv4Address, Ipv4Cidr}; use smoltcp::iface::{ EthernetInterfaceBuilder, EthernetInterface, NeighborCache, Routes, }; -use stm32_eth::{Eth, RingEntry, PhyAddress, RxDescriptor, TxDescriptor}; +use stm32_eth::{Eth, RingEntry, RxDescriptor, TxDescriptor}; use crate::command_parser::Ipv4Config; use crate::pins::EthernetPins; @@ -48,7 +48,6 @@ pub fn run( let mut eth_dev = Eth::new( ethernet_mac, ethernet_dma, &mut rx_ring[..], &mut tx_ring[..], - PhyAddress::_0, clocks, eth_pins, ).unwrap(); diff --git a/src/pins.rs b/src/pins.rs index 11986b0..f7b55a1 100644 --- a/src/pins.rs +++ b/src/pins.rs @@ -16,8 +16,8 @@ use stm32f4xx_hal::{ otg_fs::USB, rcc::Clocks, pwm::{self, PwmChannels}, - spi::{Spi, NoMiso}, - stm32::{ + spi::{Spi, NoMiso, TransferModeNormal}, + pac::{ ADC1, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, I2C1, @@ -25,6 +25,7 @@ use stm32f4xx_hal::{ SPI2, SPI4, SPI5, TIM1, TIM3, }, + timer::Timer, time::U32Ext, }; use eeprom24x::{self, Eeprom24x}; @@ -36,8 +37,8 @@ use crate::{ pub type Eeprom = Eeprom24x< I2c>, - PB9> + PB8>, + PB9> )>, eeprom24x::page_size::B8, eeprom24x::addr_size::OneByte @@ -45,8 +46,6 @@ pub type Eeprom = Eeprom24x< pub type EthernetPins = EthPins< PA1>, - PA2>, - PC1>, PA7>, PB11>, PG13>, @@ -86,10 +85,10 @@ impl ChannelPins for Channel1 { } /// SPI peripheral used for communication with the ADC -pub type AdcSpi = Spi>, PB14>, PB15>)>; +pub type AdcSpi = Spi>, PB14>, PB15>), TransferModeNormal>; pub type AdcNss = PB12>; -type Dac0Spi = Spi>, NoMiso, PE6>)>; -type Dac1Spi = Spi>, NoMiso, PF9>)>; +type Dac0Spi = Spi>, NoMiso, PE6>), TransferModeNormal>; +type Dac1Spi = Spi>, NoMiso, PF9>), TransferModeNormal>; pub type PinsAdc = Adc; pub struct ChannelPinSet { @@ -192,15 +191,13 @@ impl Pins { let leds = Leds::new(gpiod.pd9, gpiod.pd10.into_push_pull_output(), gpiod.pd11.into_push_pull_output()); - let eeprom_scl = gpiob.pb8.into_alternate_af4().set_open_drain(); - let eeprom_sda = gpiob.pb9.into_alternate_af4().set_open_drain(); - let eeprom_i2c = I2c::i2c1(i2c1, (eeprom_scl, eeprom_sda), 400.khz(), clocks); + let eeprom_scl = gpiob.pb8.into_alternate().set_open_drain(); + let eeprom_sda = gpiob.pb9.into_alternate().set_open_drain(); + let eeprom_i2c = I2c::new(i2c1, (eeprom_scl, eeprom_sda), 400.khz(), clocks); let eeprom = Eeprom24x::new_24x02(eeprom_i2c, eeprom24x::SlaveAddr::default()); let eth_pins = EthPins { ref_clk: gpioa.pa1, - md_io: gpioa.pa2, - md_clk: gpioc.pc1, crs: gpioa.pa7, tx_en: gpiob.pb11, tx_d0: gpiog.pg13, @@ -213,8 +210,8 @@ impl Pins { usb_global: otg_fs_global, usb_device: otg_fs_device, usb_pwrclk: otg_fs_pwrclk, - pin_dm: gpioa.pa11.into_alternate_af10(), - pin_dp: gpioa.pa12.into_alternate_af10(), + pin_dm: gpioa.pa11.into_alternate(), + pin_dp: gpioa.pa12.into_alternate(), hclk: clocks.hclk(), }; @@ -230,14 +227,14 @@ impl Pins { mosi: PB15, ) -> AdcSpi { - let sck = sck.into_alternate_af5(); - let miso = miso.into_alternate_af5(); - let mosi = mosi.into_alternate_af5(); - Spi::spi2( + let sck = sck.into_alternate(); + let miso = miso.into_alternate(); + let mosi = mosi.into_alternate(); + Spi::new( spi2, (sck, miso, mosi), crate::ad7172::SPI_MODE, - crate::ad7172::SPI_CLOCK.into(), + crate::ad7172::SPI_CLOCK, clocks ) } @@ -246,13 +243,13 @@ impl Pins { clocks: Clocks, spi4: SPI4, sclk: PE2, sync: PE4, sdin: PE6 ) -> (Dac0Spi, ::DacSync) { - let sclk = sclk.into_alternate_af5(); - let sdin = sdin.into_alternate_af5(); - let spi = Spi::spi4( + let sclk = sclk.into_alternate(); + let sdin = sdin.into_alternate(); + let spi = Spi::new( spi4, - (sclk, NoMiso, sdin), + (sclk, NoMiso {}, sdin), crate::ad5680::SPI_MODE, - crate::ad5680::SPI_CLOCK.into(), + crate::ad5680::SPI_CLOCK, clocks ); let sync = sync.into_push_pull_output(); @@ -264,13 +261,13 @@ impl Pins { clocks: Clocks, spi5: SPI5, sclk: PF7, sync: PF6, sdin: PF9 ) -> (Dac1Spi, ::DacSync) { - let sclk = sclk.into_alternate_af5(); - let sdin = sdin.into_alternate_af5(); - let spi = Spi::spi5( + let sclk = sclk.into_alternate(); + let sdin = sdin.into_alternate(); + let spi = Spi::new( spi5, - (sclk, NoMiso, sdin), + (sclk, NoMiso {}, sdin), crate::ad5680::SPI_MODE, - crate::ad5680::SPI_CLOCK.into(), + crate::ad5680::SPI_CLOCK, clocks ); let sync = sync.into_push_pull_output(); @@ -307,21 +304,22 @@ impl PwmPins { pin.enable(); } let channels = ( - max_v0.into_alternate_af2(), - max_v1.into_alternate_af2(), + max_v0.into_alternate(), + max_v1.into_alternate(), ); - let (mut max_v0, mut max_v1) = pwm::tim3(tim3, channels, clocks, freq); + //let (mut max_v0, mut max_v1) = pwm::tim3(tim3, channels, clocks, freq); + let (mut max_v0, mut max_v1) = Timer::new(tim3, &clocks).pwm(channels, freq); init_pwm_pin(&mut max_v0); init_pwm_pin(&mut max_v1); let channels = ( - max_i_pos0.into_alternate_af1(), - max_i_pos1.into_alternate_af1(), - max_i_neg0.into_alternate_af1(), - max_i_neg1.into_alternate_af1(), + max_i_pos0.into_alternate(), + max_i_pos1.into_alternate(), + max_i_neg0.into_alternate(), + max_i_neg1.into_alternate(), ); let (mut max_i_pos0, mut max_i_pos1, mut max_i_neg0, mut max_i_neg1) = - pwm::tim1(tim1, channels, clocks, freq); + Timer::new(tim1, &clocks).pwm(channels, freq); init_pwm_pin(&mut max_i_pos0); init_pwm_pin(&mut max_i_neg0); init_pwm_pin(&mut max_i_pos1); diff --git a/src/server.rs b/src/server.rs index 7b6da43..302d1d2 100644 --- a/src/server.rs +++ b/src/server.rs @@ -24,14 +24,14 @@ const TCP_TX_BUFFER_SIZE: usize = 2048; /// Contains a number of server sockets that get all sent the same /// data (through `fmt::Write`). pub struct Server<'a, 'b, S> { - net: EthernetInterface<'a, 'a, 'a, &'a mut stm32_eth::Eth<'static, 'static>>, - sockets: SocketSet<'b, 'b, 'b>, + net: EthernetInterface<'a, &'a mut stm32_eth::Eth<'static, 'static>>, + sockets: SocketSet<'b>, states: [SocketState; SOCKET_COUNT], } impl<'a, 'b, S: Default> Server<'a, 'b, S> { /// Run a server with stack-allocated sockets - pub fn run(net: EthernetInterface<'a, 'a, 'a, &'a mut stm32_eth::Eth<'static, 'static>>, f: F) + pub fn run(net: EthernetInterface<'a, &'a mut stm32_eth::Eth<'static, 'static>>, f: F) where F: FnOnce(&mut Server<'a, '_, S>), { diff --git a/src/timer.rs b/src/timer.rs index f02f4f9..a9cad3d 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -18,8 +18,10 @@ static TIMER_MS: Mutex> = Mutex::new(RefCell::new(0)); /// Setup SysTick exception pub fn setup(syst: SYST, clocks: Clocks) { - let mut timer = Timer::syst(syst, TIMER_RATE.hz(), clocks); - timer.listen(TimerEvent::TimeOut); + + let timer = Timer::syst(syst, &clocks); + let mut countdown = timer.start_count_down(TIMER_RATE.hz()); + countdown.listen(TimerEvent::TimeOut); } /// SysTick exception (Timer) -- 2.44.2 From 6e811f78111a69d96bcfd0c8f2decf64d23a4e57 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Tue, 25 Jan 2022 12:49:49 +0800 Subject: [PATCH 4/4] flake: update stm32-eth sha256 hash --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8ed6067..c28f806 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ cargoLock = { lockFile = ./Cargo.lock; outputHashes = { - "stm32-eth-0.2.0" = "sha256-HXRr/NDhdIKqyjdA4D8ZmcO1dDpDawdlYPUOwcEbPQk="; + "stm32-eth-0.2.0" = "sha256-48RpZgagUqgVeKm7GXdk3Oo0v19ScF9Uby0nTFlve2o="; }; }; -- 2.44.2