Skip to content
Snippets Groups Projects
Commit 805bf5b5 authored by Edvin Åkerfeldt's avatar Edvin Åkerfeldt
Browse files

dsi_debug

parent 3d058cc9
No related branches found
No related tags found
No related merge requests found
//#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m::peripheral::syst::SystClkSource;
use cortex_m::{asm, peripheral::DWT};
use panic_rtt_target as _;
use rtt_target::{rprintln, rtt_init_print};
use stm32f4;
use stm32f4::stm32f413::GPIOA;
//use stm32f411::{GPIOA, RCC};
//const bit_string: u16 = 0x0FFF;
const bit_string: u16 = 0xF000;
/*(
0x0FFF full
0 11111111 1111
start | data | stop
0x07dF half
0x000F off
*/
const big_endian: bool = true;
#[rtic::app(device = stm32f4::stm32f413, peripherals = true)]
const APP: () = {
struct Resources {
dwt: DWT,
ON: bool,
point: u16,
}
#[init]
fn init(mut cx: init::Context) -> init::LateResources {
rtt_init_print!();
rprintln!("init");
// Initialize (enable) the monotonic timer (CYCCNT)
cx.core.DCB.enable_trace();
cx.core.DWT.enable_cycle_counter();
let mut c = cx.core.SYST;
c.set_clock_source(SystClkSource::Core);
//c.set_reload(8_000_000 / 150);
c.set_reload(3333);
c.clear_current();
c.enable_counter();
c.enable_interrupt();
//let p = cx.RCC;
// power on GPIOA
let rcc = cx.device.RCC;
rcc.ahb1enr.modify(|_, w| w.gpioaen().set_bit());
// configure PA5 as output
let gpioa = cx.device.GPIOA;
gpioa.moder.modify(|_, w| unsafe { w.moder5().bits(1) });
let mut point: u16 = 0x0;
init::LateResources {
dwt: cx.core.DWT,
ON: false,
point: point,
}
}
#[idle]
fn idle(_cx: idle::Context) -> ! {
rprintln!("idle");
/*
unsafe { cx.resources.dwt.cyccnt.write(0) };
asm::bkpt();
rtic::pend(stm32f411::Interrupt::EXTI0);
asm::bkpt();
*/
loop {
continue;
}
}
#[task(binds = SysTick, resources = [ON, point],)]
fn syst(cx: syst::Context) {
let r = cx.resources;
*r.ON = !*r.ON;
if *r.ON == true {
if *r.point == 15 {
*r.point = 0;
} else {
*r.point = *r.point + 1;
}
}
let bit: u16 = (bit_string & (0x8000 >> *r.point)) >> (15 - *r.point);
let t: u16 = bit ^ (*r.ON as u16);
let mut wr: bool;
if t == 1 {
wr = true;
} else if t == 0 {
wr = false;
} else {
panic!();
}
wr = *r.ON;
unsafe {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(wr));
}
//rprintln!(*r.point);
//rprintln!("SysTick");
//asm::bkpt();
}
/*
#[task(binds = EXTI0)]
fn exti0(_cx: exti0::Context) {
asm::bkpt();
}
*/
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment