Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/std/src/bin/type_c/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ mod test_controller {
async fn process_ucsi_command(&self, command: &lpm::GlobalCommand) -> ucsi::GlobalResponse {
match command.operation() {
lpm::CommandData::ConnectorReset => {
info!("Reset for port {:#?}", command.port());
info!("Reset for {:?}", command.port());
ucsi::Response {
cci: ucsi::cci::Cci::new_cmd_complete(),
data: None,
}
}
rest => {
info!("UCSI command {:#?} for port {:#?}", rest, command.port());
info!("UCSI command {:#?} for {:?}", rest, command.port());
ucsi::Response {
cci: ucsi::cci::Cci::new_cmd_complete(),
data: None,
Expand All @@ -94,11 +94,11 @@ mod test_controller {
) -> Result<controller::PortResponseData, Error> {
Ok(match command.data {
controller::PortCommandData::PortStatus(Cached(true)) => {
info!("Port status for port {}", command.port.0);
info!("Port status for {:?}", command.port);
controller::PortResponseData::PortStatus(PortStatus::new())
}
_ => {
info!("Port command for port {}", command.port.0);
info!("Port command for {:?}", command.port);
controller::PortResponseData::Complete
}
})
Expand Down
6 changes: 3 additions & 3 deletions examples/std/src/bin/type_c/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ mod debug {
fn receive(&self, message: &comms::Message) -> Result<(), comms::MailboxDelegateError> {
if let Some(message) = message.data.get::<DebugAccessoryMessage>() {
if message.connected {
info!("Port{}: Debug accessory connected", message.port.0);
info!("{:?}: Debug accessory connected", message.port);
} else {
info!("Port{}: Debug accessory disconnected", message.port.0);
info!("{:?}: Debug accessory disconnected", message.port);
}
}

Expand Down Expand Up @@ -88,7 +88,7 @@ async fn controller_task(state: &'static mock_controller::ControllerState) {

let output = output.unwrap();
if let Output::PdAlert(OutputPdAlert { port, ado }) = &output {
info!("Port{}: PD alert received: {:?}", port.0, ado);
info!("{port:?}: PD alert received: {ado:?}");
}

if let Err(e) = wrapper.finalize(output).await {
Expand Down
26 changes: 13 additions & 13 deletions examples/std/src/lib/type_c/mock_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {
async fn get_pd_alert(&mut self, port: LocalPortId) -> Result<Option<Ado>, Error<Self::BusError>> {
let pd_alert = self.state.pd_alert.lock().await;
if let Some(ado) = *pd_alert {
debug!("Port{}: Get PD alert: {ado:#?}", port.0);
debug!("{port:?}: Get PD alert: {ado:#?}");
Ok(Some(ado))
} else {
debug!("Port{}: No PD alert", port.0);
debug!("{port:?}: No PD alert");
Ok(None)
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {
port: LocalPortId,
voltage_mv: Option<u16>,
) -> Result<(), Error<Self::BusError>> {
debug!("Set max sink voltage for port {}: {:?}", port.0, voltage_mv);
debug!("Set max sink voltage for {port:?}: {voltage_mv:?}");
Ok(())
}

Expand All @@ -239,17 +239,17 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {
}

async fn get_other_vdm(&mut self, port: LocalPortId) -> Result<OtherVdm, Error<Self::BusError>> {
debug!("Get other VDM for port {port:?}");
debug!("Get other VDM for {port:?}");
Ok(OtherVdm::default())
}

async fn get_attn_vdm(&mut self, port: LocalPortId) -> Result<AttnVdm, Error<Self::BusError>> {
debug!("Get attention VDM for port {port:?}");
debug!("Get attention VDM for {port:?}");
Ok(AttnVdm::default())
}

async fn send_vdm(&mut self, port: LocalPortId, tx_vdm: SendVdm) -> Result<(), Error<Self::BusError>> {
debug!("Send VDM for port {port:?}: {tx_vdm:?}");
debug!("Send VDM for {port:?}: {tx_vdm:?}");
Ok(())
}

Expand All @@ -266,7 +266,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {
}

async fn get_dp_status(&mut self, port: LocalPortId) -> Result<DpStatus, Error<Self::BusError>> {
debug!("Get DisplayPort status for port {port:?}");
debug!("Get DisplayPort status for {port:?}");
Ok(DpStatus {
alt_mode_entered: false,
dfp_d_pin_cfg: DpPinConfig::default(),
Expand All @@ -275,19 +275,19 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {

async fn set_dp_config(&mut self, port: LocalPortId, config: DpConfig) -> Result<(), Error<Self::BusError>> {
debug!(
"Set DisplayPort config for port {port:?}: enable={}, pin_cfg={:?}",
"Set DisplayPort config for {port:?}: enable={}, pin_cfg={:?}",
config.enable, config.dfp_d_pin_cfg
);
Ok(())
}

async fn execute_drst(&mut self, port: LocalPortId) -> Result<(), Error<Self::BusError>> {
debug!("Execute PD Data Reset for port {port:?}");
debug!("Execute PD Data Reset for {port:?}");
Ok(())
}

async fn set_tbt_config(&mut self, port: LocalPortId, config: TbtConfig) -> Result<(), Error<Self::BusError>> {
debug!("Set Thunderbolt config for port {port:?}: {config:?}");
debug!("Set Thunderbolt config for {port:?}: {config:?}");
Ok(())
}

Expand All @@ -296,7 +296,7 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {
port: LocalPortId,
config: PdStateMachineConfig,
) -> Result<(), Error<Self::BusError>> {
debug!("Set PD State Machine config for port {port:?}: {config:?}");
debug!("Set PD State Machine config for {port:?}: {config:?}");
Ok(())
}

Expand All @@ -305,15 +305,15 @@ impl embedded_services::type_c::controller::Controller for Controller<'_> {
port: LocalPortId,
state: TypeCStateMachineState,
) -> Result<(), Error<Self::BusError>> {
debug!("Set Type-C State Machine state for port {port:?}: {state:?}");
debug!("Set Type-C State Machine state for {port:?}: {state:?}");
Ok(())
}

async fn execute_ucsi_command(
&mut self,
command: lpm::LocalCommand,
) -> Result<Option<lpm::ResponseData>, Error<Self::BusError>> {
debug!("Execute UCSI command for port {:?}: {command:?}", command.port());
debug!("Execute UCSI command for {:?}: {command:?}", command.port());
match command.operation() {
lpm::CommandData::GetConnectorStatus => Ok(Some(lpm::ResponseData::GetConnectorStatus(
lpm::get_connector_status::ResponseData::default(),
Expand Down
46 changes: 23 additions & 23 deletions type-c-service/src/driver/tps6699x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,21 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
}

let status = self.tps6699x.get_port_status(port).await?;
trace!("Port{} status: {:#?}", port.0, status);
trace!("{:?} status: {:#?}", port, status);

let pd_status = self.tps6699x.get_pd_status(port).await?;
trace!("Port{} PD status: {:#?}", port.0, pd_status);
trace!("{:?} PD status: {:#?}", port, pd_status);

let port_control = self.tps6699x.get_port_control(port).await?;
trace!("Port{} control: {:#?}", port.0, port_control);
trace!("{:?} control: {:#?}", port, port_control);

let mut port_status = PortStatus::default();

let plug_present = status.plug_present();
port_status.connection_state = status.connection_state().try_into().ok();

debug!("Port{} Plug present: {}", port.0, plug_present);
debug!("Port{} Valid connection: {}", port.0, port_status.is_connected());
debug!("{:?} Plug present: {}", port, plug_present);
debug!("{:?} Valid connection: {}", port, port_status.is_connected());

if port_status.is_connected() {
// Determine current contract if any
Expand Down Expand Up @@ -339,7 +339,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {

if num_sprs == 0 {
// USB PD spec requires at least one source PDO be present, something is really wrong
error!("Port{} no source PDOs found", port.0);
error!("{:?} no source PDOs found", port);
return Err(PdError::InvalidParams.into());
}

Expand All @@ -354,19 +354,19 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
} else if pd_status.is_source() {
// Implicit source contract
let current = TypecCurrent::try_from(port_control.typec_current()).map_err(Error::Pd)?;
debug!("Port{} type-C source current: {:#?}", port.0, current);
debug!("{:?} type-C source current: {:#?}", port, current);
let new_contract = Some(PowerCapability::from(current));
port_status.available_source_contract = new_contract;
} else {
// Implicit sink contract
let pull = pd_status.cc_pull_up();
let new_contract = if pull == PdCcPullUp::NoPull {
// No pull up means no contract
debug!("Port{} no pull up", port.0);
debug!("{:?} no pull up", port);
None
} else {
let current = TypecCurrent::try_from(pd_status.cc_pull_up()).map_err(Error::Pd)?;
debug!("Port{} type-C sink current: {:#?}", port.0, current);
debug!("{:?} type-C sink current: {:#?}", port, current);
Some(PowerCapability::from(current))
};
port_status.available_sink_contract = new_contract;
Expand All @@ -390,12 +390,12 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {

// Update alt-mode status
let alt_mode = self.tps6699x.get_alt_mode_status(port).await?;
debug!("Port{} alt mode: {:#?}", port.0, alt_mode);
debug!("{:?} alt mode: {:#?}", port, alt_mode);
port_status.alt_mode = alt_mode;

// Update power path status
let power_path = self.tps6699x.get_power_path_status(port).await?;
trace!("Port{} power source: {:#?}", port.0, power_path);
trace!("{:?} power source: {:#?}", port, power_path);
port_status.power_path = match port {
PORT0 => PowerPathStatus::new(
power_path.pa_ext_vbus_sw() == PpExtVbusSw::EnabledInput,
Expand All @@ -407,7 +407,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
),
_ => Err(PdError::InvalidPort)?,
};
debug!("Port{} power path: {:#?}", port.0, port_status.power_path);
debug!("{:?} power path: {:#?}", port, port_status.power_path);
}

Ok(port_status)
Expand Down Expand Up @@ -449,7 +449,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
match self.tps6699x.execute_muxr(port, input).await? {
ReturnValue::Success => Ok(()),
r => {
debug!("Error executing MuxR on port {}: {:#?}", port.0, r);
debug!("Error executing MuxR on {:?}: {:#?}", port, r);
Err(Error::Pd(PdError::InvalidResponse))
}
}
Expand All @@ -459,19 +459,19 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
match self.tps6699x.execute_dbfg(port).await? {
ReturnValue::Success => Ok(()),
r => {
debug!("Error executing DBfg on port {}: {:#?}", port.0, r);
debug!("Error executing DBfg on {:?}: {:#?}", port, r);
Err(Error::Pd(PdError::InvalidResponse))
}
}
}

async fn enable_sink_path(&mut self, port: LocalPortId, enable: bool) -> Result<(), Error<Self::BusError>> {
debug!("Port{} enable sink path: {}", port.0, enable);
debug!("{:?} enable sink path: {}", port, enable);
match self.tps6699x.enable_sink_path(port, enable).await {
// Temporary workaround for autofet rejection
// Tracking bug: https://github.com/OpenDevicePartnership/embedded-services/issues/268
Err(Error::Pd(PdError::Rejected)) | Err(Error::Pd(PdError::Timeout)) => {
info!("Port{} autofet rejection, ignored", port.0);
info!("{:?} autofet rejection, ignored", port);
Ok(())
}
rest => rest,
Expand Down Expand Up @@ -638,7 +638,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
match self.tps6699x.send_vdms(port, input).await? {
ReturnValue::Success => Ok(()),
r => {
debug!("Error executing VDMs on port {}: {:#?}", port.0, r);
debug!("Error executing VDMs on {:?}: {:#?}", port, r);
Err(Error::Pd(PdError::InvalidResponse))
}
}
Expand Down Expand Up @@ -675,7 +675,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {

async fn get_dp_status(&mut self, port: LocalPortId) -> Result<controller::DpStatus, Error<Self::BusError>> {
let dp_status = self.tps6699x.get_dp_status(port).await?;
debug!("Port{} DP status: {:#?}", port.0, dp_status);
debug!("{:?} DP status: {:#?}", port, dp_status);

let alt_mode_entered = dp_status.dp_mode_active() != 0;

Expand All @@ -694,7 +694,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
port: LocalPortId,
config: controller::DpConfig,
) -> Result<(), Error<Self::BusError>> {
debug!("Port{} setting DP config: {:#?}", port.0, config);
debug!("{:?} setting DP config: {:#?}", port, config);

let mut dp_config_reg = self.tps6699x.get_dp_config(port).await?;

Expand All @@ -712,14 +712,14 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
match self.tps6699x.execute_drst(port).await? {
ReturnValue::Success => Ok(()),
r => {
debug!("Error executing DRST on port {}: {:#?}", port.0, r);
debug!("Error executing DRST on {:?}: {:#?}", port, r);
Err(Error::Pd(PdError::InvalidResponse))
}
}
}

async fn set_tbt_config(&mut self, port: LocalPortId, config: TbtConfig) -> Result<(), Error<Self::BusError>> {
debug!("Port{} setting TBT config: {:#?}", port.0, config);
debug!("{:?} setting TBT config: {:#?}", port, config);

let mut config_reg = self.tps6699x.lock_inner().await.get_tbt_config(port).await?;

Expand All @@ -734,7 +734,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
port: LocalPortId,
config: controller::PdStateMachineConfig,
) -> Result<(), Error<Self::BusError>> {
debug!("Port{} setting PD state machine config: {:#?}", port.0, config);
debug!("{:?} setting PD state machine config: {:#?}", port, config);

let mut config_reg = self.tps6699x.lock_inner().await.get_port_config(port).await?;

Expand All @@ -748,7 +748,7 @@ impl<M: RawMutex, B: I2c> Controller for Tps6699x<'_, M, B> {
port: LocalPortId,
state: controller::TypeCStateMachineState,
) -> Result<(), Error<Self::BusError>> {
debug!("Port{} setting Type-C state machine state: {:#?}", port.0, state);
debug!("{:?} setting Type-C state machine state: {:#?}", port, state);

let mut config_reg = self.tps6699x.lock_inner().await.get_port_config(port).await?;
let typec_state = match state {
Expand Down
14 changes: 7 additions & 7 deletions type-c-service/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ impl<'a> Service<'a> {
) -> Result<(), Error> {
let old_status = self.get_cached_port_status(port_id).await?;

debug!("Port{}: Event: {:#?}", port_id.0, event);
debug!("Port{} Previous status: {:#?}", port_id.0, old_status);
debug!("Port{} Status: {:#?}", port_id.0, status);
debug!("{:?}: Event: {:#?}", port_id, event);
debug!("{:?} Previous status: {:#?}", port_id, old_status);
debug!("{:?} Status: {:#?}", port_id, status);

let connection_changed = status.is_connected() != old_status.is_connected();
if connection_changed && (status.is_debug_accessory() || old_status.is_debug_accessory()) {
Expand All @@ -150,9 +150,9 @@ impl<'a> Service<'a> {
};

if status.is_connected() {
debug!("Port{}: Debug accessory connected", port_id.0);
debug!("{:?}: Debug accessory connected", port_id);
} else {
debug!("Port{}: Debug accessory disconnected", port_id.0);
debug!("{:?}: Debug accessory disconnected", port_id);
}

if self.tp.send(EndpointID::Internal(Internal::Usbc), &msg).await.is_err() {
Expand Down Expand Up @@ -219,12 +219,12 @@ impl<'a> Service<'a> {
pub async fn process_event(&self, event: Event<'_>) -> Result<(), Error> {
match event {
Event::PortStatusChanged(port, event_kind, status) => {
trace!("Port{}: Processing port status changed", port.0);
trace!("{:?}: Processing port status changed", port);
self.process_port_event(port, event_kind, status).await
}
Event::PortNotification(port, notification) => {
// Other port notifications
info!("Port{}: Got port notification: {:?}", port.0, notification);
info!("{:?}: Got port notification: {:?}", port, notification);
Ok(())
}
Event::ExternalCommand(request) => {
Expand Down
4 changes: 2 additions & 2 deletions type-c-service/src/service/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl<'a> Service<'a> {
// If it switches to sourcing then the system will no longer be unconstrained
// So set that port to constrained and unconstrain all others
info!(
"Setting port{} to constrained, all others unconstrained",
unconstrained_index
"Setting {:?} to constrained, all others unconstrained",
GlobalPortId(unconstrained_index as u8)
);
for port_index in 0..num_ports {
self.context
Expand Down
Loading