From 4b74df7ac6b682c6df60d92f46d8b1f7af85a2d3 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Sun, 29 May 2022 22:12:15 +0800 Subject: [PATCH] update rgb dependencies --- rgb/Cargo.toml | 8 ++++++-- rgb/elf2bin.sh | 6 ++++++ rgb/src/main.rs | 27 +++++++++++++-------------- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100755 rgb/elf2bin.sh diff --git a/rgb/Cargo.toml b/rgb/Cargo.toml index 580c876..5a748fe 100644 --- a/rgb/Cargo.toml +++ b/rgb/Cargo.toml @@ -7,13 +7,17 @@ authors = ["guozhanxin "] [dependencies] cortex-m = "0.7" -cortex-m-rt = "0.6.5" +cortex-m-rt = "0.7" panic-halt = "0.2.0" panic-semihosting = "0.6.0" cortex-m-semihosting = "0.5.0" -stm32l4xx-hal = { version = "0.6.0", features = ["rt", "stm32l4x2"] } nb = "1.0.0" +[dependencies.stm32l4xx-hal] +git = "https://github.com/stm32-rs/stm32l4xx-hal" +tag = "v0.7.1" +features = ["rt", "stm32l475"] + [profile.dev] opt-level = 1 debug = true diff --git a/rgb/elf2bin.sh b/rgb/elf2bin.sh new file mode 100755 index 0000000..a25b4c0 --- /dev/null +++ b/rgb/elf2bin.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +project_path=$(cd `dirname $0`; pwd) +project_name="${project_path##*/}" +/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-objcopy target/thumbv7em-none-eabihf/release/$project_name -O binary $project_name.bin +echo 'make' $project_name'.bin OK!' \ No newline at end of file diff --git a/rgb/src/main.rs b/rgb/src/main.rs index c57b897..3245cc2 100644 --- a/rgb/src/main.rs +++ b/rgb/src/main.rs @@ -4,7 +4,6 @@ //! pe8 is used as pandora LED_B. //! pe9 is used as pandora LED_G. //! -#![deny(unsafe_code)] #![deny(warnings)] #![no_main] #![no_std] @@ -52,9 +51,9 @@ fn main() -> ! { // TRY this alternate clock configuration (clocks run at nearly the maximum frequency) let clocks = rcc .cfgr - .sysclk(80.mhz()) - .pclk1(80.mhz()) - .pclk2(80.mhz()) + .sysclk(80.MHz()) + .pclk1(80.MHz()) + .pclk2(80.MHz()) .freeze(&mut flash.acr, &mut pwr); let mut gpioe = dp.GPIOE.split(&mut rcc.ahb2); @@ -62,8 +61,8 @@ fn main() -> ! { .pe7 .into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper); let mut led_b = gpioe - .pe8 - .into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper); + .pe8 + .into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper); let mut led_g = gpioe .pe9 .into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper); @@ -76,19 +75,19 @@ fn main() -> ! { let g:i32 = _BLINK_TAB[index][1]; let b:i32 = _BLINK_TAB[index][2]; if r == LED_ON { - led_r.set_high().ok(); + led_r.set_high(); }else{ - led_r.set_low().ok(); + led_r.set_low(); } if g == LED_ON { - led_g.set_high().ok(); + led_g.set_high(); }else{ - led_g.set_low().ok(); + led_g.set_low(); } if b == LED_ON { - led_b.set_high().ok(); + led_b.set_high(); }else{ - led_b.set_low().ok(); + led_b.set_low(); } index = index + 1; @@ -100,6 +99,6 @@ fn main() -> ! { } #[exception] -fn HardFault(ef: &ExceptionFrame) -> ! { +unsafe fn HardFault(ef: &ExceptionFrame) -> ! { panic!("{:#?}", ef); -} \ No newline at end of file +}