Skip to content

Commit 58a5149

Browse files
authored
type-c-service: Pull in latest embedded-usb-pd (#458)
1 parent fa1a17b commit 58a5149

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

embedded-service/src/type_c/controller.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub enum Response<'a> {
219219
/// Controller response
220220
Controller(InternalResponse<'a>),
221221
/// UCSI response passthrough
222-
Lpm(lpm::Response),
222+
Ucsi(ucsi::Response),
223223
/// Port response
224224
Port(PortResponse),
225225
}
@@ -585,7 +585,7 @@ impl ContextToken {
585585
&self,
586586
port_id: GlobalPortId,
587587
command: lpm::CommandData,
588-
) -> Result<lpm::ResponseData, PdError> {
588+
) -> Result<ucsi::Response, PdError> {
589589
let node = self.find_node_by_port(port_id).await?;
590590

591591
match node
@@ -597,7 +597,7 @@ impl ContextToken {
597597
}))
598598
.await
599599
{
600-
Response::Lpm(response) => response,
600+
Response::Ucsi(response) => Ok(response),
601601
r => {
602602
error!("Invalid response: expected LPM, got {:?}", r);
603603
Err(PdError::InvalidResponse)
@@ -610,7 +610,7 @@ impl ContextToken {
610610
&self,
611611
port_id: GlobalPortId,
612612
command: lpm::CommandData,
613-
) -> Result<lpm::ResponseData, PdError> {
613+
) -> Result<ucsi::Response, PdError> {
614614
match with_timeout(
615615
DEFAULT_TIMEOUT,
616616
self.send_port_command_ucsi_no_timeout(port_id, command),
@@ -627,7 +627,7 @@ impl ContextToken {
627627
&self,
628628
port_id: GlobalPortId,
629629
reset_type: lpm::ResetType,
630-
) -> Result<lpm::ResponseData, PdError> {
630+
) -> Result<ucsi::Response, PdError> {
631631
self.send_port_command_ucsi(port_id, lpm::CommandData::ConnectorReset(reset_type))
632632
.await
633633
}

examples/std/src/bin/type_c/basic.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const POWER0: power::policy::DeviceId = power::policy::DeviceId(0);
1515

1616
mod test_controller {
1717
use embedded_services::type_c::controller::{ControllerStatus, PortStatus};
18+
use embedded_usb_pd::ucsi;
1819

1920
use super::*;
2021

@@ -68,11 +69,14 @@ mod test_controller {
6869
}
6970
}
7071

71-
async fn process_ucsi_command(&self, command: lpm::Command) -> Result<lpm::ResponseData, Error> {
72+
async fn process_ucsi_command(&self, command: lpm::Command) -> ucsi::Response {
7273
match command.operation {
7374
lpm::CommandData::ConnectorReset(reset_type) => {
7475
info!("Reset ({:#?}) for port {:#?}", reset_type, command.port);
75-
Ok(lpm::ResponseData::Complete)
76+
ucsi::Response {
77+
cci: ucsi::cci::Cci::new_cmd_complete(),
78+
data: None,
79+
}
7680
}
7781
}
7882
}
@@ -100,7 +104,7 @@ mod test_controller {
100104
controller::Response::Controller(self.process_controller_command(command).await)
101105
}
102106
controller::Command::Lpm(command) => {
103-
controller::Response::Lpm(self.process_ucsi_command(command).await)
107+
controller::Response::Ucsi(self.process_ucsi_command(command).await)
104108
}
105109
controller::Command::Port(command) => {
106110
controller::Response::Port(self.process_port_command(command).await)

type-c-service/src/wrapper/pd.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use embassy_time::{Duration, Timer};
44
use embedded_services::debug;
55
use embedded_services::type_c::controller::{InternalResponseData, Response};
66
use embedded_usb_pd::constants::{T_SRC_TRANS_REQ_EPR_MS, T_SRC_TRANS_REQ_SPR_MS};
7-
use embedded_usb_pd::ucsi::lpm;
7+
use embedded_usb_pd::ucsi;
88

99
use super::*;
1010

@@ -278,7 +278,10 @@ impl<'a, const N: usize, C: Controller, BACK: Backing<'a>, V: FwOfferValidator>
278278
controller::Command::Controller(command) => {
279279
self.process_controller_command(controller, state, command).await
280280
}
281-
controller::Command::Lpm(_) => controller::Response::Lpm(lpm::Response::Err(PdError::UnrecognizedCommand)),
281+
controller::Command::Lpm(_) => controller::Response::Ucsi(ucsi::Response {
282+
cci: ucsi::cci::Cci::new_error(),
283+
data: None,
284+
}),
282285
}
283286
}
284287
}

0 commit comments

Comments
 (0)