Skip to content

Commit

Permalink
update rgb dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Guozhanxin committed May 29, 2022
1 parent 5c3f93b commit 4b74df7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
8 changes: 6 additions & 2 deletions rgb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ authors = ["guozhanxin <[email protected]>"]

[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
Expand Down
6 changes: 6 additions & 0 deletions rgb/elf2bin.sh
Original file line number Diff line number Diff line change
@@ -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!'
27 changes: 13 additions & 14 deletions rgb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -52,18 +51,18 @@ 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);
let mut led_r = gpioe
.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);
Expand All @@ -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;
Expand All @@ -100,6 +99,6 @@ fn main() -> ! {
}

#[exception]
fn HardFault(ef: &ExceptionFrame) -> ! {
unsafe fn HardFault(ef: &ExceptionFrame) -> ! {
panic!("{:#?}", ef);
}
}

0 comments on commit 4b74df7

Please sign in to comment.