コード例 #1
0
ファイル: run_test.py プロジェクト: larsks/avr-mbot-backoff
def run_test(f_cpu, mcu, timeout, gdb, testfile):
    avr = Avr(mcu=mcu, f_cpu=f_cpu)
    fw = Firmware(testfile)
    avr.load_firmware(fw)

    if gdb:
        avr.gdb_port = 1234
        avr_gdb_init(avr.backend)
        avr.state = cpu_Stopped

    t_start = time.time()
    while not avr.peek(GPIOR0) & TEST_COMPLETE:
        if timeout and time.time() - t_start > timeout:
            raise click.ClickException('Timeout')
        avr.step(100)

    if avr.uart.buffer:
        print(''.join(avr.uart.buffer))

    sys.exit(0 if avr.peek(GPIOR0) & TEST_SUCCESS else 1)
コード例 #2
0
    # Load firmware from ./avr/Button/Debug/Button.elf
    modulePath = path.dirname(path.realpath(__file__))
    fw = Firmware(path.join(modulePath, "avr", "Button", "Debug",
                            "Button.elf"))
    # fw = Firmware(path.join(modulePath, "avr", "Button", "Release", "Button.elf")
    print("Loading {}".format(fw.filename))

    avr = Avr(firmware=fw)  # The Button.elf has mcu and freq info embedded
    # avr = Avr(firmware=fw, mcu='atmega2560', f_cpu=8000000)
    # avr = Avr(firmware=fw, mcu='attiny2313', f_cpu=8000000)

    print("Fw loaded")

    # Set the GDB port and start simavr GDB
    avr.gdb_port = 1234
    avr_gdb_init(avr.backend)
    # avr.state = cpu_Stopped #To let simavr wait on the first instruction for GDB to connect.

    # Get the AVR A3 input pin.
    A3IRQ = avr.getirq(('A', 3))

    # Create simavr inbuilt button part.
    b = Button(avr)

    # Get the button's output port and attach it to the AVR input.
    pysimavr.connect.avr_connect_irq(b.getirq(0), A3IRQ)

    prevState = -1
    i = 0
コード例 #3
0
ファイル: button.py プロジェクト: ponty/pysimavr
    logging.basicConfig(level=logging.INFO)
        
    # Load firmware from ./avr/Button/Debug/Button.elf
    modulePath = path.dirname(path.realpath(__file__))
    fw = Firmware(path.join(modulePath, "avr", "Button", "Debug", "Button.elf"))    
    # fw = Firmware(path.join(modulePath, "avr", "Button", "Release", "Button.elf")
    print("Loading {}".format(fw.filename))
    
    avr = Avr(firmware=fw)  # The Button.elf has mcu and freq info embedded
    # avr = Avr(firmware=fw, mcu='atmega2560', f_cpu=8000000)
    # avr = Avr(firmware=fw, mcu='attiny2313', f_cpu=8000000)  
          
    print("Fw loaded")
    
    # Set the GDB port and start simavr GDB
    avr.gdb_port = 1234;
    avr_gdb_init(avr.backend)
    # avr.state = cpu_Stopped #To let simavr wait on the first instruction for GDB to connect. 
    
    # Get the AVR A3 input pin.
    A3IRQ = avr.getirq(('A', 3));
    
    # Create simavr inbuilt button part.
    b = Button(avr); 
    
    # Get the button's output port and attach it to the AVR input.
    pysimavr.connect.avr_connect_irq(b.getirq(0), A3IRQ)
    
    prevState = -1
    i = 0