diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-12-17 08:57:16 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-12-17 10:17:28 +0100 |
commit | 1dfd8694c6dfa31ba154456cd17ef2efe6bd7c7a (patch) | |
tree | 01e05b540040aa21ca620cbc6479d99b1c462853 /src | |
parent | 1ea7b2476d9a5f97ddf43f999306a70d7c5167d3 (diff) | |
download | ntw-1dfd8694c6dfa31ba154456cd17ef2efe6bd7c7a.tar.gz ntw-1dfd8694c6dfa31ba154456cd17ef2efe6bd7c7a.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 15 insertions, 3 deletions
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]) { |