Ejemplo n.º 1
0
    def __init__(self,
                 i2c=None,
                 spi=None,
                 ad7608=None,
                 gpio=None,
                 volt_ch1=2,
                 volt_ch2=3,
                 curr_ch1=0,
                 curr_ch2=1,
                 eeprom_dev_addr=None,
                 sensor_dev_addr=None,
                 ipcore=None):

        self.ipcore = ipcore
        if (i2c is not None and spi is not None and ad7608 is not None
                and gpio is not None):
            spi.set_mode('MODE2')
            self.cat9555 = CAT9555(ElektraDef.CAT9555_ADDR, i2c)
            self.eeprom = CAT24C32(eeprom_dev_addr, i2c)
            self.sensor = NCT75(sensor_dev_addr, i2c)
            self.ad5663 = AD5663R(spi, ElektraDef.DAC_MV_REF,
                                  ElektraDef.DAC_MODE_REF)
            self.ad7608 = ad7608
            self.gpio = gpio
        elif (ipcore is not None and i2c is not None):
            self.spi = ipcore.spi
            self.spi.set_mode('MODE2')
            self.ad5663 = AD5663R(ipcore.spi, ElektraDef.DAC_MV_REF,
                                  ElektraDef.DAC_MODE_REF)
            self.gpio = None
            self.cat9555 = CAT9555(ElektraDef.CAT9555_ADDR, i2c)
            self.eeprom = CAT24C32(ElektraDef.EEPROM_DEV_ADDR, i2c)
            self.sensor = NCT75(ElektraDef.SENSOR_DEV_ADDR, i2c)
            self.ad7608 = ad7608 or MIXAD760XSGEmulator(
                "mix_ad760x_sg_emulator")
        elif (i2c is None and spi is None and ad7608 is None and gpio is None):
            self.cat9555 = CAT9555Emulator(ElektraDef.CAT9555_ADDR, None, None)
            self.eeprom = None
            self.sensor = None
            self.ad5663 = AD5663R(spi, ElektraDef.DAC_MV_REF,
                                  ElektraDef.DAC_MODE_REF)
            self.ad7608 = MIXAD760XSGEmulator("mix_ad760x_sg_emulator")
            self.gpio = GPIOEmulator("gpio_emulator")
        else:
            raise ElektraException(
                '__init__ error! Please check the parameters!')
        super(ElektraBase, self).__init__(self.eeprom,
                                          self.sensor,
                                          cal_table=elektra_calibration_info,
                                          range_table=elektra_range_table)
        self.adc_voltage_channel = {'ch1': volt_ch1, 'ch2': volt_ch2}
        self.adc_current_channel = {'ch1': curr_ch1, 'ch2': curr_ch2}
Ejemplo n.º 2
0
    def __init__(self,
                 i2c=None,
                 spi=None,
                 blade=None,
                 gpio=None,
                 volt_ch1=2,
                 volt_ch2=3,
                 curr_ch1=0,
                 curr_ch2=1,
                 eeprom_dev_addr=None,
                 sensor_dev_addr=None,
                 ipcore=None,
                 cat9555_dev_addr=ElektraDef.CAT9555_ADDR,
                 range_table=elektra_range_table):

        self.eeprom = CAT24C32(eeprom_dev_addr, i2c)
        self.sensor = NCT75(sensor_dev_addr, i2c)
        self.cat9555 = CAT9555(cat9555_dev_addr, i2c)

        if (i2c is not None and spi is not None and gpio is not None):
            self.spi = spi
            self.spi.set_mode('MODE2')
            self.ad5663 = AD5663R(spi, ElektraDef.DAC_MV_REF,
                                  ElektraDef.DAC_MODE_REF)
            # if not using wrapper IP, blade is ad7608 IP driver
            self.ad7608 = blade
            self.gpio = gpio
        elif (ipcore is not None and i2c is not None):
            if isinstance(ipcore, basestring):
                daqt1_axi4_bus = AXI4LiteBus(ipcore,
                                             ElektraDef.MIXDAQT1_REG_SIZE)
                self.ipcore = MIXDAQT1SGR(
                    axi4_bus=daqt1_axi4_bus,
                    ad717x_chip='AD7175',
                    ad717x_mvref=ElektraDef.ADC_VREF_VOLTAGE_5000mV,
                    use_spi=True,
                    use_gpio=False)
                self.spi = self.ipcore.spi
                self.ad7175 = self.ipcore.ad717x
            else:
                self.ipcore = ipcore
                self.spi = self.ipcore.spi
                self.ad7175 = self.ipcore.ad717x

            self.spi.set_mode('MODE2')
            self.ad5663 = AD5663R(self.spi, ElektraDef.DAC_MV_REF,
                                  ElektraDef.DAC_MODE_REF)
            self.gpio = None
            if blade:
                self.blade = blade
                self.ad7608 = blade.adc
        else:
            raise ElektraException(
                '__init__ error! Please check the parameters!')

        super(ElektraBase, self).__init__(self.eeprom,
                                          self.sensor,
                                          range_table=range_table)
        self.adc_voltage_channel = {'ch1': volt_ch1, 'ch2': volt_ch2}
        self.adc_current_channel = {'ch1': curr_ch1, 'ch2': curr_ch2}
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    def __init__(self, i2c=None, spi=None, ad7175=None, gpio=None, ipcore=None):
        super(EL004002A, self).__init__(None, None, None, None, ElektraDef.VLOT_CH1, ElektraDef.VLOT_CH2,
                                        ElektraDef.CURR_CH1, ElektraDef.CURR_CH2,
                                        ElektraDef.EEPROM_DEV_ADDR, ElektraDef.SENSOR_DEV_ADDR)
        if ipcore:
            self.ad7175 = ipcore.ad717x
            self.spi = ipcore.spi
            self.ad5663 = AD5663R(ipcore.spi, ElektraDef.DAC_MV_REF, ElektraDef.DAC_MODE_REF)
            self.gpio = None
        else:
            self.spi = spi or MIXQSPISGEmulator("mix_qspi_sg_emulator", ElektraDef.PLSPIBUS_EMULATOR_REG_SIZE)
            self.ad7175 = ad7175 or MIXAd7175SGEmulator("mix_ad7175_sg_emulator", ElektraDef.AD7175_EMULATOR_REG_SIZE)
            self.ad5663 = AD5663R(spi, ElektraDef.DAC_MV_REF, ElektraDef.DAC_MODE_REF)
            self.gpio = gpio or GPIOEmulator("gpio_emulator")

        if i2c:
            self.cat9555 = CAT9555(ElektraDef.CAT9555_ADDR, i2c)
            self.eeprom = CAT24C32(ElektraDef.EEPROM_DEV_ADDR, i2c)
            self.sensor = NCT75(ElektraDef.SENSOR_DEV_ADDR, i2c)
        else:
            self.cat9555 = CAT9555Emulator(ElektraDef.CAT9555_ADDR, None, None)
            self.eeprom = None
            self.sensor = None

        super(ElektraBase, self).__init__(self.eeprom, self.sensor,
                                          cal_table=elektra_calibration_info, range_table=elektra_range_table)

        self.ad7175.config = {
            "ch0": {"P": "AIN0", "N": "AIN4"},
            "ch1": {"P": "AIN1", "N": "AIN4"},
            "ch2": {"P": "AIN2", "N": "AIN4"},
            "ch3": {"P": "AIN3", "N": "AIN4"}
        }

        self.spi.set_mode('MODE2')
