Example #1
0
def main():
    global bbd

    bbd = None
    #
    # Create an FTDI BigBangDevice instance, based on serial number passed in
    #
    bbd = BitBangDevice(device_index=0)

    #
    # Set direction regiser
    #
    bbd.direction = 0xFF

    #
    # Set initial port value to 0
    #
    bbd.port = 0

    #
    # That worked, setup XMLRPC server
    #
    server = SimpleXMLRPCServer.SimpleXMLRPCServer(
        ('localhost', int(sys.argv[1])), logRequests=False, allow_none=True)
    server.register_introspection_functions()
    server.register_function(set_bit, 'set_bit')
    server.serve_forever()
    return 0
Example #2
0
def _select_ftdi_channel(channel):
    """Select multiplexer channel. Currently uses a FTDI chip via pylibftdi"""
    if channel < 0 or channel > 8:
        raise ArgumentError(
            "FTDI-selected multiplexer only has channels 0-7 valid, make sure you specify channel with -c channel=number",
            channel=channel)
    from pylibftdi import BitBangDevice
    bb = BitBangDevice(auto_detach=False)
    bb.direction = 0b111
    bb.port = channel
Example #3
0
def turtle_right():
    bridge('A', 'R')
    bridge('B', 'L')
    sleep(COMMAND_DELAY)
    bridge('A', 'C')
    bridge('B', 'C')


# Main

# auto_detach = False is needed as a workaround to prevent
# segmentation faults when accessing the FTDI device
# see pylibftdi issue #25

bb = BitBangDevice(FTDI_SN, auto_detach=False)
bb.direction = DIRECTION

zero_all()

#
# optosensor only detects black to white transition
# loop left-front until inp6 off then right a bit
#

while True:

    # Poll inputs
    read = bb.port
    #        print('IN7:', '1' if (read & INP7) == INP7 else '0',
    #              ' IN6:', '1' if (read & INP6) == INP6 else '0', '\r', end='')
    if read & INP6 == INP6:
Example #4
0
from time import sleep

import argparse
parser = argparse.ArgumentParser(description=
    'Program ATMEGA162 through JTAG interface connected to an FT232R')
parser.add_argument('--noverify', action='store_true',
    help='Do not verify after programming')
parser.add_argument('elffile', help='.elf file to program in FLASH')
args = parser.parse_args()

dev = BitBangDevice(bitbang_mode=BITMODE_SYNCBB)
TMS = 1 << 4
TDI = 1 << 2
TDO = 1 << 3
TCK = 1 << 5
dev.direction = TMS | TDI | TCK

from math import ceil
from enum import Enum
def jtag_command(instruction, data):
    """Set the instruction register, shift in bits from data, return the output bits
    data[0] holds the least significant bits"""
    if not isinstance(instruction, AVR_JTAG):
        raise ValueError("instruction must be member of AVR_JTAG")
    irvalue = instruction.value[0]
    nbits = instruction.value[1]
    if isinstance(data, int):
        data = data.to_bytes(ceil(nbits/8), 'little')
    stream = [0]
    IR_LENGTH = 4
    def clock_in(bits):
Example #5
0
avgangs = [-90000.0] * len(devs)
wait = 10
count = 0
done = False
current_rate = None

bbd = None
#
# Create an FTDI BigBangDevice instance, based on serial number passed in
#
bbd = BitBangDevice(device_index=0)

#
# Set direction regiser
#
bbd.direction = 0xFF
bbd.port = 0

#
# For the way we've wired up the linear actuator motor, this should
#   produce an "UP" and "DOWN" motor direction.
#
# Two of the relay channels--the low-order bits just control the +/-
#   that go to the other two channels.  Those channels are wired in
#   a kind of exclusive OR, so that only bits with opposite settings
#   produce any motion at all.
#
DOWN = 0b00001101
UP = 0b00001110

#
Example #6
0
import argparse
parser = argparse.ArgumentParser(
    description=
    'Program ATMEGA162 through JTAG interface connected to an FT232R')
parser.add_argument('--noverify',
                    action='store_true',
                    help='Do not verify after programming')
parser.add_argument('elffile', help='.elf file to program in FLASH')
args = parser.parse_args()

dev = BitBangDevice(bitbang_mode=BITMODE_SYNCBB)
TMS = 1 << 4
TDI = 1 << 2
TDO = 1 << 3
TCK = 1 << 5
dev.direction = TMS | TDI | TCK

from math import ceil
from enum import Enum


def jtag_command(instruction, data):
    """Set the instruction register, shift in bits from data, return the output bits
    data[0] holds the least significant bits"""
    if not isinstance(instruction, AVR_JTAG):
        raise ValueError("instruction must be member of AVR_JTAG")
    irvalue = instruction.value[0]
    nbits = instruction.value[1]
    if isinstance(data, int):
        data = data.to_bytes(ceil(nbits / 8), 'little')
    stream = [0]