Skip to content
Permalink
Browse files

Replace stm32l43x-usbd with stm32-usbd

  • Loading branch information...
Disasm committed Jul 29, 2019
1 parent 54b1837 commit b8e70d688f581b92f5fd4ba608bd56fb6ab85c22
Showing with 12 additions and 19 deletions.
  1. +4 −3 Cargo.toml
  2. +8 −16 src/main.rs
@@ -31,6 +31,7 @@ nb = "0.1.2"
panic-halt = "0.2.0"
ufmt = "0.1.0-beta.4"
ufmt-write = "0.1.0-beta.1"
stm32-usbd = { version = "0.3.0", features = ["stm32l4x2xx"] }
usb-device = { version = "0.2.2", features = ["control-buffer-256"] }
usbd-serial = "0.1.0"
cortex-m-rtfm = { version = "0.4.0", features = ["timer-queue"] }
@@ -44,9 +45,6 @@ path = "./stm32l4xx-hal"
default-features = false
features = ["rt", "stm32l4x2", "extra-traits"]

[dependencies.stm32l43x-usbd]
path = "./stm32l43x-usbd"

[dependencies.littlefs]
path = "./rust-littlefs/littlefs"

@@ -55,3 +53,6 @@ codegen-units = 1
debug = true
lto = true
opt-level = "s"

[patch.crates-io]
stm32l4xx-hal = { path = "./stm32l4xx-hal" }
@@ -12,7 +12,7 @@ mod usb;
use rtfm::{app, Instant};
use stm32l4xx_hal::prelude::*;
use stm32l4xx_hal as hal;
use stm32l43x_usbd::UsbBus;
use stm32_usbd::{UsbBus, UsbBusType};
use ufmt::uwrite;
use usb_device::bus;
use usb_device::prelude::*;
@@ -100,16 +100,16 @@ fn experiment_with_lfs(lfs: &mut littlefs::LittleFs<gordon::Gordon>) {

#[app(device = stm32l4xx_hal::stm32)]
const APP: () = {
static mut USB_DEV: UsbDevice<'static, UsbBus> = ();
static mut CCID: usb::ccid::SmartCard<'static, UsbBus> = ();
static mut SERIAL: usb::cdc_acm::SerialPort<'static, UsbBus> = ();
static mut USB_DEV: UsbDevice<'static, UsbBusType> = ();
static mut CCID: usb::ccid::SmartCard<'static, UsbBusType> = ();
static mut SERIAL: usb::cdc_acm::SerialPort<'static, UsbBusType> = ();
// static mut GORDON: gordon::Gordon = ();
static mut LFS: littlefs::LittleFs<gordon::Gordon> = ();

// #[init(schedule = [heartbeat])]
#[init]
fn init() {
static mut USB_BUS: Option<bus::UsbBusAllocator<UsbBus>> = None;
static mut USB_BUS: Option<bus::UsbBusAllocator<UsbBusType>> = None;

let mut rcc = device.RCC.constrain();

@@ -131,33 +131,25 @@ const APP: () = {

let mut gpioa = device.GPIOA.split(&mut rcc.ahb2);

let usb_dm = gpioa.pa11.into_af10(&mut gpioa.moder, &mut gpioa.afrh);
let usb_dp = gpioa.pa12.into_af10(&mut gpioa.moder, &mut gpioa.afrh);

// disable Vddusb power isolation
let pwr = device.PWR.constrain(&mut rcc.apb1r1); // turns it on
pwr.enable_usb();

*USB_BUS = Some(UsbBus::usb_with_reset(
device.USB,
&mut rcc.apb1r1,
&clocks,
&mut gpioa.moder,
&mut gpioa.otyper,
usb_dp,
));
*USB_BUS = Some(UsbBus::new(device.USB, (usb_dm, usb_dp)));

let ccid = usb::ccid::SmartCard::new(USB_BUS.as_ref().unwrap());
let serial = usb::cdc_acm::SerialPort::new(USB_BUS.as_ref().unwrap());

let mut usb_dev =
let usb_dev =
UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0x1209, 0xcc1d))
.manufacturer("Hardcore Bits")
.product(CCID_PRODUCT)
.serial_number("∴ RTFM ∴ AEAD ∴")
.build();

// usb_dev.force_reset().expect("reset failed");

// schedule.heartbeat(Instant::now() + PERIOD.cycles()).unwrap();

USB_DEV = usb_dev;

0 comments on commit b8e70d6

Please sign in to comment.
You can’t perform that action at this time.