Ejemplo n.º 5
0
    def __init__(self, i2c=None, ipcore=None, range_table=magma_range_table):

        self.ipcore = ipcore
        if (ipcore is not None and i2c is not None):
            if isinstance(ipcore, basestring):
                axi4_bus = AXI4LiteBus(ipcore, MagmaDef.WCT001_REG_SIZE)
                self.ipcore = MIXWCT001001SGR(axi4_bus,
                                              use_signalmeter_p=True,
                                              use_signalmeter_n=True,
                                              use_signalsource=True)
            self.signalsource = self.ipcore.signalsource
            self.signalmeter_p = self.ipcore.signalmeter_p
            self.signalmeter_n = self.ipcore.signalmeter_n
            self.cat9555 = CAT9555(MagmaDef.CAT9555_ADDR, i2c)
            self.ads1119 = ADS1119(MagmaDef.ADS1119_ADDR, i2c)
            self.sensor = MAX6642(MagmaDef.MAX6642_ADDR, i2c)
            self.mp8859 = MP8859(MagmaDef.MP8859_ADDR, i2c)
            self.eeprom = CAT24C32(MagmaDef.CAT24C32_ADDR, i2c)
        else:
            raise MagmaException(
                '__init__ error! Please check the parameters!')
        self.signalmeter = {'P': self.signalmeter_p, 'N': self.signalmeter_n}
        super(Magma, self).__init__(eeprom=self.eeprom,
                                    temperature_device=self.sensor,
                                    range_table=range_table)
Ejemplo n.º 6
0
    def __init__(self, i2c=None):
        self._cat9555 = CAT9555(SG2238SP02PCADef.CAT9555_DEV_ADDR, i2c)
        self._ad5667 = AD5667(SG2238SP02PCADef.AD5667_DEV_ADDR, i2c,
                              SG2238SP02PCADef.AD5667_VREF_VOLTSGE)
        eeprom = CAT24C32(SG2238SP02PCADef.EEPROM_DEV_ADDR, i2c)
        nct75 = NCT75(SG2238SP02PCADef.NCT75_DEV_ADDR, i2c)

        super(SG2238SP02PCA, self).__init__(eeprom, nct75)
Ejemplo n.º 7
0
    def __init__(self,
                 i2c,
                 ipcore=None,
                 ad7175=None,
                 eeprom_dev_addr=MimicDef.EEPROM_DEV_ADDR,
                 sensor_dev_addr=MimicDef.SENSOR_DEV_ADDR,
                 cat9555_dev_addr=MimicDef.CAT9555_DEV_ADDR,
                 range_table=mimic_range_table):

        self.eeprom = CAT24C32(eeprom_dev_addr, i2c)
        self.sensor = NCT75(sensor_dev_addr, i2c)
        self.cat9555 = CAT9555(cat9555_dev_addr, i2c)

        if ipcore:
            if isinstance(ipcore, basestring):
                daqt1_axi4_bus = AXI4LiteBus(ipcore,
                                             MimicDef.MIXDAQT1_REG_SIZE)
                self.ip = MIXDAQT1SGR(
                    axi4_bus=daqt1_axi4_bus,
                    ad717x_chip='AD7175',
                    ad717x_mvref=MimicDef.ADC_VREF_VOLTAGE_5000mV,
                    use_spi=True,
                    use_gpio=False)
                self.ad7175 = self.ip.ad717x
            else:
                self.ip = ipcore
                self.ad7175 = self.ip.ad717x
        elif ad7175:
            if isinstance(ad7175, basestring):
                axi4_bus = AXI4LiteBus(ad7175, MimicDef.AD7175_REG_SIZE)
                self.ad7175 = MIXAd7175SG(
                    axi4_bus, mvref=MimicDef.ADC_VREF_VOLTAGE_5000mV)
            else:
                self.ad7175 = ad7175
        else:
            raise MimicException("Invalid parameter, please check")

        self.ad7175.config = {
            'ch0': {
                'P': 'AIN0',
                'N': 'AIN1'
            },
            'ch1': {
                'P': 'AIN2',
                'N': 'AIN3'
            }
        }
        self.measure_path = dict()

        super(MimicBase, self).__init__(self.eeprom,
                                        self.sensor,
                                        range_table=range_table)

        self.function_info = mimic_function_info
        self.module_calibration_info = range_table
