MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / ccgx_read

Method ccgx_read

framework_lib/src/ccgx/device.rs:227–247  ·  view source on GitHub ↗
(&self, reg: ControlRegisters, len: u16)

Source from the content-addressed store, hash-verified

225 }
226
227 fn ccgx_read(&self, reg: ControlRegisters, len: u16) -> EcResult<Vec<u8>> {
228 let mut data: Vec<u8> = Vec::with_capacity(len.into());
229
230 let addr = reg as u16;
231
232 while data.len() < len.into() {
233 let remaining = len - data.len() as u16;
234 let chunk_len = std::cmp::min(MAX_I2C_CHUNK, remaining.into());
235 let offset = addr + data.len() as u16;
236 let i2c_response = self.i2c_read(offset, chunk_len as u16)?;
237 if let Err(EcError::DeviceError(err)) = i2c_response.is_successful() {
238 return Err(EcError::DeviceError(format!(
239 "I2C read was not successful: {:?}",
240 err
241 )));
242 }
243 data.extend(i2c_response.data);
244 }
245
246 Ok(data)
247 }
248
249 fn ccgx_write(&self, reg: ControlRegisters, data: &[u8]) -> EcResult<()> {
250 let addr = reg as u16;

Callers 5

get_silicon_idMethod · 0.80
get_device_infoMethod · 0.80
get_single_fw_verMethod · 0.80
print_fw_infoMethod · 0.80
get_port_statusMethod · 0.80

Calls 2

i2c_readMethod · 0.80
is_successfulMethod · 0.80

Tested by

no test coverage detected