mirror of https://github.com/m-labs/artiq.git
parent
40baa8ecba
commit
f9910ab242
|
@ -48,23 +48,28 @@ class PCA9548:
|
||||||
self.address = address
|
self.address = address
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def set(self, channel):
|
def select(self, mask):
|
||||||
"""Select one channel.
|
"""Enable/disable channels.
|
||||||
|
|
||||||
Selecting multiple channels at the same time is not supported by this
|
:param mask: Bit mask of enabled channels
|
||||||
driver.
|
|
||||||
|
|
||||||
:param channel: channel number (0-7)
|
|
||||||
"""
|
"""
|
||||||
i2c_start(self.busno)
|
i2c_start(self.busno)
|
||||||
try:
|
try:
|
||||||
if not i2c_write(self.busno, self.address):
|
if not i2c_write(self.busno, self.address):
|
||||||
raise I2CError("PCA9548 failed to ack address")
|
raise I2CError("PCA9548 failed to ack address")
|
||||||
if not i2c_write(self.busno, 1 << channel):
|
if not i2c_write(self.busno, mask):
|
||||||
raise I2CError("PCA9548 failed to ack control word")
|
raise I2CError("PCA9548 failed to ack control word")
|
||||||
finally:
|
finally:
|
||||||
i2c_stop(self.busno)
|
i2c_stop(self.busno)
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def set(self, channel):
|
||||||
|
"""Enable one channel.
|
||||||
|
|
||||||
|
:param channel: channel number (0-7)
|
||||||
|
"""
|
||||||
|
self.select(1 << channel)
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def readback(self):
|
def readback(self):
|
||||||
i2c_start(self.busno)
|
i2c_start(self.busno)
|
||||||
|
|
Loading…
Reference in New Issue