Skip to content

Commit

Permalink
Upgrade to latest HAL
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdewid committed Jan 28, 2024
1 parent dd0dbe1 commit b8387c6
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 113 deletions.
49 changes: 42 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[profile.release]
lto = true # better optimizations
codegen-units = 1 # better optimizations
opt-level = "s" # optimize for size
debug = true # symbols are nice and they don't increase the size on Flash

[workspace]
resolver = "2"
members = [
"hcu",
"m-ecu",
"v-ecu",
"vecraft"
]

[profile.release]
opt-level = "s" # optimize for size
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
4 changes: 2 additions & 2 deletions hcu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
panic-halt = "0.2.0"
systick-monotonic = "1.0"
cortex-m-rtic = { version = "1.1.4" }
stm32h7xx-hal = { version = "0.12.2", features = ["stm32h743v", "rt", "can"] }
fdcan = { version = "0.1.0", features = ["fdcan_h7"] }
stm32h7xx-hal = { version = "0.15.1", features = ["stm32h743v", "rt", "can"] }
fdcan = { version = "0.2.0", features = ["fdcan_h7"] }
vecraft = { version = "0.1.0", path = "../vecraft" }

[[bin]]
Expand Down
13 changes: 7 additions & 6 deletions hcu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod app {
use stm32h7xx_hal::gpio::{self};
use stm32h7xx_hal::prelude::*;
use stm32h7xx_hal::rcc;
use stm32h7xx_hal::watchdog::{Event::EarlyWakeup, SystemWindowWatchdog};
use stm32h7xx_hal::system_watchdog::{Event::EarlyWakeup, SystemWindowWatchdog};
use systick_monotonic::Systick;

/// 100 Hz / 10 ms granularity
Expand Down Expand Up @@ -73,10 +73,10 @@ mod app {
.freeze(pwrcfg, &ctx.device.SYSCFG);

// Switch adc_ker_ck_input multiplexer to per_ck
ccdr.peripheral.kernel_adc_clk_mux(rcc::rec::AdcClkSel::PER);
ccdr.peripheral.kernel_adc_clk_mux(rcc::rec::AdcClkSel::Per);

ccdr.peripheral
.kernel_usart234578_clk_mux(rcc::rec::Usart234578ClkSel::PLL3_Q);
.kernel_usart234578_clk_mux(rcc::rec::Usart234578ClkSel::Pll3Q);

let mut watchdog = SystemWindowWatchdog::new(ctx.device.WWDG, &ccdr);

Expand All @@ -103,7 +103,7 @@ mod app {
let fdcan_prec = ccdr
.peripheral
.FDCAN
.kernel_clk_mux(rcc::rec::FdcanClkSel::PLL1_Q);
.kernel_clk_mux(rcc::rec::FdcanClkSel::Pll1Q);

let canbus1 = {
let rx = gpiod.pd0.into_alternate().speed(gpio::Speed::VeryHigh);
Expand Down Expand Up @@ -201,8 +201,9 @@ mod app {
lockout0: pwr_swtich1,
lockout1: pwr_swtich2,
};
gate_lock.lock();

let gate_control = vecraft::lsgc::GateControl {
let mut gate_control = vecraft::lsgc::GateControl {
gate0,
gate1,
gate2,
Expand All @@ -212,7 +213,7 @@ mod app {
gate6,
gate7,
};
gate_lock.lock();
gate_control.reset();

motd::spawn().ok();
firmware_state::spawn().ok();
Expand Down
4 changes: 2 additions & 2 deletions m-ecu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
panic-halt = "0.2.0"
systick-monotonic = "1.0"
cortex-m-rtic = { version = "1.1.4" }
stm32h7xx-hal = { version = "0.12.2", features = ["stm32h743v", "rt", "can"] }
fdcan = { version = "0.1.0", features = ["fdcan_h7"] }
stm32h7xx-hal = { version = "0.15.1", features = ["stm32h743v", "rt", "can"] }
fdcan = { version = "0.2.0", features = ["fdcan_h7"] }
vecraft = { version = "0.1.0", path = "../vecraft" }

[[bin]]
Expand Down
20 changes: 13 additions & 7 deletions m-ecu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod app {
use stm32h7xx_hal::gpio::{self};
use stm32h7xx_hal::prelude::*;
use stm32h7xx_hal::rcc;
use stm32h7xx_hal::watchdog::SystemWindowWatchdog;
use stm32h7xx_hal::system_watchdog::SystemWindowWatchdog;
use systick_monotonic::Systick;

/// 100 Hz / 10 ms granularity
Expand Down Expand Up @@ -83,10 +83,10 @@ mod app {
.freeze(pwrcfg, &ctx.device.SYSCFG);

// Switch adc_ker_ck_input multiplexer to per_ck
ccdr.peripheral.kernel_adc_clk_mux(rcc::rec::AdcClkSel::PER);
ccdr.peripheral.kernel_adc_clk_mux(rcc::rec::AdcClkSel::Per);

ccdr.peripheral
.kernel_usart234578_clk_mux(rcc::rec::Usart234578ClkSel::PLL3_Q);
.kernel_usart234578_clk_mux(rcc::rec::Usart234578ClkSel::Pll3Q);

let mut watchdog = SystemWindowWatchdog::new(ctx.device.WWDG, &ccdr);

Expand All @@ -113,7 +113,7 @@ mod app {
let fdcan_prec = ccdr
.peripheral
.FDCAN
.kernel_clk_mux(rcc::rec::FdcanClkSel::PLL1_Q);
.kernel_clk_mux(rcc::rec::FdcanClkSel::Pll1Q);

let canbus1 = {
let rx = gpiod.pd0.into_alternate().speed(gpio::Speed::VeryHigh);
Expand All @@ -132,10 +132,16 @@ mod app {
// ADC
use stm32h7xx_hal::adc::{Adc, AdcSampleTime, Resolution};

let mut adc1 =
Adc::adc1(ctx.device.ADC1, &mut k, ccdr.peripheral.ADC12, &ccdr.clocks).enable();
let mut adc1 = Adc::adc1(
ctx.device.ADC1,
4.MHz(),
&mut k,
ccdr.peripheral.ADC12,
&ccdr.clocks,
)
.enable();

adc1.set_resolution(Resolution::TWELVEBITV);
adc1.set_resolution(Resolution::TwelveBit);
adc1.set_sample_time(AdcSampleTime::T_387);

let channel1 = gpioc.pc2.into_analog();
Expand Down
4 changes: 2 additions & 2 deletions v-ecu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
panic-halt = "0.2.0"
systick-monotonic = "1.0"
cortex-m-rtic = { version = "1.1.4" }
stm32h7xx-hal = { version = "0.12.2", features = ["stm32h743v", "rt", "can", "usb_hs"] }
fdcan = { version = "0.1.0", features = ["fdcan_h7"] }
stm32h7xx-hal = { version = "0.15.1", features = ["stm32h743v", "rt", "can", "usb_hs"] }
fdcan = { version = "0.2.0", features = ["fdcan_h7"] }
vecraft = { version = "0.1.0", path = "../vecraft" }
usb-device = "0.2.9"

Expand Down
Loading

0 comments on commit b8387c6

Please sign in to comment.