Ejemplo n.º 8
0
    def __init__(self, i2c=None, ipcore=None, ad7175=None):
        if i2c:
            self.eeprom = CAT24C32(DMM003004Def.EEPROM_DEV_ADDR, i2c)
            self.sensor = NCT75(DMM003004Def.SENSOR_DEV_ADDR, i2c)
            self.cat9555 = CAT9555(DMM003004Def.CAT9555_DEV_ADDR, i2c)
        else:
            self.eeprom = EepromEmulator('eeprom_emulator')
            self.sensor = NCT75Emulator('nct75_emulator')
            self.cat9555 = CAT9555Emulator(DMM003004Def.CAT9555_DEV_ADDR, None,
                                           None)

        if ipcore:
            if isinstance(ipcore, basestring):
                daqt1_axi4_bus = AXI4LiteBus(ipcore,
                                             DMM003004Def.MIXDAQT1_REG_SIZE)
                self.ip = MIXDAQT1SGR(
                    axi4_bus=daqt1_axi4_bus,
                    ad717x_chip='AD7175',
                    ad717x_mvref=DMM003004Def.ADC_VREF_VOLTAGE_5000mV,
                    use_spi=True,
                    use_gpio=False)
                self.ad7175 = self.ip.ad717x
            else:
                self.ip = ipcore
                self.ad7175 = self.ip.ad717x
        elif ad7175:
            self.ad7175 = ad7175
        else:
            self.ad7175 = MIXAd7175SGEmulator('mix_ad7175_sg_emulator',
                                              DMM003004Def.EMULATOR_REG_SIZE)

        self.ad7175.config = {
            'ch0': {
                'P': 'AIN0',
                'N': 'AIN1'
            },
            'ch1': {
                'P': 'AIN2',
                'N': 'AIN3'
            }
        }
        self.mode = 'cal'
        self.measure_path = dict()

        super(Mimic, self).__init__(self.eeprom,
                                    self.sensor,
                                    cal_table=dmm003004_calibration_info,
                                    range_table=dmm003004_range_table)

        self.function_info = dmm003004_function_info
        self.module_calibration_info = dmm003004_calibration_info
Ejemplo n.º 9
0
def create_wolverine_dbg(ad7175_bus_name, vref, i2c_bus0_name, i2c_bus1_name,
                         i2c_dev_addr1, range_sel_bit, meter_sel_bit,
                         ip_dev_name):

    if ad7175_bus_name == '':
        ad7175 = None
    else:
        axi4_bus = AXI4LiteBus(ad7175_bus_name, 8192)
        ad7175 = MIXAd7175SG(axi4_bus, vref)
    if i2c_bus0_name == '':
        i2c_bus0 = None
    else:
        if utility.is_pl_device(i2c_bus0_name):
            axi4_bus = AXI4LiteBus(i2c_bus0_name, 256)
            i2c_bus0 = MIXI2CSG(axi4_bus)
        else:
            i2c_bus0 = I2C(i2c_bus0_name)

    if i2c_bus1_name == '':
        cat9555 = None
    else:
        if utility.is_pl_device(i2c_bus1_name):
            axi4_bus = AXI4LiteBus(i2c_bus1_name, 256)
            i2c_bus1 = MIXI2CSG(axi4_bus)
        else:
            i2c_bus1 = I2C(i2c_bus1_name)
        cat9555 = CAT9555(i2c_dev_addr1, i2c_bus1)

    if ip_dev_name == '':
        ipcore = None
    else:
        axi4_bus = AXI4LiteBus(ip_dev_name, 0x8000)
        ipcore = MIXDAQT1SGR(axi4_bus,
                             ad717x_chip='AD7175',
                             use_spi=False,
                             use_gpio=True)

    if range_sel_bit == '':
        range_sel_bit = None
    else:
        range_sel_bit = int(range_sel_bit)

    if meter_sel_bit == '':
        meter_sel_bit = None
    else:
        meter_sel_bit = int(meter_sel_bit)

    wolverine_dbg = WolverineDebugger(
        Wolverine(i2c_bus0, ad7175, Pin(cat9555, range_sel_bit),
                  Pin(cat9555, meter_sel_bit), ipcore))
    return wolverine_dbg
