From 1dfd8694c6dfa31ba154456cd17ef2efe6bd7c7a Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 17 Dec 2019 08:57:16 +0000 Subject: Update dependencies to newest versions This patch updates all dependencies to the newest versions (except static_assertions). It replaces the Git versions of stm32f103xx-usb and usb-device with crates.io versions of stm32-usbd (via stm32f1xx-hal) and usb-device. This bumps the minimum supported Rust version to 1.36.0 (for stm32-usbd). static_assertions is not updated as it would require an even newer Rust version. --- src/main.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index eb01dd6..99f1ec6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,9 +14,11 @@ mod crc; mod device; mod hid; +use cortex_m::asm::delay; use cortex_m_rt::entry; +use embedded_hal::digital::v2::OutputPin; use hal::prelude::*; -use stm32f103xx_usb::UsbBus; +use hal::usb::{Peripheral, UsbBus}; use usb_device::class::UsbClass; use crate::crc::Stm32Crc; @@ -44,10 +46,20 @@ fn main() -> ! { let mut gpioa = p.GPIOA.split(&mut rcc.apb2); - let usb_bus = UsbBus::usb_with_reset(p.USB, &mut rcc.apb1, &clocks, &mut gpioa.crh, gpioa.pa12); + let mut pin_dp = gpioa.pa12.into_push_pull_output(&mut gpioa.crh); + pin_dp.set_low().unwrap(); + delay(clocks.sysclk().0 / 100); + let pin_dp = pin_dp.into_floating_input(&mut gpioa.crh); + let pin_dm = gpioa.pa11; + + let usb = Peripheral { + usb: p.USB, + pin_dm, + pin_dp, + }; + let usb_bus = UsbBus::new(usb); let mut usb_class = HidClass::new(Nitrokey::new(crc), &usb_bus); let mut usb_dev = device::create_usb_device(&usb_bus); - usb_dev.force_reset().expect("USB reset failed"); loop { if usb_dev.poll(&mut [&mut usb_class]) { -- cgit v1.2.3