Skip to content

Commit c3b68e8

Browse files
authored
Fix usb otg build (#293)
* 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
1 parent 127e51e commit c3b68e8

File tree

4 files changed

+25
-77
lines changed

4 files changed

+25
-77
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@ jobs:
1212
matrix: # All permutations of {rust, mcu}
1313
rust:
1414
- stable
15-
mcu:
16-
- stm32l412
17-
- stm32l422
18-
- stm32l431
19-
- stm32l432
20-
- stm32l433
21-
- stm32l442
22-
- stm32l443
23-
- stm32l451
24-
- stm32l452
25-
- stm32l462
26-
- stm32l471
27-
- stm32l475
28-
- stm32l476
29-
- stm32l486
30-
- stm32l496
31-
- stm32l4a6
32-
#- stm32l4r9
33-
#- stm32l4s9
15+
mcu: # Note leading comma is required if any additional fetures are specified
16+
- { id: stm32l412, additional-features: ",stm32-usbd" }
17+
- { id: stm32l422, additional-features: ",stm32-usbd" }
18+
- { id: stm32l431, additional-features: "" }
19+
- { id: stm32l432, additional-features: ",stm32-usbd" }
20+
- { id: stm32l433, additional-features: ",stm32-usbd" }
21+
- { id: stm32l442, additional-features: ",stm32-usbd" }
22+
- { id: stm32l443, additional-features: ",stm32-usbd" }
23+
- { id: stm32l451, additional-features: "" }
24+
- { id: stm32l452, additional-features: ",stm32-usbd" }
25+
- { id: stm32l462, additional-features: ",stm32-usbd" }
26+
- { id: stm32l471, additional-features: "" }
27+
- { id: stm32l475, additional-features: "" } # USB_OTG not supported by PAC
28+
- { id: stm32l476, additional-features: ",otg_fs" }
29+
- { id: stm32l486, additional-features: ",otg_fs" }
30+
- { id: stm32l496, additional-features: ",otg_fs" }
31+
- { id: stm32l4a6, additional-features: ",otg_fs" }
3432

3533
steps:
3634
- uses: actions/checkout@v2
@@ -45,12 +43,12 @@ jobs:
4543
with:
4644
use-cross: true
4745
command: build
48-
args: --verbose --release --examples --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu }}
46+
args: --verbose --release --examples --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
4947
- name: test
5048
uses: actions-rs/cargo@v1
5149
with:
5250
command: test
53-
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu }}
51+
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
5452

5553
ci-r9:
5654
runs-on: ubuntu-latest
@@ -59,8 +57,8 @@ jobs:
5957
rust:
6058
- stable
6159
mcu:
62-
- stm32l4r9
63-
- stm32l4s9
60+
- { id: stm32l4r9, additional-features: "" }
61+
- { id: stm32l4s9, additional-features: "" }
6462

6563
steps:
6664
- uses: actions/checkout@v2
@@ -75,10 +73,10 @@ jobs:
7573
with:
7674
use-cross: true
7775
command: build
78-
args: --verbose --release --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu }}
76+
args: --verbose --release --target thumbv7em-none-eabihf --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}
7977
# note that examples were not built
8078
- name: test
8179
uses: actions-rs/cargo@v1
8280
with:
8381
command: test
84-
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu }}
82+
args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }}

examples/otg_fs_serial.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,62 +39,12 @@ fn enable_usb_pwr() {
3939
pwr.cr2.modify(|_, w| w.usv().set_bit());
4040
}
4141

42-
/// Reset peripherals to known state.
43-
unsafe fn reset_peripherals(dp: &Peripherals) {
44-
dp.RCC.cr.modify(|_, w| w.msion().set_bit());
45-
dp.RCC.cfgr.modify(|_, w| {
46-
w.sw().bits(0);
47-
w.hpre().bits(0);
48-
w.ppre1().bits(0);
49-
w.ppre2().bits(0);
50-
w.mcosel().bits(0);
51-
w
52-
});
53-
dp.RCC.cr.modify(|_, w| {
54-
w.pllsai2on().clear_bit();
55-
w.pllsai1on().clear_bit();
56-
w.pllon().clear_bit();
57-
w.hsion().clear_bit();
58-
w.csson().clear_bit();
59-
w.hseon().clear_bit();
60-
w
61-
});
62-
dp.RCC.pllcfgr.modify(|_, w| {
63-
w.pllpdiv().bits(0);
64-
w.pllr().bits(0);
65-
w.pllren().clear_bit();
66-
w.pllq().bits(0);
67-
w.pllqen().clear_bit();
68-
w.pllp().clear_bit();
69-
w.pllpen().clear_bit();
70-
w.plln().bits(1 << 4);
71-
w.pllm().bits(0);
72-
w.pllsrc().bits(0);
73-
w
74-
});
75-
76-
dp.RCC.crrcr.modify(|_, w| w.hsi48on().clear_bit());
77-
dp.RCC.cr.modify(|_, w| w.hsebyp().clear_bit());
78-
79-
dp.RCC.pllcfgr.modify(|_, w| {
80-
w.pllsrc().bits(0);
81-
w.pllpdiv().bits(0);
82-
w
83-
});
84-
85-
dp.RCC.cier.reset();
86-
87-
dp.FLASH.acr.modify(|_, w| w.bits(4));
88-
}
89-
9042
static mut EP_MEMORY: [u32; 1024] = [0; 1024];
9143

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

96-
//reset_peripherals(&dp);
97-
9848
let mut flash = dp.FLASH.constrain();
9949
let mut rcc = dp.RCC.constrain();
10050
let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);

src/otg_fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ unsafe impl UsbPeripheral for USB {
4545
}
4646

4747
fn ahb_frequency_hz(&self) -> u32 {
48-
self.hclk.0
48+
self.hclk.to_Hz()
4949
}
5050
}
5151

src/usb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! for usage examples.
77
88
use crate::rcc::{Enable, Reset};
9-
use crate::stm32::{RCC, USB};
9+
use crate::stm32::USB;
1010
use stm32_usbd::UsbPeripheral;
1111

1212
use crate::gpio::gpioa::{PA11, PA12};

0 commit comments

Comments
 (0)