def __init__(self, dev_addr, i2c_bus): assert dev_addr & ~0x07 == 0x20 if i2c_bus is None: self.i2c_bus = I2CBusEmulator("i2c_emulator", 256) else: self.i2c_bus = i2c_bus self.dev_addr = dev_addr
def __init__(self, i2c, spi, gpio_switch=None): if i2c: self.i2c = i2c self.cat9555 = CAT9555(LuggageDef.CAT9555_ADDR, i2c) self.eeprom = CAT24C64(LuggageDef.EEPROM_DEV_ADDR, i2c) self.sensor = MAX6642(LuggageDef.SENSOR_DEV_ADDR, i2c) else: self.i2c = I2CBusEmulator("i2c_emulator", LuggageDef.PLI2CBUS_EMULATOR_REG_SIZE) self.cat9555 = CAT9555Emulator(LuggageDef.CAT9555_ADDR, None, None) self.eeprom = EepromEmulator("eeprom_emulator") self.sensor = MAX6642Emulator("max6642_emulator") if spi: self.spi = spi else: self.spi = MIXQSPISGEmulator( "mix_qspi_sg_emulator", LuggageDef.MIXQSPISG_EMULATOR_REG_SIZE) if gpio_switch: self.gpio_switch = gpio_switch else: self.gpio_switch = GPIOEmulator("gpio_switch_emulator") super(Luggage, self).__init__(self.eeprom, None)
def __init__(self, dev_addr, i2c_bus=None): assert (dev_addr & (~0x01)) == 0x2c if i2c_bus is None: self.i2c_bus = I2CBusEmulator("sn65dsi86_emulator", 256) else: self.i2c_bus = i2c_bus self.dev_addr = dev_addr
def __init__(self, dev_addr, i2c_bus=None): assert (dev_addr & (~0x07)) == 0x50 self.dev_addr = dev_addr if i2c_bus is None: self.i2c_bus = I2CBusEmulator('at24c08_emulator', 256) else: self.i2c_bus = i2c_bus
def __init__(self, dev_addr=0x70, i2c_bus=None): if i2c_bus is None: self.i2c_bus = I2CBusEmulator("adg2128_emulator", 256) else: self.i2c_bus = i2c_bus self.device_addr = dev_addr
def __init__(self, device_address, i2c_bus=None): assert isinstance(device_address, int) assert (device_address & TPS6598xDef.DEVICE_MASK) == TPS6598xDef.DEVICE_ID self._dev_addr = device_address self._i2c_bus = i2c_bus or I2CBusEmulator( 'tps6598x_emulator', TPS6598xDef.EMULATOR_REG_SIZE)
def __init__(self, dev_addr, mode, bus_rate, i2c_bus=None): self.bus_rate = bus_rate self.dev_addr = dev_addr self.mode_init = str(mode) if not i2c_bus: self.i2c_bus = I2CBusEmulator('ad5667_emulator', 256) else: self.i2c_bus = i2c_bus
def __init__(self, dev_addr, i2c_bus=None): # Slave address is 0x48~0x4F, Table 6 of MAX6642 Datasheet assert dev_addr & ~0x07 == 0x48 self.dev_addr = dev_addr if i2c_bus is None: self.i2c_bus = I2CBusEmulator("i2c_emulator", PLI2CDef.REG_SIZE) else: self.i2c_bus = i2c_bus
def __init__(self, dev_addr, i2c_bus=None): self.data_length = 1 self.config_data = [0x25, 0x10] self.dev_addr = dev_addr if i2c_bus is None: self.i2c_bus = I2CBusEmulator('ads1115_emulator', PLI2CDef.REG_SIZE) else: self.i2c_bus = i2c_bus
def __init__(self, dev_addr, i2c_bus=None): # the ad527x i2c address is seven bits, but high five bits is 0b101100 assert (dev_addr & (~0xD3)) == 0x2c self.dev_addr = dev_addr self.resolution = 10 if i2c_bus is None: self.i2c_bus = I2CBusEmulator('ad5272_emulator', 256) else: self.i2c_bus = i2c_bus
def __init__(self, dev_addr, i2c_bus=None): # 7-bit address, excluding read/write bits, lower two bits are variable assert dev_addr == 0x41 self.dev_addr = dev_addr if not i2c_bus: self.i2c_bus = I2CBusEmulator('pca9536_emulator', 256) else: self.i2c_bus = i2c_bus super(PCA9536, self).__init__()
def __init__(self, dev_addr, i2c_bus=None, mvref=3300.0): assert dev_addr & (~0x01) == 0x60 assert mvref >= 2700 and mvref <= 5500 self._dev_addr = dev_addr self._mvref = float(mvref) if i2c_bus is None: self._i2c_bus = I2CBusEmulator('mcp4725_emulator', PLI2CDef.REG_SIZE) else: self._i2c_bus = i2c_bus
def __init__(self, dev_addr, i2c_bus=None, measure_time=120): assert dev_addr in [0x5c, 0x23] assert measure_time >= 53.9 and measure_time <= 441.7 self._dev_addr = dev_addr if i2c_bus is None: self.i2c_bus = I2CBusEmulator('bh1750_emulator', PLI2CDef.REG_SIZE) else: self.i2c_bus = i2c_bus self.measure_time = measure_time self.open()
def __init__(self, dev_addr, i2c_bus=None, mvref=5000): # 7-bit slave address. The two LSBs are variable # assert dev_addr == 0x0F self.dev_addr = dev_addr if not i2c_bus: self.i2c_bus = I2CBusEmulator('ad5667_emulator', 256) else: self.i2c_bus = i2c_bus self.vref = mvref
def __init__(self, dev_addr, i2c_bus=None, mvref=2500): assert (dev_addr & (~0x03)) == 0x0C if i2c_bus is None: self._i2c_bus = I2CBusEmulator('i2c_emulator', PLI2CDef.REG_SIZE) else: self._i2c_bus = i2c_bus self.dev_addr = dev_addr self._mvref = mvref self._dev_name = self._i2c_bus._dev_name self._mode_register = 0 self._gain_register = 0
def __init__(self, dev_addr, i2c_bus=None): assert (dev_addr & (~0x03)) == 0x48 self._dev_addr = dev_addr if i2c_bus is None: self.i2c_bus = I2CBusEmulator('i2c_emulator', 256) else: self.i2c_bus = i2c_bus self.code = ADS1110Def.DATA_RATE['15SPS']['code'] self.gain = ADS1110Def.GAIN_SET['GAIN_1']['gain']
def __init__(self, dev_addr, i2c_bus=None, mvref=2500): assert (dev_addr & (~0x03)) == 0x4C if i2c_bus is None: self.i2c_bus = I2CBusEmulator('ad5693_emulator', PLSPIDef.REG_SIZE) else: self.i2c_bus = i2c_bus self.dev_addr = dev_addr self.control_register = 0 self.set_ref(AD5693Def.REF_INTERNAL) self.mvref = mvref self.dev_name = self.i2c_bus._dev_name
def __init__(self, dev_addr, i2c_bus=None, fs='fs0'): assert (dev_addr & (~0x03)) == 0x48 assert fs in ADS1115Def.FS.keys() self._dev_addr = dev_addr if i2c_bus is None: self.i2c_bus = I2CBusEmulator('ads1115_emulator', 256) else: self.i2c_bus = i2c_bus self.fs = fs self.mvref = ADS1115Def.FS[fs]['mvref'] self.rate = 16
def __init__(self, dev_addr, mvref=3300, i2c_bus=None): assert dev_addr >= 0 assert mvref >= 0 self.resolution = None if i2c_bus is None: self.i2c_bus = I2CBusEmulator( "adcxx1c0xx_emulator", PLSPIDef.REG_SIZE) else: self.i2c_bus = i2c_bus self.dev_addr = dev_addr self.vref = mvref self.dev_name = self.i2c_bus._dev_name
def __init__(self, dev_addr, i2c_bus=None, mvref=2500.0): # 7-bit slave address. The two LSBs are variable assert isinstance(dev_addr, int) and (dev_addr & (~0x03)) == 0x54 assert isinstance(mvref, (float, int)) assert mvref > 0.0 self.dev_addr = dev_addr if not i2c_bus: self.i2c_bus = I2CBusEmulator('ad56x9r_emulator', AD56X9RDef.REG_SIZE) else: self.i2c_bus = i2c_bus self.mvref = float(mvref) self.resolution = AD56X9RDef.AD5669R_RESOLUTION self.ref_mode = "extern"
def __init__(self, dev_addr, i2c_bus=None, mvref=2500.0): # 7-bit slave address. The two LSBs are variable assert (dev_addr & (~0x03)) == 0x0C assert isinstance(mvref, (float, int)) self.dev_addr = dev_addr if not i2c_bus: self.i2c_bus = I2CBusEmulator('ad5667_emulator', 256) else: self.i2c_bus = i2c_bus self.mvref = mvref # rewritten in the subclass,default is 16 self.resolution = AD56X7RDef.AD5667_RESLUTION self.ref_mode = "EXTERN"
def __init__(self, dev_addr, i2c_bus=None, vref=2500): assert isinstance(dev_addr, int) and (dev_addr & (~0x03)) == AD569XDef.SLAVE_ADDR_5MSB assert isinstance(vref, (float, int)) and vref > 0.0 self._dev_addr = dev_addr self.vref = vref self.resolution = AD569XDef.AD5696_RESOLUTION self.gain = AD569XDef.GAIN_1 if i2c_bus is None: self.i2c_bus = I2CBusEmulator('ad569x_emulator', 256) else: self.i2c_bus = i2c_bus
def __init__(self, ipcore=None, spi_adc=None, audio_analyzer=None, signal_meter=None, signal_source_0=None, signal_source_1=None, spi_dac_0=None, spi_dac_1=None, i2c_0=None, i2c_1=None, i2c_2=None, dma=None, rms_dma_channel=1): self.dma_channel = {"rms": rms_dma_channel} self.i2c_1 = i2c_1 self.i2c_2 = i2c_2 self.pcal6524 = list() if not ipcore and not spi_adc and not audio_analyzer and not signal_meter \ and not signal_source_0 and not signal_source_1 and not spi_dac_0 \ and not spi_dac_1 and not i2c_0 and not i2c_1 and not i2c_2 and not dma: self.dma = MIXDMASGEmulator('dma') self.i2c_1 = I2CBusEmulator("i2c_emulator", 256) self.i2c_2 = I2CBusEmulator("i2c_emulator", 256) self.ltc2378 = LTC2378Emulator("ltc2378") self.ad5061_0 = AD5061Emulator("ad5061") self.ad5061_1 = AD5061Emulator("ad5061") self.eeprom = EepromEmulator('m24128_emulator') self.tmp108 = TMP108(SodiumDef.TMP108_DEV_ADDR, self.i2c_1) for i in range(SodiumDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524Emulator(SodiumDef.PCAL6524_DEV_ADDR[i], self.i2c_1)) else: if ipcore and i2c_0 and i2c_1 and i2c_2 and dma and not spi_adc and not audio_analyzer \ and not signal_meter and not signal_source_0 and not signal_source_1 \ and not spi_dac_0 and not spi_dac_1: if isinstance(ipcore, basestring): self.ipcore = MIXSodiumSGR(ipcore) else: self.ipcore = ipcore self.spi_adc = self.ipcore.spi_adc self.signal_meter = self.ipcore.signal_meter self.signal_source_0 = self.ipcore.signal_source_0 self.signal_source_1 = self.ipcore.signal_source_1 self.spi_dac_0 = self.ipcore.spi_dac_0 self.spi_dac_1 = self.ipcore.spi_dac_1 elif not ipcore and i2c_0 and i2c_1 and i2c_2 and dma and spi_adc and audio_analyzer \ and signal_source_0 and signal_source_1 and spi_dac_0 and spi_dac_1: if isinstance(signal_meter, basestring): self.signal_meter = MIXSignalMeterSG(signal_meter) else: self.signal_meter = signal_meter if isinstance(spi_adc, basestring): self.spi_adc = PLSPIADC(spi_adc) else: self.spi_adc = spi_adc if isinstance(audio_analyzer, basestring): self.audio_analyzer = MIXFftAnalyzerSG(audio_analyzer) else: self.audio_analyzer = audio_analyzer if isinstance(signal_source_0, basestring): self.signal_source_0 = MIXSignalSourceSG(signal_source_0) else: self.signal_source_0 = signal_source_0 if isinstance(signal_source_1, basestring): self.signal_source_1 = MIXSignalSourceSG(signal_source_1) else: self.signal_source_1 = signal_source_1 if isinstance(spi_dac_0, basestring): self.spi_dac_0 = PLSPIDAC(spi_dac_0) else: self.spi_dac_0 = spi_dac_0 if isinstance(spi_dac_1, basestring): self.spi_dac_1 = PLSPIDAC(spi_dac_1) else: self.spi_dac_1 = spi_dac_1 else: raise SodiumException( "Not allowed to use both aggregated IP and " "spi_adc,audio_analyzer,signal_meter," "signal_source_0,signal_source_1,spi_dac_0,spi_dac_1 at the same time" ) self.dma = dma self.ad5061_0 = AD506x(SodiumDef.AD5061_OUTPUT_RANGE[0], SodiumDef.AD5061_OUTPUT_RANGE[1], SodiumDef.AD5061_SAMPLE_RATE, SodiumDef.AD5061_SCK_SPEED, self.signal_source_0, self.spi_dac_0) self.ad5061_1 = AD506x(SodiumDef.AD5061_OUTPUT_RANGE[0], SodiumDef.AD5061_OUTPUT_RANGE[1], SodiumDef.AD5061_SAMPLE_RATE, SodiumDef.AD5061_SCK_SPEED, self.signal_source_1, self.spi_dac_1) self.ltc2378 = LTC2378(self.signal_meter, self.spi_adc, None, SodiumDef.LTC2378_VOLT_RANGE) self.eeprom = M24128(SodiumDef.M24128_DEV_ADDR, self.i2c_1) self.pcal6524 = list() for i in range(SodiumDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524(SodiumDef.PCAL6524_DEV_ADDR[i], self.i2c_1)) self.tmp108 = TMP108(SodiumDef.TMP108_DEV_ADDR, self.i2c_2) self.waveforms = {0: self.ad5061_0, 1: self.ad5061_1} super(Sodium, self).__init__(self.eeprom, self.tmp108)
def __init__(self, i2c_0=None, i2c_1=None, i2c_2=None, dma=None, thdn_dma_channel=2, rms_dma_channel=1, ipcore=None, meter=None, spi_adc=None, audio=None, spi_bus=None, source=None, gpio=None, spi_dac=None, ad5761_mvref=2500): self.ipcore = ipcore self.pcal6524 = list() self.adg2128 = list() self.i2c_0 = i2c_0 self.i2c_1 = i2c_1 self.i2c_2 = i2c_2 self.dma_inited = False self.dma_channel = {"rms": rms_dma_channel, "thdn": thdn_dma_channel} if not ipcore and not i2c_0 and not i2c_1 and not i2c_2 and not dma \ and not meter and not spi_adc and not audio and not spi_bus \ and not source and not gpio and not spi_dac: self.i2c_0 = I2CBusEmulator("i2c_emulator", 256) self.i2c_1 = I2CBusEmulator("i2c_emulator", 256) self.i2c_2 = I2CBusEmulator("i2c_emulator", 256) self.eeprom = EepromEmulator('m24128_emulator') self.ltc2378 = LTC2378Emulator("ltc2378") self.ad5761 = AD5761Emulator("ad5761") self.gpio = MIXGPIOSGEmulator("gpio", 256) self.signal_source = MIXSignalSourceSGEmulator( "pl_signal_source_emulator") self.spi_dac = PLSPIDACEmulator("pl_spi_dac_emulator") self.dma = MIXDMASGEmulator('dma') self.eeprom = EepromEmulator('m24128_emulator') for i in range(SolarisDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524Emulator(SolarisDef.PCAL6524_DEV_ADDR[i], self.i2c_0)) for i in range(8): self.adg2128.append( ADG2128Emulator(SolarisDef.ADG2128_DEV_ADDR[i])) for i in range(8): self.adg2128.append( ADG2128Emulator(SolarisDef.ADG2128_DEV_ADDR[i])) self.tmp108 = TMP108(SolarisDef.TMP108_DEV_ADDR, self.i2c_2) self.ad5272 = AD5272Emulator("ad5272") for i in range(2): self.adg2128.append( ADG2128Emulator(SolarisDef.ADG2128_DEV_ADDR[i])) else: if ipcore and i2c_0 and i2c_1 and i2c_2 and dma \ and not meter and not spi_adc and not audio and not spi_bus \ and not source and not gpio and not spi_dac: if isinstance(ipcore, basestring): self.ipcore = MIXSolarisSGR(ipcore) self.ltc2378 = LTC2378(self.ipcore.meter, self.ipcore.spi_adc, self.ipcore.audio, SolarisDef.LTC2378_VOLT_RANGE) self.ad5761 = AD5761(ad5761_mvref, self.ipcore.spi_bus) self.gpio = self.ipcore.gpio self.signal_source = self.ipcore.source self.spi_dac = self.ipcore.spi_dac elif not ipcore and i2c_0 and i2c_1 and i2c_2 and dma and \ meter and spi_adc and audio and spi_bus \ and source and gpio and spi_dac: if isinstance(meter, basestring): meter = MIXSignalMeterSG(meter) if isinstance(spi_adc, basestring): spi_adc = PLSPIADC(spi_adc) if isinstance(audio, basestring): audio = MIXFftAnalyzerSG(audio) if isinstance(source, basestring): source = MIXSignalSourceSG(source) if isinstance(spi_dac, basestring): spi_dac = PLSPIDAC(spi_dac) self.ltc2378 = LTC2378(meter, spi_adc, audio, SolarisDef.LTC2378_VOLT_RANGE) self.ad5761 = AD5761(ad5761_mvref, spi_bus) self.gpio = gpio self.signal_source = source self.spi_dac = spi_dac else: raise SolarisException( 'Not allowed to use both aggregated IP and\ meter,spi_adc,audio,spi_bus,source,gpio,spi_dac at the same time' ) self.dma = dma self.eeprom = M24128(SolarisDef.M24128_DEV_ADDR, self.i2c_0) for i in range(SolarisDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524(SolarisDef.PCAL6524_DEV_ADDR[i], self.i2c_0)) for i in range(8): self.adg2128.append( ADG2128(SolarisDef.ADG2128_DEV_ADDR[i], self.i2c_0)) for i in range(8): self.adg2128.append( ADG2128(SolarisDef.ADG2128_DEV_ADDR[i], self.i2c_1)) self.tmp108 = TMP108(SolarisDef.TMP108_DEV_ADDR, self.i2c_2) self.ad5272 = AD5272(SolarisDef.AD5272_DEV_ADDR, self.i2c_2) for i in range(2): self.adg2128.append( ADG2128(SolarisDef.ADG2128_DEV_ADDR[i], self.i2c_2)) super(Solaris, self).__init__(self.eeprom, self.tmp108)