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

Method get_device_info

framework_lib/src/ccgx/device.rs:285–307  ·  view source on GitHub ↗

Get device info (fw_mode, flash_row_size)

(&self)

Source from the content-addressed store, hash-verified

283
284 /// Get device info (fw_mode, flash_row_size)
285 pub fn get_device_info(&self) -> EcResult<(FwMode, u16)> {
286 let data = self.ccgx_read(ControlRegisters::DeviceMode, 1)?;
287 let byte = data[0];
288
289 // Currently used firmware
290 let fw_mode = match FwMode::try_from(byte & 0b0000_0011) {
291 Ok(mode) => mode,
292 Err(err_byte) => {
293 return Err(EcError::DeviceError(format!(
294 "FW Mode invalid: {}",
295 err_byte
296 )))
297 }
298 };
299
300 let flash_row_size = decode_flash_row_size(byte);
301
302 // All our devices support HPI v2 and we expect to use that to interact with them
303 let hpi_v2 = (byte & (1 << 7)) > 0;
304 debug_assert!(hpi_v2);
305
306 Ok((fw_mode, flash_row_size))
307 }
308 pub fn get_fw_versions(&self) -> EcResult<ControllerFirmwares> {
309 let (active_fw, _row_size) = self.get_device_info()?;
310 Ok(ControllerFirmwares {

Callers 3

get_fw_versionsMethod · 0.80
print_single_pd_detailsFunction · 0.80
selftestFunction · 0.80

Calls 2

decode_flash_row_sizeFunction · 0.85
ccgx_readMethod · 0.80

Tested by

no test coverage detected