예제 #1
0
파일: prio.py 프로젝트: byuccl/PYNQ-PRIO
	def download(self, partial_bit=None):
		if partial_bit is not None:
			decoupler = GPIO(int(partial_bit[len(self.PARTIAL_BITSTREAM_PATH) + 3]) + GPIO.get_gpio_base(), 'out')
			decoupler.write(1)
		super().download(partial_bit)
		if partial_bit is not None:
			decoupler.write(0)
예제 #2
0
def test_gpio():
    """ Test whether the GPIO class is working properly.
    
    Note
    ----
    The gpio_min is the GPIO base pin number + minimum user pin
    The gpio_max is the smallest power of 2 greater than the GPIO base.
    
    """
    # Find the GPIO base pin
    for root, dirs, files in os.walk('/sys/class/gpio'):
        for name in dirs:
            if 'gpiochip' in name:
                index = int(''.join(x for x in name if x.isdigit()))
    base = GPIO.get_gpio_base()
    gpio_min = base + general_const.GPIO_MIN_USER_PIN
    gpio_max = 2**(math.ceil(math.log(gpio_min, 2)))

    for index in range(gpio_min, gpio_max):
        g = GPIO(index, 'in')
        with pytest.raises(Exception) as error_infor:
            # GPIO type is 'in'. Hence g.write() is illegal.
            # Test will pass if exception is raised.
            g.write()
        del g

        g = GPIO(index, 'out')
        with pytest.raises(Exception) as error_infor:
            # GPIO type is 'out'. Hence g.read() is illegal.
            # Test will pass if exception is raised.
            g.read()
        with pytest.raises(Exception) as error_infor:
            # write() only accepts integer 0 or 1 (not 'str').
            # Test will pass if exception is raised.
            g.write('1')

        del g
예제 #3
0
파일: test_gpio.py 프로젝트: hexanoid/PYNQ
def test_gpio():
    """ Test whether the GPIO class is working properly.
    
    Note
    ----
    The gpio_min is the GPIO base pin number + minimum user pin
    The gpio_max is the smallest power of 2 greater than the GPIO base.
    
    """
    # Find the GPIO base pin
    for root, dirs, files in os.walk('/sys/class/gpio'):
            for name in dirs:
                if 'gpiochip' in name:
                    index = int(''.join(x for x in name if x.isdigit()))
    base = GPIO.get_gpio_base()
    gpio_min = base + general_const.GPIO_MIN_USER_PIN
    gpio_max = 2**(math.ceil(math.log(gpio_min, 2)))
            
    for index in range(gpio_min, gpio_max):
        g = GPIO(index, 'in')
        with pytest.raises(Exception) as error_infor:
            # GPIO type is 'in'. Hence g.write() is illegal. 
            # Test will pass if exception is raised.
            g.write()
        
        g = GPIO(index, 'out')
        with pytest.raises(Exception) as error_infor:
            # GPIO type is 'out'. Hence g.read() is illegal. 
            # Test will pass if exception is raised.
            g.read()
        with pytest.raises(Exception) as error_infor:
            # write() only accepts integer 0 or 1 (not 'str'). 
            # Test will pass if exception is raised.
            g.write('1')
        
        del g
예제 #4
0
from pynq import GPIO
import time
import smbus

# This will minipulate a LED Ring R Click Board in Slot 1
# of the Ultra96 mikro click mezzanine board 

# Obtain the reset pin of slot 1 of the Ultra96 mikro mezzanine board
# PS pin MIO37 is connected to slot 1 RST
# PS pin MIO40 is connected to slot 2 RST

# Linux pin number to Xilinx pin numbers are weird and have a large
# base number than can change between different releases of Linux
# The pynq base fcn will help here!  base for 2018.2 was 338
mio_linux_number = GPIO.get_gpio_base() + 37

# EMIOs start after MIO and there
# is fixed offset for ZYNQ (54) and ZYNQ US+ (78)
#   emio_linux_number = GPIO.get_gpio_pin(emio_offset)

rst_pin = GPIO(mio_linux_number, 'out')

# Reset is usually active LOW
rst_pin.write(1)
time.sleep(.1)
rst_pin.write(0)
time.sleep(.1)
rst_pin.write(1)

print("Start I2C Test\n")
예제 #5
0
 def pr_download(self, partial_region, partial_bit, dtbo_path=None):
     decoupler = GPIO(int(partial_region[3]) + GPIO.get_gpio_base(), 'out')
     decoupler.write(1)
     super().pr_download(partial_region, partial_bit, dtbo_path)
     decoupler.write(0)