Skip to content

Commit

Permalink
Fix usb otg build (#293)
Browse files Browse the repository at this point in the history
* fugit::Rate<u32> can't access the raw member. Use `to_Hz()` instead

* resolve warnings is usb related files

* add `additional-features` to mcu matrix to allow for specific features in ci (only some are usb capable)

* fix device definition for L4+ devices, fix missing PAC support for L475 usb OTG
  • Loading branch information
Crzyrndm authored Feb 27, 2022
1 parent 127e51e commit c3b68e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 77 deletions.
48 changes: 23 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ jobs:
matrix: # All permutations of {rust, mcu}
rust:
- stable
mcu:
- stm32l412
- stm32l422
- stm32l431
- stm32l432
- stm32l433
- stm32l442
- stm32l443
- stm32l451
- stm32l452
- stm32l462
- stm32l471
- stm32l475
- stm32l476
- stm32l486
- stm32l496
- stm32l4a6
#- stm32l4r9
#- stm32l4s9
mcu: # Note leading comma is required if any additional fetures are specified
- { id: stm32l412, additional-features: ",stm32-usbd" }
- { id: stm32l422, additional-features: ",stm32-usbd" }
- { id: stm32l431, additional-features: "" }
- { id: stm32l432, additional-features: ",stm32-usbd" }
- { id: stm32l433, additional-features: ",stm32-usbd" }
- { id: stm32l442, additional-features: ",stm32-usbd" }
- { id: stm32l443, additional-features: ",stm32-usbd" }
- { id: stm32l451, additional-features: "" }
- { id: stm32l452, additional-features: ",stm32-usbd" }
- { id: stm32l462, additional-features: ",stm32-usbd" }
- { id: stm32l471, additional-features: "" }
- { id: stm32l475, additional-features: "" } # USB_OTG not supported by PAC
- { id: stm32l476, additional-features: ",otg_fs" }
- { id: stm32l486, additional-features: ",otg_fs" }
- { id: stm32l496, additional-features: ",otg_fs" }
- { id: stm32l4a6, additional-features: ",otg_fs" }

steps:
- uses: actions/checkout@v2
Expand All @@ -45,12 +43,12 @@ jobs:
with:
use-cross: true
command: build
args: --verbose --release --examples --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu }}
args: --verbose --release --examples --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
- name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu }}
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}

ci-r9:
runs-on: ubuntu-latest
Expand All @@ -59,8 +57,8 @@ jobs:
rust:
- stable
mcu:
- stm32l4r9
- stm32l4s9
- { id: stm32l4r9, additional-features: "" }
- { id: stm32l4s9, additional-features: "" }

steps:
- uses: actions/checkout@v2
Expand All @@ -75,10 +73,10 @@ jobs:
with:
use-cross: true
command: build
args: --verbose --release --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu }}
args: --verbose --release --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
# note that examples were not built
- name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu }}
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
50 changes: 0 additions & 50 deletions examples/otg_fs_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,62 +39,12 @@ fn enable_usb_pwr() {
pwr.cr2.modify(|_, w| w.usv().set_bit());
}

/// Reset peripherals to known state.
unsafe fn reset_peripherals(dp: &Peripherals) {
dp.RCC.cr.modify(|_, w| w.msion().set_bit());
dp.RCC.cfgr.modify(|_, w| {
w.sw().bits(0);
w.hpre().bits(0);
w.ppre1().bits(0);
w.ppre2().bits(0);
w.mcosel().bits(0);
w
});
dp.RCC.cr.modify(|_, w| {
w.pllsai2on().clear_bit();
w.pllsai1on().clear_bit();
w.pllon().clear_bit();
w.hsion().clear_bit();
w.csson().clear_bit();
w.hseon().clear_bit();
w
});
dp.RCC.pllcfgr.modify(|_, w| {
w.pllpdiv().bits(0);
w.pllr().bits(0);
w.pllren().clear_bit();
w.pllq().bits(0);
w.pllqen().clear_bit();
w.pllp().clear_bit();
w.pllpen().clear_bit();
w.plln().bits(1 << 4);
w.pllm().bits(0);
w.pllsrc().bits(0);
w
});

dp.RCC.crrcr.modify(|_, w| w.hsi48on().clear_bit());
dp.RCC.cr.modify(|_, w| w.hsebyp().clear_bit());

dp.RCC.pllcfgr.modify(|_, w| {
w.pllsrc().bits(0);
w.pllpdiv().bits(0);
w
});

dp.RCC.cier.reset();

dp.FLASH.acr.modify(|_, w| w.bits(4));
}

static mut EP_MEMORY: [u32; 1024] = [0; 1024];

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

//reset_peripherals(&dp);

let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);
Expand Down
2 changes: 1 addition & 1 deletion src/otg_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ unsafe impl UsbPeripheral for USB {
}

fn ahb_frequency_hz(&self) -> u32 {
self.hclk.0
self.hclk.to_Hz()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! for usage examples.
use crate::rcc::{Enable, Reset};
use crate::stm32::{RCC, USB};
use crate::stm32::USB;
use stm32_usbd::UsbPeripheral;

use crate::gpio::gpioa::{PA11, PA12};
Expand Down

0 comments on commit c3b68e8

Please sign in to comment.