@@ -3,14 +3,14 @@ use crate::ral::{
3
3
} ;
4
4
use crate :: transition:: { EndpointConfig , EndpointDescriptor } ;
5
5
use core:: marker:: PhantomData ;
6
+ use critical_section:: { CriticalSection , Mutex } ;
6
7
use embedded_hal:: blocking:: delay:: DelayMs ;
7
8
use usb_device:: bus:: { PollResult , UsbBusAllocator } ;
8
9
use usb_device:: endpoint:: { EndpointAddress , EndpointType } ;
9
10
use usb_device:: { Result , UsbDirection , UsbError } ;
10
11
11
12
use crate :: endpoint:: { EndpointIn , EndpointOut } ;
12
13
use crate :: endpoint_memory:: { EndpointBufferState , EndpointMemoryAllocator } ;
13
- use crate :: target:: interrupt:: { self , CriticalSection , Mutex } ;
14
14
use crate :: target:: UsbRegisters ;
15
15
use crate :: { PhyType , UsbPeripheral } ;
16
16
@@ -37,7 +37,7 @@ impl<USB: UsbPeripheral> UsbBus<USB> {
37
37
self . peripheral
38
38
}
39
39
40
- fn configure_all ( & self , cs : & CriticalSection ) {
40
+ fn configure_all ( & self , cs : CriticalSection < ' _ > ) {
41
41
let regs = self . regs . borrow ( cs) ;
42
42
43
43
// Rx FIFO
@@ -111,7 +111,7 @@ impl<USB: UsbPeripheral> UsbBus<USB> {
111
111
}
112
112
}
113
113
114
- fn deconfigure_all ( & self , cs : & CriticalSection ) {
114
+ fn deconfigure_all ( & self , cs : CriticalSection < ' _ > ) {
115
115
let regs = self . regs . borrow ( cs) ;
116
116
117
117
// disable interrupts
@@ -131,7 +131,7 @@ impl<USB: UsbPeripheral> UsbBus<USB> {
131
131
}
132
132
133
133
pub fn force_reset ( & self , delay : & mut impl DelayMs < u32 > ) -> Result < ( ) > {
134
- interrupt :: free ( |cs| {
134
+ critical_section :: with ( |cs| {
135
135
let regs = self . regs . borrow ( cs) ;
136
136
write_reg ! ( otg_device, regs. device( ) , DCTL , SDIS : 1 ) ; // Soft disconnect
137
137
delay. delay_ms ( 3 ) ;
@@ -165,7 +165,7 @@ impl<USB: UsbPeripheral> UsbBus<USB> {
165
165
panic ! ( "ulpi_read is only supported with external ULPI PHYs" ) ;
166
166
}
167
167
168
- interrupt :: free ( |cs| {
168
+ critical_section :: with ( |cs| {
169
169
let regs = self . regs . borrow ( cs) ;
170
170
171
171
// Begin ULPI register read transaction
@@ -200,7 +200,7 @@ impl<USB: UsbPeripheral> UsbBus<USB> {
200
200
panic ! ( "ulpi_write is only supported with external ULPI PHYs" ) ;
201
201
}
202
202
203
- interrupt :: free ( |cs| {
203
+ critical_section :: with ( |cs| {
204
204
let regs = self . regs . borrow ( cs) ;
205
205
206
206
// Begin ULPI register write transaction
@@ -367,7 +367,7 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
367
367
// Enable USB_OTG in RCC
368
368
USB :: enable ( ) ;
369
369
370
- interrupt :: free ( |cs| {
370
+ critical_section :: with ( |cs| {
371
371
let regs = self . regs . borrow ( cs) ;
372
372
373
373
let core_id = read_reg ! ( otg_global, regs. global( ) , CID ) ;
@@ -517,7 +517,7 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
517
517
}
518
518
519
519
fn reset ( & self ) {
520
- interrupt :: free ( |cs| {
520
+ critical_section :: with ( |cs| {
521
521
let regs = self . regs . borrow ( cs) ;
522
522
523
523
self . configure_all ( cs) ;
@@ -527,7 +527,7 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
527
527
}
528
528
529
529
fn set_device_address ( & self , addr : u8 ) {
530
- interrupt :: free ( |cs| {
530
+ critical_section :: with ( |cs| {
531
531
let regs = self . regs . borrow ( cs) ;
532
532
533
533
modify_reg ! ( otg_device, regs. device( ) , DCFG , DAD : addr as u32 ) ;
@@ -584,7 +584,7 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
584
584
}
585
585
586
586
fn poll ( & self ) -> PollResult {
587
- interrupt :: free ( |cs| {
587
+ critical_section :: with ( |cs| {
588
588
let regs = self . regs . borrow ( cs) ;
589
589
590
590
let core_id = read_reg ! ( otg_global, regs. global( ) , CID ) ;
@@ -703,7 +703,7 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
703
703
704
704
if status == 0x02 || status == 0x06 {
705
705
if let Some ( ep) = & self . allocator . endpoints_out [ epnum as usize ] {
706
- let mut buffer = ep. buffer . borrow ( cs) . borrow_mut ( ) ;
706
+ let mut buffer = ep. buffer . borrow_ref_mut ( cs) ;
707
707
if buffer. state ( ) == EndpointBufferState :: Empty {
708
708
read_reg ! ( otg_global, regs. global( ) , GRXSTSP ) ; // pop GRXSTSP
709
709
0 commit comments