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

Added ticking

parent b875d605
No related branches found
No related tags found
No related merge requests found
......@@ -13,11 +13,16 @@ use stm32f4::stm32f413::GPIOA;
//const bit_string: u16 = 0x0;
//const bit_string: u16 = 0xFFFF;
const bit_string: u16 = 0x0FFF;
//actual string 0b1_01111101_1111
//actual string 0b1_01111101_1111 (send value 255)
//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;
// actual string 0b1_00000000_1111 (send value 0)
//const bit_s: u32 = 0b10_0101010101010101_10101010; // Start stop high
const WAIT_TICKS: u16 = 240;
//const bit_string: u16 = 0xF000;
/*(
0x0FFF full
......@@ -36,6 +41,7 @@ const APP: () = {
dwt: DWT,
ON: bool,
point: u16,
tick: u16,
}
#[init]
......@@ -63,13 +69,20 @@ const APP: () = {
let gpioa = cx.device.GPIOA;
gpioa.moder.modify(|_, w| unsafe { w.moder5().bits(1) });
gpioa.moder.modify(|_, w| unsafe { w.moder6().bits(1) });
/*
unsafe {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(true));
}
*/
let mut point: u16 = 25;
let mut tick: u16 = 0;
init::LateResources {
dwt: cx.core.DWT,
ON: false,
point: point,
tick: tick,
}
}
......@@ -87,11 +100,10 @@ const APP: () = {
}
}
#[task(binds = SysTick, resources = [ON, point],)]
#[task(binds = SysTick, resources = [ON, point, tick],)]
fn syst(cx: syst::Context) {
let r = cx.resources;
if *r.point != 0 {
if *r.point != 0 && false {
let m = bit_s >> *r.point & 0x1;
unsafe {
if m == 1 {
......@@ -105,6 +117,11 @@ const APP: () = {
unsafe {
(*GPIOA::ptr()).odr.modify(|_, w| w.odr5().bit(false));
}
*r.tick = *r.tick + 1;
if *r.tick >= WAIT_TICKS {
*r.point = 25;
*r.tick = 0;
}
}
/*
let r = cx.resources;
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment