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

??

parent 805bf5b5
No related branches found
No related tags found
No related merge requests found
......@@ -10,8 +10,15 @@ use stm32f4;
use stm32f4::stm32f413::GPIOA;
//use stm32f411::{GPIOA, RCC};
//const bit_string: u16 = 0x0FFF;
const bit_string: u16 = 0xF000;
//const bit_string: u16 = 0x0;
//const bit_string: u16 = 0xFFFF;
const bit_string: u16 = 0x0FFF;
//actual string 0b1_01111101_1111
//const bit_s: u32 = 0b10_0110101010100110_10101010; // Start stop high 26 bits (start pos 25)
//const bit_s: u32 = 0b01_0110101010100110_01010101; // Start stop low
const bit_s: u32 = 0b10_0101010101010101_10101010;
//const bit_string: u16 = 0xF000;
/*(
0x0FFF full
0 11111111 1111
......@@ -55,8 +62,9 @@ const APP: () = {
// configure PA5 as output
let gpioa = cx.device.GPIOA;
gpioa.moder.modify(|_, w| unsafe { w.moder5().bits(1) });
gpioa.moder.modify(|_, w| unsafe { w.moder6().bits(1) });
let mut point: u16 = 0x0;
let mut point: u16 = 25;
init::LateResources {
dwt: cx.core.DWT,
......@@ -81,16 +89,35 @@ const APP: () = {
#[task(binds = SysTick, resources = [ON, point],)]
fn syst(cx: syst::Context) {
let r = cx.resources;
if *r.point != 0 {
let m = bit_s >> *r.point & 0x1;
unsafe {
if m == 1 {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(true));
} else {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(false));
}
}
*r.point = *r.point - 1;
} else {
unsafe {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(false));
}
}
/*
let r = cx.resources;
*r.ON = !*r.ON;
if *r.ON == true {
if *r.point == 15 {
*r.point = 0;
if *r.point == 2 {
} else {
*r.point = *r.point + 1;
*r.point = *r.point - 1;
}
}
let bit: u16 = (bit_string & (0x8000 >> *r.point)) >> (15 - *r.point);
let bit: u16 = (bit_string >> *r.point) & 0x1;
//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 {
......@@ -100,11 +127,18 @@ const APP: () = {
} else {
panic!();
}
wr = *r.ON;
if *r.point == 2 {
unsafe {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr6().bit(false)); // output clock on PA6
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(false));
}
} else {
unsafe {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(wr));
(*GPIOA::ptr()).odr.modify(|_, w| w.odr6().bit(*r.ON)); // output clock on PA6
}
}
*/
//rprintln!(*r.point);
//rprintln!("SysTick");
//asm::bkpt();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment