boards/kakute-f7-mini-v3: simple led demo for board testing
Signed-off-by: Onur Özkan <work@onurozkan.dev>
This commit is contained in:
1 parent
bd9fef26e5
commit
e0065f8963
5 files changed
+56
-9
No files matched your search
Generated
+1
@@ -104,6 +104,7 @@ name = "kaptan-kakute-f7-mini-v3"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"kaptan-spec",
|
||||
"panic-halt",
|
||||
"rtic",
|
||||
|
||||
@@ -11,9 +11,10 @@ firmware = []
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.7"
|
||||
cortex-m-rt = "0.7"
|
||||
panic-halt = "1"
|
||||
rtic = { version = "2.3", default-features = false, features = ["thumbv7-backend"] }
|
||||
stm32f7 = { version = "0.16", default-features = false, features = ["rt", "stm32f745"] }
|
||||
stm32f7 = { version = "0.16", default-features = false, features = ["rt", "stm32f722"] }
|
||||
|
||||
[build-dependencies]
|
||||
kaptan-spec = { path = "../../libs/kaptan-spec", features = ["std"] }
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
fn main() {
|
||||
kaptan_spec::validate_package();
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
println!("cargo:rustc-link-arg=-Tlink.x");
|
||||
println!(
|
||||
"cargo:rustc-link-search={}",
|
||||
std::env::var("CARGO_MANIFEST_DIR").expect("Cargo must set CARGO_MANIFEST_DIR")
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 256K
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use cortex_m_rt as _;
|
||||
use panic_halt as _;
|
||||
|
||||
#[rtic::app(device = stm32f7::stm32f745, peripherals = true)]
|
||||
#[rtic::app(device = stm32f7::stm32f722, peripherals = true)]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
@@ -13,11 +14,30 @@ mod app {
|
||||
#[local]
|
||||
struct Local {
|
||||
// TODO
|
||||
led: stm32f7::stm32f722::GPIOD,
|
||||
led_output_high: bool,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_context: init::Context) -> (Shared, Local) {
|
||||
(Shared {}, Local {})
|
||||
fn init(context: init::Context) -> (Shared, Local) {
|
||||
let device = context.device;
|
||||
|
||||
device
|
||||
.RCC
|
||||
.ahb1enr()
|
||||
.modify(|_, write| write.gpioden().set_bit());
|
||||
device
|
||||
.GPIOD
|
||||
.moder()
|
||||
.modify(|_, write| write.moder2().output());
|
||||
|
||||
(
|
||||
Shared {},
|
||||
Local {
|
||||
led: device.GPIOD,
|
||||
led_output_high: false,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = EXTI4, priority = 15)]
|
||||
@@ -25,12 +45,25 @@ mod app {
|
||||
// TODO
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle(_context: idle::Context) -> ! {
|
||||
// TODO
|
||||
|
||||
#[idle(local = [led, led_output_high])]
|
||||
fn idle(context: idle::Context) -> ! {
|
||||
loop {
|
||||
cortex_m::asm::wfi();
|
||||
if *context.local.led_output_high {
|
||||
context
|
||||
.local
|
||||
.led
|
||||
.bsrr()
|
||||
.write(|write| write.br2().set_bit());
|
||||
} else {
|
||||
context
|
||||
.local
|
||||
.led
|
||||
.bsrr()
|
||||
.write(|write| write.bs2().set_bit());
|
||||
}
|
||||
|
||||
*context.local.led_output_high = !*context.local.led_output_high;
|
||||
cortex_m::asm::delay(8_000_000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user