Skip to content

Commit

Permalink
Merge pull request #43 from rust-embedded-community/feature/endpoint-…
Browse files Browse the repository at this point in the history
…accessors

Feature/endpoint accessors
  • Loading branch information
ryan-summers authored Mar 6, 2024
2 parents ca0b3cc + aafbc33 commit f445381
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
* Added the following `embedded-io` traits to the `SerialPort` object: `Write`, `WriteReady`,
`Read`, and `ReadReady`, and `ErrorType`
* The `CdcAcmClass` now exposes the IN and OUT endpoints for direct access via the `read_ep{_mut}`
and `write_ep{_mut}` functions.

## [0.2.0] - 2023-11-13

Expand Down
21 changes: 18 additions & 3 deletions src/cdc_acm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,24 @@ impl<'a, B: UsbBus> CdcAcmClass<'a, B> {
self.read_ep.read(data)
}

/// Gets the address of the IN endpoint.
pub(crate) fn write_ep_address(&self) -> EndpointAddress {
self.write_ep.address()
/// Gets the IN endpoint.
pub fn write_ep(&self) -> &EndpointIn<'a, B> {
&self.write_ep
}

/// Mutably gets the IN endpoint.
pub fn write_ep_mut(&mut self) -> &mut EndpointIn<'a, B> {
&mut self.write_ep
}

/// Gets the OUT endpoint.
pub fn read_ep(&self) -> &EndpointOut<'a, B> {
&self.read_ep
}

/// Mutably gets the OUT endpoint.
pub fn read_ep_mut(&mut self) -> &mut EndpointOut<'a, B> {
&mut self.read_ep
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/serial_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ where
}

fn endpoint_in_complete(&mut self, addr: EndpointAddress) {
if addr == self.inner.write_ep_address() {
if addr == self.inner.write_ep().address() {
self.flush().ok();
}
}
Expand Down

0 comments on commit f445381

Please sign in to comment.