def read_register_by_name(self, register_name): ''' VDM001002 board read TPS6598x chip register information by name. Args: register_name: string, name as follow: VID, DID, UID, MODE_REG, VERSION_REG, DEVICE_INFO_REG, CUSTUSE, BOOT_FLAGS, STATUS_REG, DATA_STATUS_REG,CONTROL_CONFIG_REG, SYS_CONFIG_REG, SYS_POWER, PWR_STATUS, PD_STATUS, ACTIVE_CONTRACT_PDO,ACTIVE_CONTRACT_RDO, SINK_REQUEST_RDO, TX_SOURCE_CAP, TX_SINK_CAP,RX_SOURCE_CAP, RX_SINK_CAP, AUTONEGOTIATE_SINK, INT_EVENT1, INT_MASK1, INT_EVENT2, INT_MASK2, GPIO_CONFIG_REG_1, GPIO_CONFIG_REG_2, GPIO_STATUS, TX_IDENTITY_REG, RX_IDENTITY_SOP_REG, RX_IDENTITY_SOPP_REG, RX_VDM_REG, RX_ATTN_REG, ALT_MODE_ENTRY, DATA_CONTROL_REG, DP_CAPABILITIES_REG, INTEL_CONFIG_REG, DP_STATUS_REG, INTEL_STATUS_REG, PWR_SWITCH, CCn_PINSTATE, SLEEP_CONFIG_REG, FW_STATE_HISTORY, FW_STATE_CONFIG, FW_STATE, FW_STATE_FOCUS, MUX_DEBUG_REG, TI_VID_STATUS_REG, USER_VID_CONFIG, USER_VID_STATUS_REG, RX_USER_SVID_ATTN_VDM_REG, RX_USER_SVID_OTHER_VDM_REG Returns: string, str, information of all register. Examples: register_info = vdm.read_register_by_name('VID')\r\n print(register_info)\r\n ''' register = register_definitions.registerByName(register_name) register.read(self.tps6598x) return show(register)
def write_register_by_name(self, chip_id, register_name, field_name, value): ''' USBC001001 write TPS6598x chip register information by name. Args: chip_id: string, ["XA", "XB"]. register_name: str, name range as follow:\r\n INT_MASK1, INT_MASK2, SYS_POWER, SYS_CONFIG_REG, CONTROL_CONFIG_REG, TX_SOURCE_CAP, TX_SINK_CAP, AUTONEGOTIATE_SINK, ALT_MODE_ENTRY, TX_IDENTITY_REG, USER_VID_CONFIG, DATA_CONTROL_REG, DP_CAPABILITIES_REG, INTEL_CONFIG_REG, GPIO_CONFIG_REG_1, GPIO_CONFIG_REG_2, MUX_DEBUG_REG, SLEEP_CONFIG_REG, GPIO_STATUS, FW_STATE_CONFIG. field_name: str, register file name. value: int, field value Returns: None Raise: Usbc001001Exception: if register not support filed name will throw exception and raise what support Examples: usbc001001.write_register_by_name( 'XA', "SYS_CONFIG_REG", "PortInfo", 0) ''' assert chip_id in USBC001001Def.USBC_ID assert isinstance(register_name, basestring) assert isinstance(field_name, basestring) assert isinstance(value, int) register = register_definitions.registerByName(register_name) field_list = [field.name for field in register.fields] if field_name not in field_list: raise Usbc001001Exception('field name \'{}\' not in {}'.format( field_name, field_list)) register.read(self.tps6598x[chip_id]) register.fieldByName(field_name).value = value register.write(self.tps6598x[chip_id])