コード例 #1
0
    def __init__(self, ipcore=None,
                 signal_source_0=None,
                 spi_dac_0=None,
                 i2c_0=None,
                 i2c_1=None,
                 i2c_2=None,
                 ):

        self.i2c_0 = i2c_0
        self.i2c_1 = i2c_1
        self.i2c_2 = i2c_2
        self.pcal6524 = list()

        if not ipcore and not signal_source_0 and not spi_dac_0 \
           and not i2c_0 and not i2c_1 and not i2c_2:
            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.tmp108 = TMP108(EssosDef.TMP108_DEV_ADDR, self.i2c_1)
            self.ad5061_0 = AD5061Emulator("ad5061", EssosDef.AD5061_OUTPUT_RANGE[0], EssosDef.AD5061_OUTPUT_RANGE[1])
            for i in range(EssosDef.PCAL6524_CHIP_NUM):
                self.pcal6524.append(PCAL6524Emulator(EssosDef.PCAL6524_DEV_ADDR[i],
                                                      self.i2c_2))
        else:
            if ipcore and not signal_source_0 and not spi_dac_0 \
                    and i2c_0 and i2c_1 and i2c_2:
                if isinstance(ipcore, basestring):
                    axi4_bus = AXI4LiteBus(ipcore, EssosDef.MIX_SODIUM_REG_SIZE)
                    self.ipcore = MIXSodiumSGR(axi4_bus)
                else:
                    self.ipcore = ipcore
                self.signal_source_0 = self.ipcore.signal_source_0
                self.spi_dac_0 = self.ipcore.spi_dac_0

            elif not ipcore and signal_source_0 and spi_dac_0 and i2c_0 and i2c_1 and i2c_2:
                if isinstance(signal_source_0, basestring):
                    axi4_bus = AXI4LiteBus(signal_source_0, EssosDef.SIGNAL_SOURCE_REG_SIZE)
                    self.signal_source_0 = MIXSignalSourceSG(axi4_bus)
                else:
                    self.signal_source_0 = signal_source_0

                if isinstance(spi_dac_0, basestring):
                    axi4_bus = AXI4LiteBus(spi_dac_0, EssosDef.PL_SPI_DAC_REG_SIZE)
                    self.spi_dac_0 = PLSPIDAC(axi4_bus)
                else:
                    self.spi_dac_0 = spi_dac_0
            else:
                raise EssosException('Not allowed to use both aggregated IP and \
                 signal_source_0, spi_dac_0 at the same time')

            self.ad5061_0 = AD506x(EssosDef.AD5061_OUTPUT_RANGE[0],
                                   EssosDef.AD5061_OUTPUT_RANGE[1],
                                   EssosDef.AD5061_SAMPLE_RATE,
                                   EssosDef.AD5061_SCK_SPEED,
                                   self.signal_source_0,
                                   self.spi_dac_0)

            self.eeprom = M24128(EssosDef.M24128_DEV_ADDR, self.i2c_1)
            self.tmp108 = TMP108(EssosDef.TMP108_DEV_ADDR, self.i2c_1)
            for i in range(EssosDef.PCAL6524_CHIP_NUM):
                self.pcal6524.append(PCAL6524(EssosDef.PCAL6524_DEV_ADDR[i], self.i2c_2))

        self.waveforms = {0: self.ad5061_0}

        super(Essos, self).__init__(self.eeprom, self.tmp108)
コード例 #2
0
ファイル: magneto002002.py プロジェクト: lcw86/PythonExercise
    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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: hppsu001002.py プロジェクト: lcw86/PythonExercise
    def __init__(self,
                 i2c,
                 ad7175=None,
                 fault_pin=None,
                 ipcore=None,
                 cal_info=None,
                 range_table=None):

        if ipcore and ad7175:
            raise HPPSU001Exception(
                "Not allowed to use both aggregated IP and AD717X")

        if i2c:
            self.tca9538 = TCA9538(HPPSU001Def.TCA9538_DEV_ADDR, i2c)
            self.ad5667_1 = AD5667(HPPSU001Def.AD5667_DEV_1_ADDR, i2c,
                                   HPPSU001Def.AD5667_MVREF)
            self.ad5667_2 = AD5667(HPPSU001Def.AD5667_DEV_2_ADDR, i2c,
                                   HPPSU001Def.AD5667_MVREF)
            self.eeprom = CAT24C32(HPPSU001Def.EEPROM_DEV_ADDR, i2c)
            self.sensor = NCT75(HPPSU001Def.NCT75_DEV_ADDR, i2c)
        else:
            self.tca9538 = TCA9538Emulator(HPPSU001Def.TCA9538_DEV_ADDR)
            self.ad5667_1 = AD5667Emulator("ad5667_emulator_1")
            self.ad5667_2 = AD5667Emulator("ad5667_emulator_2")
            self.eeprom = EepromEmulator("eeprom_emulator")
            self.sensor = NCT75Emulator("nct75_emulator")

        if fault_pin:
            self.fault_pin = fault_pin
        else:
            self.fault_pin = GPIOEmulator('gpio_emulator')

        if ipcore:
            self.ipcore = ipcore
            self.ad7175 = self.ipcore.ad717x
        elif ad7175:
            self.ad7175 = ad7175
        else:
            raise HPPSU001Exception("Use one of aggregated IP or AD717X")

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

        super(HPPSU001001Base, self).__init__(self.eeprom,
                                              self.sensor,
                                              cal_table=cal_info,
                                              range_table=range_table)
コード例 #5
0
ファイル: magneto003002.py プロジェクト: lcw86/PythonExercise
    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)