diff --git a/Cargo.lock b/Cargo.lock
index 22cf644..b088d88 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -41,6 +41,12 @@ dependencies = [
"stable_deref_trait",
]
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
[[package]]
name = "bare-metal"
version = "0.2.5"
@@ -253,12 +259,16 @@ dependencies = [
"cortex-m-log",
"cortex-m-rt",
"cortex-m-semihosting 0.5.0",
+ "fugit",
"log",
"nb 1.0.0",
+ "num-traits",
"panic-halt",
"smoltcp",
"stm32-eth",
"stm32f4xx-hal",
+ "usb-device",
+ "usbd-serial",
]
[[package]]
@@ -267,6 +277,12 @@ version = "0.2.135"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
+[[package]]
+name = "libm"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565"
+
[[package]]
name = "log"
version = "0.4.17"
@@ -297,6 +313,16 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
+[[package]]
+name = "num-traits"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
+dependencies = [
+ "autocfg",
+ "libm",
+]
+
[[package]]
name = "num_threads"
version = "0.1.6"
@@ -482,6 +508,17 @@ version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508"
+[[package]]
+name = "usbd-serial"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db75519b86287f12dcf0d171c7cf4ecc839149fe9f3b720ac4cfce52959e1dfe"
+dependencies = [
+ "embedded-hal 0.2.7",
+ "nb 0.1.3",
+ "usb-device",
+]
+
[[package]]
name = "vcell"
version = "0.1.3"
diff --git a/Cargo.toml b/Cargo.toml
index 8eed748..81166b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,6 +25,10 @@ cortex-m-log = { version = "0.7.0", features = ["log-integration", "semihosting"
stm32f4xx-hal = { version = "0.13.2", features = ["rt", "stm32f407", "usb_fs"] }
stm32-eth = { version = "0.3.0", features = ["stm32f407"] }
smoltcp = { version = "0.8.0", default-features = false, features = ["proto-ipv4", "socket-tcp", "log", "medium-ethernet"] }
+num-traits = { version = "0.2.15", default-features = false, features = ["libm"] }
+usb-device = "0.2.9"
+usbd-serial = "0.1.1"
+fugit = "0.3.6"
[features]
diff --git a/flake.lock b/flake.lock
index 6586fc9..9e751b7 100644
--- a/flake.lock
+++ b/flake.lock
@@ -18,16 +18,16 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1659446231,
- "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=",
+ "lastModified": 1666164185,
+ "narHash": "sha256-5v+YB4ijeUfg5LCz9ck4gIpCPhIS+qn02OyPJO48bCE=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d",
+ "rev": "c5203abb1329f7ea084c04acda330ca75d5b9fb5",
"type": "github"
},
"original": {
"owner": "NixOS",
- "ref": "nixos-21.11",
+ "ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
diff --git a/flake.nix b/flake.nix
index 600309c..1ce69ee 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,7 +1,7 @@
{
description = "Firmware for kirdy";
- inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
+ inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.05;
inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; };
outputs = { self, nixpkgs, mozilla-overlay }:
diff --git a/src/current_source/max5719.rs b/src/current_source/max5719.rs
new file mode 100644
index 0000000..e69de29
diff --git a/src/device/gpio.rs b/src/device/gpio.rs
new file mode 100644
index 0000000..b9b1a19
--- /dev/null
+++ b/src/device/gpio.rs
@@ -0,0 +1,87 @@
+use stm32f4xx_hal::{
+ adc::Adc,
+ gpio::{
+ AF5, Alternate, AlternateOD, Analog, Floating, Input,
+ gpioa::*,
+ gpiob::*,
+ gpioc::*,
+ gpioe::*,
+ gpiof::*,
+ gpiog::*,
+ GpioExt,
+ Output, PushPull,
+ },
+ hal::{self, blocking::spi::Transfer, digital::v2::OutputPin},
+ otg_fs::USB,
+ rcc::Clocks,
+ pwm::{self, PwmChannels},
+ spi::{Spi, NoMiso, TransferModeNormal},
+ pac::{
+ ADC1,
+ GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG,
+ OTG_FS_GLOBAL, OTG_FS_DEVICE, OTG_FS_PWRCLK,
+ SPI1, SPI2, SPI3,
+ TIM4
+ },
+ timer::Timer,
+ time::U32Ext,
+};
+
+use stm32_eth::EthPins;
+pub type EthernetPins = EthPins<
+ PA1>,
+ PA7>,
+ PB11>,
+ PG13>,
+ PB13>,
+ PC4>,
+ PC5>,
+>;
+
+impl thermostatPins for thermostat {
+ type DacSpi = Dac0Spi;
+ type DacSync = PE4