Ejemplo n.º 10
0
    def __init__(self, i2c, ipcore=None, analyzer=None, adc_rst_pin=None, adc_ovfl_l_pin=None, i2s_rx_en_pin=None,
                 i2s_ch_select_pin=None, tone_detect_pin=None, upload_ch_select_pin=None, sample_rate=48000):

        assert sample_rate > 0 and sample_rate <= WarlockDef.MAX_SAMPLING_RATE

        if (i2c and analyzer and adc_rst_pin and adc_ovfl_l_pin and i2s_rx_en_pin and
                i2s_ch_select_pin and tone_detect_pin and upload_ch_select_pin):
            self.i2c = i2c

            if isinstance(analyzer, basestring):
                self.analyzer = MIXFftAnalyzerSG(analyzer)
            else:
                self.analyzer = analyzer

            self.adc_rst_pin = adc_rst_pin
            self.adc_ovfl_l_pin = adc_ovfl_l_pin
            self.i2s_rx_en_pin = i2s_rx_en_pin
            self.i2s_ch_select_pin = i2s_ch_select_pin
            self.tone_detect_pin = tone_detect_pin
            self.upload_ch_select_pin = upload_ch_select_pin
        elif (ipcore and i2c):
            self.i2c = i2c
            if isinstance(ipcore, basestring):
                axi4_bus = AXI4LiteBus(ipcore, WarlockDef.MIX_MIK002_REG_SIZE)
                self.ipcore = MIXMIK002SGR(axi4_bus)
            else:
                self.ipcore = ipcore
            self.analyzer = self.ipcore.analyzer
            self.adc_rst_pin = Pin(self.ipcore.gpio, WarlockDef.ADC_RST_PIN)
            self.adc_ovfl_l_pin = Pin(self.ipcore.gpio, WarlockDef.ADC_OVFL_L_PIN)
            self.i2s_rx_en_pin = Pin(self.ipcore.gpio, WarlockDef.I2S_RX_EN_PIN)
            self.i2s_ch_select_pin = Pin(self.ipcore.gpio, WarlockDef.I2S_CH_SELECT_PIN)
            self.tone_detect_pin = Pin(self.ipcore.gpio, WarlockDef.TONE_DETECT_PIN)
            self.upload_ch_select_pin = Pin(self.ipcore.gpio, WarlockDef.UPLOAD_CH_SELECT_PIN)
        else:
            raise WarlockException("Parameter error")

        self.eeprom = CAT24C32(WarlockDef.EEPROM_DEV_ADDR, i2c)
        self.nct75 = NCT75(WarlockDef.SENSOR_DEV_ADDR, i2c)
        self.cat9555 = CAT9555(WarlockDef.CAT9555_DEV_ADDR, i2c)

        super(Warlock, self).__init__(self.eeprom, self.nct75,
                                      cal_table={}, range_table=warlock_range_table)

        self.sampling_rate = sample_rate
        self.scope = ""
        self.mode = ""
Ejemplo n.º 11
0
 def __init__(self, i2c, spi, gpio_switch=None):
     self.i2c = i2c
     if isinstance(spi, basestring):
         axi4_bus = AXI4LiteBus(spi, LuggageDef.MIX_QSPI_REG_SIZE)
         self.spi = MIXQSPISG(axi4_bus)
     else:
         self.spi = spi
     self.gpio_switch = gpio_switch
     self.cat9555 = CAT9555(LuggageDef.CAT9555_ADDR, i2c)
     self.eeprom = CAT24C64(LuggageDef.EEPROM_DEV_ADDR, i2c)
     self.sensor = MAX6642(LuggageDef.SENSOR_DEV_ADDR, i2c)
     self.ads1119 = ADS1119(LuggageDef.ADS1119_DEV_ADDR, self.i2c,
                            LuggageDef.ADS1119_REF_MODE,
                            LuggageDef.ADS1119_MVREF,
                            LuggageDef.ADS1119_SAMPLE_RATE)
     super(Luggage, self).__init__(eeprom=self.eeprom,
                                   range_table=luggage_range_table)
Ejemplo n.º 12
0
    def __init__(self,
                 i2c_io_exp=None,
                 i2c=None,
                 eeprom_dev_addr=PSU001003Def.EEPROM_DEV_ADDR,
                 sensor_dev_addr=PSU001003Def.SENSOR_DEV_ADDR):

        if i2c_io_exp and i2c:
            self.cat9555 = CAT9555(PSU001003Def.CAT9555_ADDR, i2c_io_exp)
            self.eeprom = CAT24C32(eeprom_dev_addr, i2c)
            self.sensor = NCT75(sensor_dev_addr, i2c)
        elif i2c_io_exp is None and i2c_io_exp is None:
            self.cat9555 = CAT9555Emulator(0x20, None, None)
            self.eeprom = EepromEmulator('eeprom_emulator')
            self.sensor = NCT75Emulator('nct75_emulator')
        else:
            raise PSU001003Exception(
                'Not Allowed: either of i2c_io_exp,i2c is None')

        super(PSU001003Base, self).__init__(self.eeprom, self.sensor)
