Skip to content
Snippets Groups Projects
Commit e8f2db25 authored by Jonas Jacobsson's avatar Jonas Jacobsson
Browse files

fixed merge

parents 05bc742b 3104a687
No related branches found
No related tags found
No related merge requests found
fn test_modify() {
let t: VolatileCell<u32> = VolatileCell {
value: core::cell::UnsafeCell::new(0),
};
t.write(0);
assert!(t.read() == 0);
t.modify(3, 3, 0b10101);
// 10101
// ..0111000
// ---------
// 000101000
assert!(t.read() == 0b101 << 3);
t.modify(4, 3, 0b10001);
// 000101000
// 111
// 001
// 000011000
assert!(t.read() == 0b011 << 3);
//
// add more tests here if you like
}
......@@ -20,6 +20,7 @@ use stm32f4xx_hal::stm32;
use rtic::cyccnt::{Instant, U32Ext as _};
<<<<<<< HEAD
#[rtic::app(device = stm32f4xx_hal::stm32, monotonic = rtic::cyccnt::CYCCNT, peripherals = true)]
const APP: () = {
......@@ -73,6 +74,61 @@ const APP: () = {
}
}
=======
#[rtic::app(device = stm32f4xx_hal::stm32, monotonic = rtic::cyccnt::CYCCNT, peripherals = true)]
const APP: () = {
struct Resources {
// late resources
GPIOA: stm32::GPIOA,
GPIOC: stm32::GPIOC,
//button: <stm32::GPIOC as int>::PC13,
}
#[init(schedule = [toggle])]
fn init(cx: init::Context) -> init::LateResources {
rtt_init_print!();
rprintln!("init");
for i in 0..11 {
rprintln!("RTIC Says Hello, world {}!!", i);
}
let mut core = cx.core;
let device = cx.device;
// Initialize (enable) the monotonic timer (CYCCNT)
core.DCB.enable_trace();
// required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7)
DWT::unlock();
core.DWT.enable_cycle_counter();
// semantically, the monotonic timer is frozen at time "zero" during `init`
// NOTE do *not* call `Instant::now` in this context; it will return a nonsense value
let now = cx.start; // the start time of the system
// Schedule `toggle` to run 8e6 cycles (clock cycles) in the future
cx.schedule.toggle(now + 8_000_000.cycles()).unwrap();
// power on GPIOA, RM0368 6.3.11
device.RCC.ahb1enr.modify(|_, w| w.gpioaen().set_bit());
// configure PA5 as output, RM0368 8.4.1
device.GPIOA.moder.modify(|_, w| w.moder5().bits(1));
// Test button thingy. Think I put PC13 to input
device.GPIOC.moder.modify(|_, w| w.moder13().bits(0));
// device.GPIOC.pupdr.modify(|_, w| w.pupdr13().bits(0));
// pass on late resources
init::LateResources {
GPIOA: device.GPIOA,
GPIOC: device.GPIOC,
//button: device.button,
}
}
>>>>>>> 3104a68743e72194c1e8649cdee76a82240fc05e
#[idle]
fn idle(_cx: idle::Context) -> ! {
......@@ -95,10 +151,19 @@ const APP: () = {
cx.resources.GPIOA.bsrr.write(|w| w.br5().set_bit());
}
<<<<<<< HEAD
=======
//cx.resources.GPIOC.PullDown;
>>>>>>> 3104a68743e72194c1e8649cdee76a82240fc05e
*TOGGLE = !*TOGGLE;
cx.schedule
.toggle(cx.scheduled + 16_000_000.cycles())
.unwrap();
<<<<<<< HEAD
=======
>>>>>>> 3104a68743e72194c1e8649cdee76a82240fc05e
}
extern "C" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment