added C hal into the project successfuly

This commit is contained in:
Filipriec
2025-12-02 13:44:47 +01:00
parent f7063f877d
commit af781eb1f8
4 changed files with 65 additions and 6 deletions

View File

@@ -13,3 +13,7 @@ rustflags = [
[package.metadata.cargo-flash]
chip = "STM32U575ZIT"
[env]
CC_thumbv8m_main_none_eabihf = "arm-none-eabi-gcc"
AR_thumbv8m_main_none_eabihf = "arm-none-eabi-ar"

View File

@@ -109,9 +109,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.2.44"
version = "1.2.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3"
checksum = "c481bdbf0ed3b892f6f806287d72acd515b352a4ec27a208489b8c1bc839633a"
dependencies = [
"find-msvc-tools",
"shlex",
@@ -294,6 +294,7 @@ dependencies = [
name = "dma_gpio"
version = "0.1.0"
dependencies = [
"cc",
"cortex-m",
"cortex-m-rt",
"defmt 1.0.1",
@@ -648,9 +649,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "find-msvc-tools"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
[[package]]
name = "float-cmp"

View File

@@ -1,5 +1,5 @@
[package]
authors = ["Priec <filippriec@gmail.com>"]
[package]
authors = ["Priec <filippriec@gmail.com>"]
name = "dma_gpio"
edition = "2024"
version = "0.1.0"
@@ -33,6 +33,9 @@ embedded-io-async = "0.6.1"
[dev-dependencies]
defmt-test = "0.4.0"
[build-dependencies]
cc = "1.2.48"
[[test]]
name = "uart_emulation"
harness = false

51
semestralka_2/build.rs Normal file
View File

@@ -0,0 +1,51 @@
use std::env;
use std::path::PathBuf;
fn main() {
let cube_path = PathBuf::from("/home/priec/programs/STM32CubeU5");
let hal_driver = cube_path.join("Drivers/STM32U5xx_HAL_Driver");
let cmsis = cube_path.join("Drivers/CMSIS");
let device = cmsis.join("Device/ST/STM32U5xx");
let example_inc = cube_path.join("Projects/NUCLEO-U575ZI-Q/Examples/GPIO/GPIO_IOToggle/Inc");
let hal_srcs = [
"stm32u5xx_hal.c",
"stm32u5xx_hal_rcc.c",
"stm32u5xx_hal_rcc_ex.c",
"stm32u5xx_hal_pwr.c",
"stm32u5xx_hal_pwr_ex.c",
"stm32u5xx_hal_gpio.c",
"stm32u5xx_hal_cortex.c",
"stm32u5xx_hal_flash.c",
"stm32u5xx_hal_flash_ex.c",
"stm32u5xx_hal_icache.c",
"stm32u5xx_hal_ramcfg.c",
"stm32u5xx_hal_rtc.c",
"stm32u5xx_hal_rtc_ex.c",
];
let mut build = cc::Build::new();
for src in hal_srcs {
build.file(hal_driver.join("Src").join(src));
}
build
.include(hal_driver.join("Inc"))
.include(device.join("Include"))
.include(cmsis.join("Core/Include"))
.include(&example_inc)
.define("USE_HAL_DRIVER", None)
.define("STM32U575xx", None)
// flags
.flag("-mthumb")
.flag("-march=armv8-m.main+fp.dp")
.flag("-mfloat-abi=hard")
.warnings(false)
.compile("stm32u5_hal");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed={}", hal_driver.display());
println!("cargo:rerun-if-changed={}", example_inc.display());
}