From 16354258928264c1851978030eb9733f8b2c6099 Mon Sep 17 00:00:00 2001 From: Pablo Mansanet Date: Fri, 27 Oct 2023 13:17:26 +0200 Subject: [PATCH 1/3] Implement fan protocol behind feature flag --- Cargo.toml | 4 ++++ src/fan_controller.rs | 54 +++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 32 +++++++++++++++++++++---- 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/fan_controller.rs diff --git a/Cargo.toml b/Cargo.toml index a023675..a7526aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,10 @@ authors = ["Brian Schwind "] license = "MIT" edition = "2018" +[features] +default = ["fan_control"] +fan_control = [] + [dependencies] stm32f4xx-hal = { version = "0.9", features = ["rt", "stm32f411", "usb_fs"] } embedded-hal = "0.2" diff --git a/src/fan_controller.rs b/src/fan_controller.rs new file mode 100644 index 0000000..03fe4c1 --- /dev/null +++ b/src/fan_controller.rs @@ -0,0 +1,54 @@ +use embedded_hal::PwmPin; + +pub struct FanController +where + P1: PwmPin, + P1: PwmPin, + P3: PwmPin, + P4: PwmPin, +{ + fan_1: P1, + fan_2: P2, + fan_3: P3, + fan_4: P4, +} + +impl FanController +where + P1: PwmPin, + P2: PwmPin, + P3: PwmPin, + P4: PwmPin, +{ + pub fn new(mut fan_1: P1, mut fan_2: P2, mut fan_3: P3, mut fan_4: P4) -> Self { + fan_1.enable(); + fan_2.enable(); + fan_3.enable(); + fan_4.enable(); + + fan_1.set_duty(0); + fan_2.set_duty(0); + fan_3.set_duty(0); + fan_4.set_duty(0); + + Self { fan_1, fan_2, fan_3, fan_4 } + } + + /// 0 = Off + /// u16::MAX = Maximum Speed + pub fn set_speed(&mut self, speed: u16, fan_index: u8) { + // Invert the value because our transistor circuit inverts the PWM signal. + let speed = u16::MAX - speed; + + let fan: &mut dyn PwmPin = match fan_index { + 0 => &mut self.fan_1, + 1 => &mut self.fan_2, + 2 => &mut self.fan_3, + 3 => &mut self.fan_4, + _ => panic!("Invalid fan index"), + }; + + let adjusted = ((speed as f32 / u16::MAX as f32) * fan.get_max_duty() as f32) as u16; + fan.set_duty(adjusted); + } +} diff --git a/src/main.rs b/src/main.rs index 6e7a07d..98d4164 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,10 +7,13 @@ use panic_reset as _; // panic handler use stm32f4xx_hal as hal; +#[cfg(feature = "fan_control")] +use crate::fan_controller::FanController; +#[cfg(not(feature = "fan_control"))] +use crate::overhead_light::OverheadLight; use crate::{ button::{Active, Button, ButtonEvent, Debouncer}, counter::Counter, - overhead_light::OverheadLight, rgb_led::{LedStrip, Pulser}, serial::{Command, Report, SerialProtocol}, }; @@ -31,6 +34,9 @@ use usbd_serial::{SerialPort, USB_CLASS_CDC}; mod bootload; mod button; mod counter; +#[cfg(feature = "fan_control")] +mod fan_controller; +#[cfg(not(feature = "fan_control"))] mod overhead_light; mod rgb; mod rgb_led; @@ -90,29 +96,39 @@ fn main() -> ! { // PWM Setup let pwm_freq = 1.khz(); - let back_light_pwm_pins = ( + #[cfg(not(feature = "fan_control"))] + // Used for lights only. + let pwm_pin_block_a = ( gpioa.pa0.into_alternate_af2(), gpioa.pa1.into_alternate_af2(), gpioa.pa2.into_alternate_af2(), gpioa.pa3.into_alternate_af2(), ); - let front_light_pwm_pins = ( + // Flexible between lights and fans. + let pwm_pin_block_b = ( gpioa.pa6.into_alternate_af2(), gpioa.pa7.into_alternate_af2(), gpiob.pb0.into_alternate_af2(), gpiob.pb1.into_alternate_af2(), ); - let (pwm1, pwm2, pwm3, pwm4) = pwm::tim5(dp.TIM5, back_light_pwm_pins, clocks, pwm_freq); - let (pwm5, pwm6, pwm7, pwm8) = pwm::tim3(dp.TIM3, front_light_pwm_pins, clocks, pwm_freq); + #[cfg(not(feature = "fan_control"))] + let (pwm1, pwm2, pwm3, pwm4) = pwm::tim5(dp.TIM5, pwm_pin_block_a, clocks, pwm_freq); + let (pwm5, pwm6, pwm7, pwm8) = pwm::tim3(dp.TIM3, pwm_pin_block_b, clocks, pwm_freq); + + #[cfg(not(feature = "fan_control"))] // The overhead light closer to the screen. let mut front_light = OverheadLight::new(pwm1, pwm2, pwm3, pwm4); + #[cfg(not(feature = "fan_control"))] // The overhead light farther away from the screen. let mut back_light = OverheadLight::new(pwm5, pwm6, pwm7, pwm8); + #[cfg(feature = "fan_control")] + let mut fan_controller = FanController::new(pwm5, pwm6, pwm7, pwm8); + // Connect a rotary encoder to pins A8 and A9. let rotary_encoder_timer = dp.TIM1; let rotary_encoder_pins = (gpioa.pa8.into_alternate_af1(), gpioa.pa9.into_alternate_af1()); @@ -195,11 +211,13 @@ fn main() -> ! { // TODO(bschwind) - Report any poll errors back to the USB host if possible. for command in protocol.poll().unwrap() { match command { + #[cfg(not(feature = "fan_control"))] Command::Brightness { target, value } => match target { 0 => front_light.set_brightness(value), 1 => back_light.set_brightness(value), _ => {}, }, + #[cfg(not(feature = "fan_control"))] Command::Temperature { target, value } => match target { 0 => front_light.set_color_temperature(value), 1 => back_light.set_color_temperature(value), @@ -213,6 +231,10 @@ fn main() -> ! { led.set_high().unwrap(); bootload::request_bootloader(); }, + #[cfg(feature = "fan_control")] + Command::FanSpeed { target, value } if target < 4 => { + fan_controller.set_speed(value, target) + }, _ => {}, } } From de28e00c791790cc1892ab3dff0a20576a2a9778 Mon Sep 17 00:00:00 2001 From: Pablo Mansanet Date: Mon, 30 Oct 2023 10:09:57 +0100 Subject: [PATCH 2/3] Update dependencies --- Cargo.lock | 176 +++++++++++++++++++++-------------------------------- Cargo.toml | 4 +- 2 files changed, 72 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30212b3..7468601 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,10 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aligned" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19796bd8d477f1a9d4ac2465b464a8b1359474f06a96bb3cda650b4fca309bf" +checksum = "3a785a543aea40f5e4e2e93bb2655d31bc21bb391fff65697150973e383f16bb" dependencies = [ "as-slice", ] @@ -23,15 +25,15 @@ checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" dependencies = [ "generic-array 0.12.4", "generic-array 0.13.3", - "generic-array 0.14.4", + "generic-array 0.14.7", "stable_deref_trait", ] [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bare-metal" @@ -56,20 +58,19 @@ checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] name = "cast" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ - "rustc_version 0.3.3", + "rustc_version 0.4.0", ] [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ - "num-integer", "num-traits", ] @@ -82,15 +83,15 @@ dependencies = [ "aligned", "bare-metal 0.2.5", "bitfield", - "cortex-m 0.7.2", + "cortex-m 0.7.7", "volatile-register", ] [[package]] name = "cortex-m" -version = "0.7.2" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643a210c1bdc23d0db511e2a576082f4ff4dcae9d0c37f50b431b8f8439d6d6b" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ "bare-metal 0.2.5", "bitfield", @@ -100,9 +101,9 @@ dependencies = [ [[package]] name = "cortex-m-rt" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d8353767db816419630a76d5f1ad5b09610d22b67ceb59647df6a8abc667f8" +checksum = "454f278bf469e2de0a4d22ea019d169d8944f86957c8207a39e3f66c32be2fc6" dependencies = [ "cortex-m-rt-macros", "r0", @@ -110,9 +111,9 @@ dependencies = [ [[package]] name = "cortex-m-rt-macros" -version = "0.1.8" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717562afbba06e760d34451919f5c3bf3ac15c7bb897e8b04862a7428378647" +checksum = "c8e3aa52243e26f5922fa522b0814019e0c98fc567e2756d715dce7ad7a81f49" dependencies = [ "proc-macro2", "quote", @@ -130,9 +131,9 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db184d3fa27bc7a2344250394c0264144dfe0bc81a4401801dcb964b8dd172ad" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" dependencies = [ "nb 0.1.3", "void", @@ -158,9 +159,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -168,9 +169,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.1" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "nb" @@ -178,43 +179,33 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" dependencies = [ - "nb 1.0.0", + "nb 1.1.0", ] [[package]] name = "nb" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" - -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "panel-firmware" -version = "0.3.0" +version = "0.4.0" dependencies = [ - "cortex-m 0.7.2", + "cortex-m 0.7.7", "cortex-m-rt", "embedded-hal", "libm", - "nb 1.0.0", + "nb 1.1.0", "panel-protocol", "panic-reset", "stm32f4xx-hal", @@ -224,44 +215,35 @@ dependencies = [ [[package]] name = "panel-protocol" -version = "0.4.0" -source = "git+https://github.com/tonarino/panel-protocol.git?rev=0.4#47f7a1ed57a8ccee9fe69fe56ce22828e7ae6fa8" +version = "0.5.0" +source = "git+https://github.com/tonarino/panel-protocol.git?rev=0.6#89f3491b6707099a8fa04cb57a0c1c08122b5533" dependencies = [ "arrayvec", ] [[package]] name = "panic-reset" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acee8535a38487c5c70d61ee87284710452cb3b265304463f20a0c5327a4a8a5" -dependencies = [ - "cortex-m 0.6.7", -] - -[[package]] -name = "pest" -version = "2.1.3" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "6cf1ff2a5b1a478dd94572aa43476b6630e72071cbd016985003ad3903a3a4f5" dependencies = [ - "ucd-trie", + "cortex-m 0.7.7", ] [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -274,15 +256,15 @@ checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" [[package]] name = "rand_core" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "rtcc" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1048f7217bcd4bd977c01288e4973a69cf9195681f8b0b3a45d92ea21148f4a8" +checksum = "ef35f9dcbf434a34dcc99b3ebba1c1945d49c70832958e932e83dc63a5273994" dependencies = [ "chrono", ] @@ -298,11 +280,11 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 0.11.0", + "semver 1.0.20", ] [[package]] @@ -311,17 +293,14 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0", + "semver-parser", ] [[package]] name = "semver" -version = "0.11.0" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser 0.10.2", -] +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "semver-parser" @@ -329,15 +308,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -351,7 +321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da3d56009c8f32e4f208dbea17df72484154d1040a8969b75d8c73eb7b18fe8f" dependencies = [ "bare-metal 0.2.5", - "cortex-m 0.7.2", + "cortex-m 0.7.7", "cortex-m-rt", "vcell", ] @@ -364,11 +334,11 @@ checksum = "89b4cb13b1bb36e7381eaf8941062b1eba172542b9d4f72dc50c35c4ac6260f2" dependencies = [ "bare-metal 1.0.0", "cast", - "cortex-m 0.7.2", + "cortex-m 0.7.7", "cortex-m-rt", "embedded-dma", "embedded-hal", - "nb 1.0.0", + "nb 1.1.0", "rand_core", "rtcc", "stm32f4", @@ -378,13 +348,13 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.72" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -400,27 +370,21 @@ dependencies = [ [[package]] name = "typenum" -version = "1.13.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "ucd-trie" -version = "0.1.3" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "usb-device" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6be90410d4772074ea49525e2e753b65920b94b57eee21a6ef7b6a6fe6296245" +checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" [[package]] name = "usbd-serial" @@ -441,9 +405,9 @@ checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -453,9 +417,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile-register" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" +checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] diff --git a/Cargo.toml b/Cargo.toml index a7526aa..69124ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "panel-firmware" -version = "0.3.0" +version = "0.4.0" authors = ["Brian Schwind "] license = "MIT" edition = "2018" @@ -16,7 +16,7 @@ cortex-m = "0.7" cortex-m-rt = "0.6" panic-reset = "0.1" nb = "1" -panel-protocol = { git = "https://github.com/tonarino/panel-protocol.git", rev = "0.4" } +panel-protocol = { git = "https://github.com/tonarino/panel-protocol.git", rev = "0.6" } usb-device = "0.2" usbd-serial = "0.1" libm = "0.2" From 565271ce34e9eed51b9b336e9be64b8fcc37a15a Mon Sep 17 00:00:00 2001 From: Pablo Mansanet Date: Mon, 30 Oct 2023 10:25:10 +0100 Subject: [PATCH 3/3] Fix lints --- src/bootload.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootload.rs b/src/bootload.rs index defc627..f10701f 100644 --- a/src/bootload.rs +++ b/src/bootload.rs @@ -28,9 +28,9 @@ pub fn jump_to_bootloader_if_requested(dp: &stm32::Peripherals) { let magic_num: u32 = read_backup_register(dp); if magic_num == MAGIC_BOOTLOADER_NUMBER { - enable_backup_domain(&dp); + enable_backup_domain(dp); write_to_backup_register(0, dp); - disable_backup_domain(&dp); + disable_backup_domain(dp); unsafe { cortex_m::asm::bootload(BOOTLOADER_FIRMWARE_MEMORY_LOCATION as *const u32);