Ejemplo n.º 13
0
def create_dbg(file, uart, i2c_bus_name, plgpio, pull_up_pin_num,
               pull_down_pin_num, tx_en_pin_num, removal_det_pin_num,
               connect_det_pin_num, a0_pin_id, a1_pin_id, a2_pin_id,
               elaod_en_pin_id):
    dbg = DarkBeastDebuger()

    firmware_path = file
    pl_uart_drv_ko_file = uart

    if i2c_bus_name == '':
        i2c_bus = None
    else:
        if utility.is_pl_device(i2c_bus_name):
            axi4_bus = AXI4LiteBus(i2c_bus_name, 256)
            i2c_bus = MIXI2CSG(axi4_bus)
        else:
            i2c_bus = I2C(i2c_bus_name)

    if plgpio == '':
        gpio = None
    else:
        axi4_bus = AXI4LiteBus(plgpio, 256)
        gpio = MIXGPIOSG(axi4_bus)

    pull_up_pin = GPIO(int(pull_up_pin_num))
    pull_down_pin = GPIO(int(pull_down_pin_num))
    tx_en_pin = GPIO(int(tx_en_pin_num))
    removal_det_pin = GPIO(int(removal_det_pin_num))
    connect_det_pin = GPIO(int(connect_det_pin_num))

    cat9555 = CAT9555(0x20, i2c_bus)
    a0_pin = Pin(cat9555, a0_pin_id)
    a1_pin = Pin(cat9555, a1_pin_id)
    a2_pin = Pin(cat9555, a2_pin_id)
    elaod_en_pin = Pin(cat9555, elaod_en_pin_id)
    dbg.darkbeast = DarkBeast(firmware_path, pl_uart_drv_ko_file, i2c_bus,
                              gpio, pull_up_pin, pull_down_pin, tx_en_pin,
                              removal_det_pin, connect_det_pin, a0_pin, a1_pin,
                              a2_pin, elaod_en_pin)
    return dbg
Ejemplo n.º 14
0
    def __init__(self,
                 i2c,
                 spi=None,
                 ad7175=None,
                 ipcore=None,
                 eeprom_dev_addr=OmegaDef.EEPROM_DEV_ADDR,
                 sensor_dev_addr=OmegaDef.SENSOR_DEV_ADDR,
                 cat9555_dev_addr=OmegaDef.CAT9555_DEV_ADDR,
                 cal_info=None,
                 range_table=None):

        if ipcore and ad7175:
            raise OmegaException(
                'Not allowed to use both aggregated IP and AD7175 at the same time'
            )
        elif ipcore and spi:
            raise OmegaException(
                'Not allowed to use both aggregated IP and MIXQSPI at the same time'
            )

        if i2c:
            self.eeprom = CAT24C32(eeprom_dev_addr, i2c)
            self.sensor = NCT75(sensor_dev_addr, i2c)
            self.cat9555 = CAT9555(cat9555_dev_addr, i2c)
        else:
            self.eeprom = EepromEmulator("eeprom_emulator")
            self.sensor = NCT75Emulator("nct75_emulator")
            self.cat9555 = CAT9555Emulator(cat9555_dev_addr, None, None)

        if ipcore is None:
            if isinstance(ad7175, basestring):
                ad717x_axi4_bus = AXI4LiteBus(ad7175,
                                              OmegaDef.PLAD7175_REG_SIZE)
                ad7175 = MIXAd7175SG(ad717x_axi4_bus,
                                     OmegaDef.ADC_VREF_VOLTAGE_5000mV)
            elif ad7175:
                self.ad7175 = ad7175
            else:
                self.ad7175 = MIXAd7175SGEmulator(
                    "mix_ad7175_sg_emulator", OmegaDef.ADC_VREF_VOLTAGE_5000mV)

            self.spi = spi or PLSPIBusEmulator('spi_emulator',
                                               OmegaDef.SPI_REG_SIZE)
            self.ad9832 = AD9832(
                self.spi) if self.spi is not None else AD9832Emulator(
                    "ad9832_emulator")
        else:
            if isinstance(ipcore, basestring):
                daqt1_axi4_bus = AXI4LiteBus(ipcore,
                                             OmegaDef.MIXDAQT1_REG_SIZE)
                ipcore = MIXDAQT1SGR(
                    axi4_bus=daqt1_axi4_bus,
                    ad717x_chip='AD7175',
                    ad717x_mvref=OmegaDef.ADC_VREF_VOLTAGE_5000mV,
                    use_spi=True,
                    use_gpio=False)

            self.ipcore = ipcore
            self.spi = self.ipcore.spi
            self.ad7175 = self.ipcore.ad717x
            self.ad9832 = AD9832(
                self.spi) if self.spi is not None else AD9832Emulator(
                    "ad9832_emulator")

        self.line_select = None
        self.ad7175.config = {
            "ch0": {
                "P": "AIN0",
                "N": "AIN1"
            },
            "ch1": {
                "P": "AIN2",
                "N": "AIN3"
            }
        }

        super(OmegaBase, self).__init__(self.eeprom,
                                        self.sensor,
                                        cal_table=cal_info,
                                        range_table=range_table)

        # RMS Voltage of DDS Output wave during board initialization
        self.dds_value_dict = {
            '20Hz': None,
            '100Hz': None,
            '200Hz': None,
            '1kHz': None,
            '10kHz': None,
            '30kHz': None,
            '100kHz': None,
        }

        self.omega_line_select = omega_line_select
        # calibration info
        self.omega_calibration_info = omega_calibration_info
