Merge pull request #2971 from mattico/usb-ep-send
embassy-usb-synopsys-otg: impl Sync for EpState
This commit is contained in:
commit
5bc1e1793d
2 changed files with 13 additions and 4 deletions
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
|
@ -9,12 +9,14 @@
|
||||||
"rust-analyzer.check.noDefaultFeatures": true,
|
"rust-analyzer.check.noDefaultFeatures": true,
|
||||||
"rust-analyzer.cargo.noDefaultFeatures": true,
|
"rust-analyzer.cargo.noDefaultFeatures": true,
|
||||||
"rust-analyzer.showUnlinkedFileNotification": false,
|
"rust-analyzer.showUnlinkedFileNotification": false,
|
||||||
// uncomment the target of your chip.
|
// Uncomment the target of your chip.
|
||||||
//"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
|
//"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
|
||||||
//"rust-analyzer.cargo.target": "thumbv7m-none-eabi",
|
//"rust-analyzer.cargo.target": "thumbv7m-none-eabi",
|
||||||
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
|
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
|
||||||
|
//"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
|
||||||
//"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
|
//"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
|
||||||
"rust-analyzer.cargo.features": [
|
"rust-analyzer.cargo.features": [
|
||||||
|
// Comment out these features when working on the examples. Most example crates do not have any cargo features.
|
||||||
"stm32f446re",
|
"stm32f446re",
|
||||||
"time-driver-any",
|
"time-driver-any",
|
||||||
"unstable-pac",
|
"unstable-pac",
|
||||||
|
@ -22,9 +24,10 @@
|
||||||
"rt",
|
"rt",
|
||||||
],
|
],
|
||||||
"rust-analyzer.linkedProjects": [
|
"rust-analyzer.linkedProjects": [
|
||||||
// Uncomment ONE line for the chip you want to work on.
|
|
||||||
// This makes rust-analyzer work on the example crate and all its dependencies.
|
|
||||||
"embassy-stm32/Cargo.toml",
|
"embassy-stm32/Cargo.toml",
|
||||||
|
// To work on the examples, comment the line above and all of the cargo.features lines,
|
||||||
|
// then uncomment ONE line below to select the chip you want to work on.
|
||||||
|
// This makes rust-analyzer work on the example crate and all its dependencies.
|
||||||
// "examples/nrf52840-rtic/Cargo.toml",
|
// "examples/nrf52840-rtic/Cargo.toml",
|
||||||
// "examples/nrf5340/Cargo.toml",
|
// "examples/nrf5340/Cargo.toml",
|
||||||
// "examples/nrf-rtos-trace/Cargo.toml",
|
// "examples/nrf-rtos-trace/Cargo.toml",
|
||||||
|
|
|
@ -221,6 +221,12 @@ struct EpState {
|
||||||
out_size: AtomicU16,
|
out_size: AtomicU16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SAFETY: The EndpointAllocator ensures that the buffer points to valid memory exclusive for each endpoint and is
|
||||||
|
// large enough to hold the maximum packet size. Access to the buffer is synchronized between the USB interrupt and the
|
||||||
|
// EndpointOut impl using the out_size atomic variable.
|
||||||
|
unsafe impl Send for EpState {}
|
||||||
|
unsafe impl Sync for EpState {}
|
||||||
|
|
||||||
struct ControlPipeSetupState {
|
struct ControlPipeSetupState {
|
||||||
/// Holds received SETUP packets. Available if [Ep0State::setup_ready] is true.
|
/// Holds received SETUP packets. Available if [Ep0State::setup_ready] is true.
|
||||||
setup_data: UnsafeCell<[u8; 8]>,
|
setup_data: UnsafeCell<[u8; 8]>,
|
||||||
|
@ -1034,7 +1040,7 @@ impl<'d> embassy_usb_driver::EndpointOut for Endpoint<'d, Out> {
|
||||||
return Poll::Ready(Err(EndpointError::BufferOverflow));
|
return Poll::Ready(Err(EndpointError::BufferOverflow));
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: exclusive access ensured by `ep_out_size` atomic variable
|
// SAFETY: exclusive access ensured by `out_size` atomic variable
|
||||||
let data = unsafe { core::slice::from_raw_parts(*self.state.out_buffer.get(), len as usize) };
|
let data = unsafe { core::slice::from_raw_parts(*self.state.out_buffer.get(), len as usize) };
|
||||||
buf[..len as usize].copy_from_slice(data);
|
buf[..len as usize].copy_from_slice(data);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue