diff --git a/CHANGELOG.md b/CHANGELOG.md index bb68ef6304ec9a52a5bf93892bc05e9f383663dd..a5bd6c2e1c91d18cbd6d7345ea8007abac797e80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +<<<<<<< HEAD <<<<<<< HEAD ======= ## 2021-03-18 @@ -7,6 +8,8 @@ - examples/usb-mouse.rs, a very small example using external hid library. >>>>>>> 8d3a36604d8080052d125e924e11622c6bf8b01c +======= +>>>>>>> 5e5504062ee4477abe60461125dac9cfae10ea99 ## 2021-03-07 - examples/rtic_bare7.rs, using embedded HAL. diff --git a/Cargo.toml b/Cargo.toml index 86101195d5395ae3ceb70af7dc81bb0c7d90a9df..029b5e29f0190a0087ac6000f236967954724316 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ usb-device = "0.2.7" panic-halt = "0.2.0" # Uncomment for the itm panic examples. -panic-itm = "0.4.2" +#panic-itm = "0.4.2" # Uncomment for the rtt-timing examples. panic-rtt-target = { version = "0.1.1", features = ["cortex-m"] } @@ -36,6 +36,10 @@ version = "0.13.0" features = ["stm32f411", "rt"] +# [dependencies.stm32f4] +# version = "0.13.0" +# features = ["stm32f411", "rt"] + # [dependencies.stm32f4] # version = "0.13.0" # features = ["stm32f411", "rt"] @@ -64,3 +68,17 @@ codegen-units = 1 # better optimizations debug = true # symbols are nice and they don't increase the size on Flash lto = true # better optimizations +<<<<<<< HEAD +======= + + +# [features] +# nightly = ["cortex-m/inline-asm"] + +# # this lets you use `cargo fix`! +# [[bin]] +# name = "app" +# test = false +# bench = false + +>>>>>>> 5e5504062ee4477abe60461125dac9cfae10ea99 diff --git a/examples/pmw3389.rs b/examples/pmw3389.rs index b6fe0a13029db05ab2050beaebde0fc0eba27617..0d3cc8edf424f1806c21d2a97ea8a51e128ff5ee 100644 --- a/examples/pmw3389.rs +++ b/examples/pmw3389.rs @@ -11,7 +11,11 @@ use stm32f4xx_hal::{ dwt::Dwt, gpio::Speed, gpio::{ +<<<<<<< HEAD gpiob::{PB10, PB12}, +======= + gpiob::{PB10, PB4}, +>>>>>>> 5e5504062ee4477abe60461125dac9cfae10ea99 gpioc::{PC2, PC3}, Alternate, Output, PushPull, }, @@ -36,7 +40,11 @@ type PMW3389T = pmw3389::Pmw3389< PC3<Alternate<stm32f4xx_hal::gpio::AF5>>, ), >, +<<<<<<< HEAD PB12<Output<PushPull>>, +======= + PB4<Output<PushPull>>, +>>>>>>> 5e5504062ee4477abe60461125dac9cfae10ea99 >; #[rtic::app(device = stm32f4xx_hal::stm32, monotonic = rtic::cyccnt::CYCCNT, peripherals = true)] @@ -80,7 +88,11 @@ const APP: () = { let sck = gpiob.pb10.into_alternate_af5(); let miso = gpioc.pc2.into_alternate_af5(); let mosi = gpioc.pc3.into_alternate_af5(); +<<<<<<< HEAD let cs = gpiob.pb12.into_push_pull_output().set_speed(Speed::High); +======= + let cs = gpiob.pb4.into_push_pull_output().set_speed(Speed::High); +>>>>>>> 5e5504062ee4477abe60461125dac9cfae10ea99 let spi = Spi::spi2( device.SPI2, diff --git a/examples/rtic_bare5.rs b/examples/rtic_bare5.rs index b46c0960b6ea1ac223c5229f72c83f5074a1aae1..4079dd70a0c7583cde867c05c5d6de4cc9a1bfd7 100644 --- a/examples/rtic_bare5.rs +++ b/examples/rtic_bare5.rs @@ -181,8 +181,8 @@ const APP: () = { gpioa.MODER.write(r | 0b01 << (5 * 2)); // set output mode // test_modify(); - test_modify(); + test_modify(); loop { // set PA5 high @@ -246,6 +246,12 @@ const APP: () = { // What if we could automatically generate that from Vendors specifications (SVD files)? // Wouldn't that be great? // + +// I got the first assert to work. But I don't understand the second. What are we supposed to do? + + +// ** your answer here ** + // I got the first assert to work. But I don't understand the second. What are we supposed to do? // // Commit your answers (bare5_2) diff --git a/examples/usb-mouse.rs b/examples/usb-mouse.rs deleted file mode 100644 index 8ce314810a04e6974f22238d765dc22fd15493d1..0000000000000000000000000000000000000000 --- a/examples/usb-mouse.rs +++ /dev/null @@ -1,110 +0,0 @@ -// > cargo run usb-mouse -// or -// > cargo run usb-mouse --release - -#![no_main] -#![no_std] - -use stm32f4xx_hal::{ - gpio::{gpioc::PC13, Input, PullUp}, - otg_fs::{UsbBus, UsbBusType, USB}, - prelude::*, -}; -use usb_device::{bus::UsbBusAllocator, prelude::*}; -use usbd_hid::{ - descriptor::{generator_prelude::*, MouseReport}, - hid_class::HIDClass, -}; - -use panic_rtt_target as _; -use rtt_target::{rprintln, rtt_init_print}; - -#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true)] -const APP: () = { - struct Resources { - btn: PC13<Input<PullUp>>, - hid: HIDClass<'static, UsbBusType>, - usb_dev: UsbDevice<'static, UsbBus<USB>>, - } - - #[init] - fn init(ctx: init::Context) -> init::LateResources { - static mut EP_MEMORY: [u32; 1024] = [0; 1024]; - static mut USB_BUS: Option<UsbBusAllocator<UsbBusType>> = None; - - rtt_init_print!(); - rprintln!("init"); - - // Set up the system clock. - let rcc = ctx.device.RCC.constrain(); - let _clocks = rcc.cfgr.sysclk(48.mhz()).require_pll48clk().freeze(); - - let gpioc = ctx.device.GPIOC.split(); - let btn = gpioc.pc13.into_pull_up_input(); - - let gpioa = ctx.device.GPIOA.split(); - let usb = USB { - usb_global: ctx.device.OTG_FS_GLOBAL, - usb_device: ctx.device.OTG_FS_DEVICE, - usb_pwrclk: ctx.device.OTG_FS_PWRCLK, - pin_dm: gpioa.pa11.into_alternate_af10(), - pin_dp: gpioa.pa12.into_alternate_af10(), - }; - USB_BUS.replace(UsbBus::new(usb, EP_MEMORY)); - - let hid = HIDClass::new(USB_BUS.as_ref().unwrap(), MouseReport::desc(), 1); - let usb_dev = UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0xc410, 0x0000)) - .manufacturer("E70011E") - .product("Mouse") - .serial_number("1.0") - .device_class(0) - .build(); - - init::LateResources { btn, hid, usb_dev } - } - - #[task(binds=OTG_FS, resources = [btn, hid, usb_dev])] - fn on_usb(ctx: on_usb::Context) { - static mut COUNTER: u16 = 0; - - // destruct the context - let (btn, usb_dev, hid) = (ctx.resources.btn, ctx.resources.usb_dev, ctx.resources.hid); - - let report = MouseReport { - x: match *COUNTER { - // reached after 100ms - 100 => { - rprintln!("10"); - 10 - } - // reached after 199ms - 199 => { - rprintln!("-10"); - -10 - } - _ => 0, - }, - y: 0, - buttons: btn.is_low().unwrap().into(), // (into takes a bool into an integer) - wheel: 0, - }; - // wraps around after 200ms - *COUNTER = (*COUNTER + 1) % 200; - - // push the report - hid.push_input(&report).ok(); - - // update the usb device state - if usb_dev.poll(&mut [hid]) { - return; - } - } - - #[idle] - fn idle(_cx: idle::Context) -> ! { - rprintln!("idle"); - loop { - continue; - } - } -};