Ejemplo n.º 15
0
    def __init__(self,
                 ipcore=None,
                 signal_meter_0=None,
                 signal_meter_1=None,
                 spi=None,
                 i2c=None,
                 eeprom_dev_addr=MagikDef.EEPROM_DEV_ADDR,
                 sensor_dev_addr=MagikDef.SENSOR_DEV_ADDR):
        if ipcore:
            if isinstance(ipcore, basestring):
                axi4_bus = AXI4LiteBus(ipcore, MagikDef.MIX_DAQT2_REG_SIZE)
                self.mix_daqt2 = MIXDAQT2SGR(axi4_bus,
                                             use_signal_meter1=True,
                                             use_spi=True,
                                             use_gpio=False)
                self.signal_meter0 = self.mix_daqt2.signal_meter0
                self.signal_meter1 = self.mix_daqt2.signal_meter1
                self.spi = self.mix_daqt2.spi
            else:
                self.ipcore = ipcore
                self.signal_meter0 = ipcore.signal_meter0
                self.signal_meter1 = ipcore.signal_meter1
                self.spi = ipcore.spi
            if signal_meter_0 or signal_meter_1 or spi:
                raise MagikException(
                    'Not allowed to use both Integrated IP and Separated IP at the same time!'
                )
        else:
            if signal_meter_0 and signal_meter_1:
                if isinstance(signal_meter_0, basestring):
                    axi4_bus = AXI4LiteBus(signal_meter_0,
                                           MagikDef.SIGNAL_METER_REG_SIZE)
                    self.signal_meter0 = MIXSignalMeterSG(axi4_bus)
                else:
                    self.signal_meter0 = signal_meter_0
                if isinstance(signal_meter_1, basestring):
                    axi4_bus = AXI4LiteBus(signal_meter_1,
                                           MagikDef.SIGNAL_METER_REG_SIZE)
                    self.signal_meter1 = MIXSignalMeterSG(axi4_bus)
                else:
                    self.signal_meter1 = signal_meter_1
            elif not signal_meter_0 and not signal_meter_1:
                self.signal_meter0 = MIXSignalMeterSGEmulator(
                    'mix_signalmeter_sg_emulator', 256)
                self.signal_meter1 = MIXSignalMeterSGEmulator(
                    'mix_signalmeter_sg_emulator', 256)
            else:
                raise MagikException(
                    'signal_meter_0 and signal_meter_1 IP need to exist or be empty at the same time!'
                )
            self.spi = spi if spi else MIXQSPISGEmulator(
                'mix_qspi_sg_emulator', 256)

        if i2c:
            self.cat9555 = CAT9555(MagikDef.CAT9555_ADDR, i2c)
            self.nct75 = NCT75(sensor_dev_addr, i2c)
            self.eeprom = CAT24C32(eeprom_dev_addr, i2c)
        else:
            self.cat9555 = CAT9555Emulator(MagikDef.CAT9555_ADDR, None, None)
            self.eeprom = EepromEmulator('eeprom_emulator')
            self.nct75 = NCT75Emulator('nct75_emulator')

        self.spi.open()
        self.spi.set_speed(MagikDef.SPI_CLOCK_SPEED)
        self.spi.set_mode(MagikDef.SPI_BUS_MODE)
        ad9628_pdwn = Pin(self.cat9555, 6)
        ad9628_oeb = Pin(self.cat9555, 7)
        ad9628_cs = Pin(self.cat9555, 12)
        self.ad9628 = AD9628(self.spi, ad9628_pdwn, ad9628_oeb, ad9628_cs)
        super(MagikBase, self).__init__(self.eeprom,
                                        self.nct75,
                                        cal_table=magik_calibration_info,
                                        range_table=magik_range_table)
Ejemplo n.º 16
0
    def __init__(self,
                 i2c,
                 ipcore=None,
                 analyzer=None,
                 adc_rst_pin=None,
                 adc_ovfl_l_pin=None,
                 i2s_left_select_pin=None,
                 i2s_right_select_pin=None,
                 i2s_both_select_pin=None,
                 tone_detect_pin=None,
                 upload_enable_pin=None,
                 measure_enable_pin=None,
                 sample_rate=48000):

        assert sample_rate > 0 and sample_rate <= MIK002004Def.MAX_SAMPLING_RATE

        if (i2c and analyzer and adc_rst_pin and adc_ovfl_l_pin
                and i2s_left_select_pin and i2s_right_select_pin
                and i2s_both_select_pin and tone_detect_pin
                and upload_enable_pin and measure_enable_pin):
            self.i2c = i2c

            if isinstance(analyzer, basestring):
                self.analyzer = MIXXtalkMeasureSG(analyzer)
            else:
                self.analyzer = analyzer

            self.adc_rst_pin = adc_rst_pin
            self.adc_ovfl_l_pin = adc_ovfl_l_pin
            self.i2s_left_select_pin = i2s_left_select_pin
            self.i2s_right_select_pin = i2s_right_select_pin
            self.i2s_both_select_pin = i2s_both_select_pin
            self.tone_detect_pin = tone_detect_pin
            self.upload_enable_pin = upload_enable_pin
            self.measure_enable_pin = measure_enable_pin
        elif (ipcore and i2c):
            self.i2c = i2c
            if isinstance(ipcore, basestring):
                axi4_bus = AXI4LiteBus(ipcore,
                                       MIK002004Def.MIX_MIK002_REG_SIZE)
                self.ipcore = MIXMIK002SGR(axi4_bus)
            else:
                self.ipcore = ipcore
            self.analyzer = self.ipcore.analyzer
            self.adc_rst_pin = Pin(self.ipcore.gpio, MIK002004Def.ADC_RST_PIN)
            self.adc_ovfl_l_pin = Pin(self.ipcore.gpio,
                                      MIK002004Def.ADC_OVFL_L_PIN)
            self.i2s_left_select_pin = Pin(self.ipcore.gpio,
                                           MIK002004Def.I2S_LEFT_SELECT_PIN)
            self.i2s_right_select_pin = Pin(self.ipcore.gpio,
                                            MIK002004Def.I2S_RIGHT_SELECT_PIN)
            self.i2s_both_select_pin = Pin(self.ipcore.gpio,
                                           MIK002004Def.I2S_BOTH_SELECT_PIN)
            self.tone_detect_pin = Pin(self.ipcore.gpio,
                                       MIK002004Def.TONE_DETECT_PIN)
            self.upload_enable_pin = Pin(self.ipcore.gpio,
                                         MIK002004Def.UPLOAD_ENABLE_PIN)
            self.measure_enable_pin = Pin(self.ipcore.gpio,
                                          MIK002004Def.MEASURE_ENABLE_PIN)
        else:
            raise MIK002004Exception("Parameter error")

        self.eeprom = CAT24C32(MIK002004Def.EEPROM_DEV_ADDR, i2c)
        self.nct75 = NCT75(MIK002004Def.SENSOR_DEV_ADDR, i2c)
        self.cat9555 = CAT9555(MIK002004Def.CAT9555_DEV_ADDR, i2c)

        super(MIK002004, self).__init__(self.eeprom,
                                        self.nct75,
                                        range_table=warlock_range_table)

        self.sampling_rate = sample_rate
        self.scope = ""
        self.mode = ""
