Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions example-stm32f303vc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "example-stm32f303vc"
version = "0.1.0"
version = "0.2.0"
authors = ["Vadim Kaushan <[email protected]>"]
edition = "2018"
edition = "2021"

[dependencies]
cortex-m = "0.6"
cortex-m-rt = "0.6"
stm32f3xx-hal = { version = "0.4", features = ["stm32f303xc", "stm32-usbd", "rt"] }
panic-semihosting = "0.5"
cortex-m = "0.7"
cortex-m-rt = "0.7"
stm32f3xx-hal = { version = "0.9", features = ["stm32f303xc", "stm32-usbd", "rt"] }
panic-semihosting = "0.6"
usb-device = "0.2.4"
usbd-serial = "0.1"
20 changes: 12 additions & 8 deletions example-stm32f303vc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ extern crate panic_semihosting;
use cortex_m::asm::delay;
use cortex_m_rt::entry;
use stm32f3xx_hal::usb::{Peripheral, UsbBus};
use stm32f3xx_hal::{hal::digital::v2::OutputPin, prelude::*, stm32};
use stm32f3xx_hal::{hal::digital::v2::OutputPin, pac, prelude::*};
use usb_device::prelude::*;
use usbd_serial::{SerialPort, USB_CLASS_CDC};

#[entry]
fn main() -> ! {
let dp = stm32::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();

let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();

let clocks = rcc
.cfgr
.use_hse(8.mhz())
.sysclk(48.mhz())
.pclk1(24.mhz())
.pclk2(24.mhz())
.use_hse(8.MHz())
.sysclk(48.MHz())
.pclk1(24.MHz())
.pclk2(24.MHz())
.freeze(&mut flash.acr);

assert!(clocks.usbclk_valid());
Expand All @@ -47,8 +47,12 @@ fn main() -> ! {
usb_dp.set_low().ok();
delay(clocks.sysclk().0 / 100);

let usb_dm = gpioa.pa11.into_af14(&mut gpioa.moder, &mut gpioa.afrh);
let usb_dp = usb_dp.into_af14(&mut gpioa.moder, &mut gpioa.afrh);
let usb_dm =
gpioa
.pa11
.into_af_push_pull::<14>(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
let usb_dp =
usb_dp.into_af_push_pull::<14>(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);

let usb = Peripheral {
usb: dp.USB,
Expand Down