def LaserscannerResource(*args, laser0, laser1, photodiode, pwm, enable, number=None, conn=None, attrs=None): """ Resource for laser scanner The enable pin is currently activated via the Linux host I/O signals: O: laser0 -- laser channel 0 O: laser1 -- laser channel 1 I: photodiode -- photodiode used to measure position of laser O: pwm -- polygon is rotated with pwm O: en -- on low polygon motor is enabled (depends on type) """ io = [] io.append( Subsignal("laser0", Pins(laser0, dir="o", conn=conn, assert_width=1))) io.append( Subsignal("laser1", Pins(laser1, dir="o", conn=conn, assert_width=1))) io.append( Subsignal("photodiode", Pins(photodiode, dir="i", conn=conn, assert_width=1))) io.append(Subsignal("pwm", Pins(pwm, dir="o", conn=conn, assert_width=1))) io.append( Subsignal("en", PinsN(enable, dir="o", conn=conn, assert_width=1))) if attrs is not None: io.append(attrs) return Resource.family(*args, number, default_name="laserscanner", ios=io)
def Bus(*args, pins, invert=False, conn=None, attrs=None, default_name, dir): """Adds a bus resource. Add to resources using *Bus(...).""" assert isinstance(pins, (str, list, dict)) if isinstance(pins, str): pins = pins.split() if isinstance(pins, list): pins = dict(enumerate(pins)) resources = [] for number, pin in pins.items(): ios = [Pins(pin, dir=dir, invert=invert, conn=conn)] if attrs is not None: ios.append(attrs) resources.append( Resource.family(*args, number, default_name=default_name, ios=ios)) return resources
def StepperResource(*args, step, direction, limit, number=None, conn=None, attrs=None): """ The enable pin is currently activated via the Linux host I/O signals: O: step -- pin for step pulse O: dir -- rotating direction of motor I: limit -- limit switch to detect end movement """ io = [] io.append(Subsignal("step", Pins(step, dir="o", conn=conn, assert_width=1))) io.append( Subsignal("dir", Pins(direction, dir="o", conn=conn, assert_width=1))) io.append( Subsignal("limit", Pins(limit, dir="i", conn=conn, assert_width=1))) if attrs is not None: io.append(attrs) return Resource.family(*args, number, default_name="stepper", ios=io)