Ejemplo n.º 17
0
    def __init__(self,
                 i2c_bus0=None,
                 led1642_bus=None,
                 pwm_gck_led=None,
                 pwm_output=None,
                 uart_rs485=None,
                 ad5592r_spi=None,
                 ad9833_spi=None,
                 analyzer=None,
                 gpio_state_pin=None,
                 pwm1_en_pin=None,
                 pwm2_en_pin=None,
                 pwm3_en_pin=None,
                 pwm4_en_pin=None,
                 pwm5_en_pin=None,
                 pwm6_en_pin=None,
                 pwm7_en_pin=None,
                 pwm8_en_pin=None,
                 signal_out_en=None,
                 iis_rx_en=None,
                 iis_rx_ovfl=None,
                 iis_rx_rst=None):

        if i2c_bus0:
            self.cat9555_0 = CAT9555(MAGNETO002002Def.CAT9555_ADDR_0, i2c_bus0)
            self.cat9555_1 = CAT9555(MAGNETO002002Def.CAT9555_ADDR_1, i2c_bus0)
            self.cat9555_2 = CAT9555(MAGNETO002002Def.CAT9555_ADDR_2, i2c_bus0)
            self.cat9555_3 = CAT9555(MAGNETO002002Def.CAT9555_ADDR_3, i2c_bus0)
            self.cat9555_4 = CAT9555(MAGNETO002002Def.CAT9555_ADDR_4, i2c_bus0)
            self.cat9555_5 = CAT9555(MAGNETO002002Def.CAT9555_ADDR_5, i2c_bus0)
            self.eeprom = CAT24C32(MAGNETO002002Def.EEPROM_DEV_ADDR, i2c_bus0)

        else:
            self.cat9555_0 = CAT9555Emulator(MAGNETO002002Def.CAT9555_ADDR_0,
                                             None, None)
            self.cat9555_1 = CAT9555Emulator(MAGNETO002002Def.CAT9555_ADDR_1,
                                             None, None)
            self.cat9555_2 = CAT9555Emulator(MAGNETO002002Def.CAT9555_ADDR_2,
                                             None, None)
            self.cat9555_3 = CAT9555Emulator(MAGNETO002002Def.CAT9555_ADDR_3,
                                             None, None)
            self.cat9555_4 = CAT9555Emulator(MAGNETO002002Def.CAT9555_ADDR_4,
                                             None, None)
            self.cat9555_5 = CAT9555Emulator(MAGNETO002002Def.CAT9555_ADDR_5,
                                             None, None)
            self.eeprom = EepromEmulator('eeprom_emulator')

        if ad5592r_spi:
            self.ad5592r = AD5592R(ad5592r_spi, MAGNETO002002Def.MVREF,
                                   'internal', MAGNETO002002Def.ADC_GAIN,
                                   MAGNETO002002Def.DAC_GAIN)
        else:
            self.ad5592r = AD5592REmulator('ad5592r')

        self.dds_dev = AD9833(ad9833_spi) if ad9833_spi else AD9833Emulator()

        self.uart_rs485 = uart_rs485 or UARTBusEmulator(
            'uart_emulator', MAGNETO002002Def.UART_SIZE)
        self.pwm_led = pwm_gck_led if pwm_gck_led else MIXPWMSG(
            'pwm_gck_led', MAGNETO002002Def.PWM_SIZE)
        self.pwm_dev = pwm_output if pwm_output else MIXPWMSG(
            'pwm_output', MAGNETO002002Def.PWM_SIZE)
        if isinstance(analyzer, basestring):
            analyzer = MIXFftAnalyzerSG(analyzer)
        elif analyzer:
            self.analyzer = analyzer
        else:
            self.analyzer = MIXFftAnalyzerSGEmulator(
                'mix_fftanalyzer_sg_emulator')
        self.gpio_map = {
            "PWM1_EN_PIN": pwm1_en_pin or GPIOEmulator("PWM1_EN_PIN"),
            "PWM2_EN_PIN": pwm2_en_pin or GPIOEmulator("PWM2_EN_PIN"),
            "PWM3_EN_PIN": pwm3_en_pin or GPIOEmulator("PWM3_EN_PIN"),
            "PWM4_EN_PIN": pwm4_en_pin or GPIOEmulator("PWM4_EN_PIN"),
            "PWM5_EN_PIN": pwm5_en_pin or GPIOEmulator("PWM5_EN_PIN"),
            "PWM6_EN_PIN": pwm6_en_pin or GPIOEmulator("PWM6_EN_PIN"),
            "PWM7_EN_PIN": pwm7_en_pin or GPIOEmulator("PWM7_EN_PIN"),
            "PWM8_EN_PIN": pwm8_en_pin or GPIOEmulator("PWM8_EN_PIN"),
            "SIGNAL_OUT_EN": signal_out_en or GPIOEmulator("SIGNAL_OUT_EN"),
            "GPIO_STATE_PIN": gpio_state_pin or GPIOEmulator("GPIO_STATE_PIN"),
            "IIS_RX_EN": iis_rx_en or GPIOEmulator("IIS_RX_EN"),
            "IIS_RX_OVFL": iis_rx_ovfl or GPIOEmulator("IIS_RX_OVFL"),
            "IIS_RX_RST": iis_rx_rst or GPIOEmulator("IIS_RX_RST")
        }
        if led1642_bus:
            self.led1642 = LED1642(led1642_bus, self.gpio_map['SIGNAL_OUT_EN'])
        else:
            self.led1642 = LED1642Emulator(None, None)

        super(MAGNETO002002,
              self).__init__(self.eeprom,
                             None,
                             cal_table=magneto002002_calibration_info,
                             range_table=magneto002002_range_table)
