Beispiel #1
0
    def __init__(self, address=0x2F, **kwargs):
        #Initialise the AD5272 device.
        #:param address: The address of the AD5272 default: 0x2F when ADDR=0, 2E when ADD= FLOAT (see schematics)
        #

        I2CDevice.__init__(self, address, **kwargs)
	self.write8(0x1C, 0x02) # enable the update of wiper position by default

        #Read back current wiper settings
        self.write8(0x08, 0x00) # Have to write code 0x0800 to initiate a read of the wiper 
        tmp=self.readU16(0) # read the result into tmp variable
        self.__wiper_pos = ((tmp&0x03) << 8) + ((tmp&0xFF00) >> 8) #mask off lower 8 bits and shift down 8, mask off upper 8 bits and bits 7-2 & shift up 8
	
        #read the contents of the control register
        #0x1 = 50-TP program enable 0 = default, dissable
        #0x2 = RDAC register write protect 0 = default, wiper position frozen, 1 = allow update via i2c
        #0x4 = Resistance performance enable 0 = default = enabled, 1 = dissbale
        #0x8 = 50-TP memory program success bit 0 = default = unsuccessful, 1 = successful
        
        #send the command to read the contents of the control register
        self.write8(0x20, 0x00) #send the command to read the contents of the control register
        
        # when read, byte swap to get register contents
        self.__control_reg = (self.readU16(0)&0xF00 >> 8) 


        #Internal variable settings depending on device / voltage connections
        self.__num_wiper_pos = 1024
        self.__tot_resistance = 100.0
        self.__low_pd = 0.0
        self.__high_pd = 3.3
Beispiel #2
0
    def __init__(self, address, **kwargs):

        I2CDevice.__init__(self, address, **kwargs)
        self.address = address
	#addresses of the 4 DACs
        self.dacs = [0x01, 0x02, 0x04, 0x08]
	#store dac values to minimise i2c traffic	
        self.dac_values = [0x00, 0x00, 0x00, 0x00]
Beispiel #3
0
    def __init__(self, address=0x20, **kwargs):
        """Initialise the AD7998 device.

        :param address: address of the AD7998 device on the I2C bus
        :param kwargs: keyword arguments to be passed to the underlying I2CDevice
        """
        # Initialise the I2CDevice superclass instance
        I2CDevice.__init__(self, address, **kwargs)

        # Set cycle register to fastest conversion mode
        self.write8(3, 1)
Beispiel #4
0
	def __init__(self, address=0x50, **kwargs):
		"""Initialise the TPL0102 device.
		:param address: The address of the TPL0102 default: 0x50
		"""

		I2CDevice.__init__(self, address, **kwargs)

		#Read back current wiper settings
		self.__wiper_pos = [self.readU8(0), self.readU8(1)]
		self.__tot_resistance = 100.0
		self.__low_pd = [0.0,0.0]
		self.__high_pd = [3.3, 3.3]
Beispiel #5
0
    def __init__(self, address=0x20, **kwargs):
        """Initialise the MCP23008 device.

        :param address: address of the MCP23008 deviceon the I2C bus
        :param kwargs: keyword arguments to be passed to the underlying I2CDevice
        """
        # Initialise the I2CDevice superclass instance
        I2CDevice.__init__(self, address, **kwargs)

        # Synchronise local buffered register values with state of device
        self.__iodir = self.readU8(self.IODIR)
        self.__gppu = self.readU8(self.GPPU)
        self.__gpio = self.readU8(self.GPIO)
Beispiel #6
0
    def __init__(self, address=0x2c, **kwargs):
        """Initialises the AD5245 device.
		:param addresss: Address of the AD5245 on the I2C bus
		:param kwargs: Parameters to pass to the I2CDevice
		"""

        I2CDevice.__init__(self, address, **kwargs)

        #Read back current wiper settings
        self.__wiper_pos = self.readU8(0)
        self.__tot_resistance = 100.0
        self.__low_pd = 0.0
        self.__high_pd = 3.3
Beispiel #7
0
    def __init__(self, address=0x70, allowMultiple=True, **kwargs):
        """Initialise the the TCA9548 device.

        :param address: address of TCA9548 on the I2C bus
        :param kwargs: keyword arguments to be passed to underlying I2CDevice
        """
        # Initialise the I2CDevice superclass instance
        I2CDevice.__init__(self, address, **kwargs)

        # Clear attached devices and currently enabled channel
        self._attached_devices = {}
        self._selected_channel = None

        # Disable any already enabled devices by clearing output bus selection
        self.write8(0, 0)
Beispiel #8
0
    def __init__(self, address=0x55, model=SI570_C, **kwargs):
        """Initialise the SI570 and determine the crystal frequency.
		This resets the device to the factory programmed frequency.
		"""

        I2CDevice.__init__(self, address, busnum=1, **kwargs)

        #Registers used are dependant on the device model
        self.__register = 13 if model == self.SI570_C else 7

        #Reset device to 156.25MHz and calculate fXTAL
        self.write8(135, 1 << 7)
        while self.readU8(135) & 1:
            continue

        #Device is reset, read initial register configurations
        data = self.readList(self.__register, 6)
        self.__hs_div, self.__n1, self.__rfreq = self.__calculate_params(data)
        self.__fxtal = (156250000 * self.__hs_div *
                        self.__n1) / self.__rfreq / 1000000