Ejemplo n.º 18
0
    def __init__(
        self,
        i2c=None,
        spi=None,
        led1642_bus=None,
        pwm_gck_led=None,
        pwm_output=None,
        uart_rs485=None,
        green_led_en=None,
        signal_out_en=None,
        spk_shdn_en=None,
        ringer_dir_pin=None,
        acc1_relay=None,
        acc2_relay=None,
        relay1_res=None,
        relay2_res=None,
    ):

        if i2c:
            self.cat9555_0 = CAT9555(MAGNETO003002Def.CAT9555_INPUT_DEV_ADDR,
                                     i2c)
            self.cat9555_1 = CAT9555(MAGNETO003002Def.CAT9555_OUTPUT_DEV_ADDR,
                                     i2c)
            self.mcp4725_spk = MCP4725(MAGNETO003002Def.MCP4725_SPK_DEV_ADDR,
                                       i2c, MAGNETO003002Def.MCP4725_MVREF)
            self.mcp4725_eload = MCP4725(MAGNETO003002Def.MCP4725_SPK_DEV_ADDR,
                                         i2c, MAGNETO003002Def.MCP4725_MVREF)
            self.ads1115 = ADS1115(MAGNETO003002Def.ADS1115_DEV_ADDR, i2c)
            self.eeprom = CAT24C32(MAGNETO003002Def.EEPROM_DEV_ADDR, i2c)

        else:
            self.cat9555_0 = CAT9555Emulator(
                MAGNETO003002Def.CAT9555_INPUT_DEV_ADDR, None, None)
            self.cat9555_1 = CAT9555Emulator(
                MAGNETO003002Def.CAT9555_OUTPUT_DEV_ADDR, None, None)
            self.mcp4725_spk = MCP4725Emulator('mcp4725_emulator')
            self.mcp4725_eload = MCP4725Emulator('mcp4725_emulator')
            self.ads1115 = ADS1115Emulator('ads1115_emulator')
            self.eeprom = EepromEmulator('eeprom_emulator')

        self.dds_dev = AD9833(spi) if spi else AD9833Emulator()
        self.pwm_led = pwm_gck_led if pwm_gck_led else MIXPWMSG(
            'pwm_gck_led', MAGNETO003002Def.PWM_SIZE)
        self.pwm_dev = pwm_output if pwm_output else MIXPWMSG(
            'pwm_output', MAGNETO003002Def.PWM_SIZE)
        self.uart_rs485 = uart_rs485 or UARTBusEmulator(
            'uart_emulator', MAGNETO003002Def.UART_SIZE)
        self.gpio_map = {
            "GREEN_LED": green_led_en or GPIOEmulator('GREEN_LED'),
            "SPK_SHDN_EN": spk_shdn_en or GPIOEmulator('SPK_SHDN_EN'),
            "ACC1_RELAY": acc1_relay or GPIOEmulator('ACC1_RELAY'),
            "ACC2_RELAY": acc2_relay or GPIOEmulator('ACC2_RELAY'),
            "RINGER_DIR": ringer_dir_pin or GPIOEmulator('RINGER_DIR'),
            "RELAY1_ERS": relay1_res or GPIOEmulator('RELAY1_ERS'),
            "RELAY2_ERS": relay2_res or GPIOEmulator('RELAY2_ERS'),
            "SIGNAL_OUT_EN": signal_out_en or GPIOEmulator('SIGNAL_OUT_EN')
        }

        if led1642_bus:
            self.led1642 = LED1642(led1642_bus, self.gpio_map['SIGNAL_OUT_EN'])
        else:
            self.led1642 = LED1642Emulator(None, None)

        super(MAGNETO003002,
              self).__init__(self.eeprom,
                             None,
                             cal_table=magneto003002_calibration_info,
                             range_table=magneto003002_range_table)