Esempio n. 1
0
 def join(self):
     logging.debug("joining")
     self.running = False
     self.t.join()        
     self.ddr_mem.close()                                    # Close the memory        
     pypruss.pru_disable(0)                                  # Disable PRU 0, this is already done by the firmware
     pypruss.exit()                                          # Exit, don't know what this does. 
Esempio n. 2
0
File: servos.py Progetto: Miaou/BBB
 def __del__(self):
     # Hope we get there
     print('Closing the PRU interface')
     pypruss.pru_disable(0) # Does not wait for program to complete, I don't care here
     pypruss.exit()
     self.pruicss.close()
     self.mem_fd.close()
Esempio n. 3
0
File: dallas.py Progetto: Miaou/BBB
 def __del__(self):
     global OneWire # Hack: sometimes OneWire is deleted before self
     if not OneWire:
         OneWire = self._keepalive
     OneWire.nInstances -= 1
     if not OneWire.nInstances:
         print('Exiting PRU program')
         pypruss.pru_disable(0)
         pypruss.exit()
Esempio n. 4
0
def main():
    # Initialize environment
    pypruss.modprobe()

    pypruss.init()              # Init the PRU
    pypruss.open(0)             # Open PRU event 0 which is PRU0_ARM_INTERRUPT
    pypruss.pruintc_init()      # Init the interrupt controller
    pypruss.exec_program(0, "./hello_pru.bin")  # Load firmware on PRU0
    pypruss.wait_for_event(0)   # Wait for event 0 which is conn to PRU0_ARM_INTERUPT
    pypruss.clear_event(0)      # Clear the event
    pypruss.exit()              # Exit PRU

    print("Test completed: PRU was successfully opened and closed.")
Esempio n. 5
0
	def stop(self):
		print("Ending")
		# Set our command byte to FF and write it out
		self.data[0] = 0x000000FF
		pypruss.pru_write_memory(0, 0, self.data)

		# Wait for event 0 which is connected to PRU0_ARM_INTERRUPT
		pypruss.wait_for_event(0)
		# Clear the event
		pypruss.clear_event(0)
		# Disable PRU 0, this is already done by the firmware
		pypruss.pru_disable(0)
		# Exit, don't know what this does.
		pypruss.exit()
Esempio n. 6
0
def sendData(addr,data,rx=0):
	if(rx==0):
		data = [int((0x00 << 24) + (addr << 16) + data)]
	else:
		data = [int((0x80 << 24) + (addr << 16) + 0x0000)]
	
	# data = [0x80272345]	
	GPIO.output("P8_30",GPIO.LOW)
	pypruss.init()						# Init the PRU
	pypruss.open(0)						# Open PRU event 0 which is PRU0_ARM_INTERRUPT
	pypruss.pruintc_init()					# Init the interrupt controller
	pypruss.pru_write_memory(1, 0, data)			# Load the data in the PRU ram
	pypruss.exec_program(1, "arm/spi_awg.bin")		# Load firmware "mem_write.bin" on PRU 0
	pypruss.wait_for_event(0)				# Wait for event 0 which is connected to PRU0_ARM_INTERRUPT
	pypruss.clear_event(0)					# Clear the event
	# data = [0x12345678]
	pypruss.pru_write_memory(1, 0, data)			# Load the data in the PRU ram
	GPIO.output("P8_30",GPIO.HIGH)
	if (rx == 1):

		PRU_ICSS = 0x4A300000  
		PRU_ICSS_LEN = 512*1024 

		# RAM0_START = 0x00000000
		# RAM1_START = 0x00002000
		RAM2_START = 0x00012000


		with open("/dev/mem", "r+b") as f:
			ddr_mem = mmap.mmap(f.fileno(), PRU_ICSS_LEN, offset=PRU_ICSS) 
			# local = struct.unpack('LLLL', ddr_mem[RAM1_START:RAM1_START+16])
			shared = struct.unpack('L', ddr_mem[RAM2_START:RAM2_START+4])
		f.close()
	pypruss.exit()							# Exit
	if (rx == 1):
		return shared[0]
	else:
		return 0
Esempio n. 7
0
File: Pru.py Progetto: zittix/redeem
    def emergency_interrupt(self):
        pypruss.pru_disable(0)                                  # Disable PRU 0, this is already done by the firmware
        pypruss.exit()                                          # Exit, don't know what this does. 
        logging.debug('Resetting PRU...')
      
        self.pru_data       = []

        while True:
            try:
                b = self.ddr_used.get(block=False)
                if b != None:
                    self.ddr_used.task_done()
            except Queue.Empty:
                break

        self.ddr_reserved   = 0      
        with Pru.ddr_lock: 
            self.ddr_mem_used   = 0  
        self.clear_events   = []       
        self.ddr_start      = self.DDR_START
        self.ddr_nr_events  = self.ddr_addr+self.ddr_size-4

        self.init_pru()
Esempio n. 8
0
def main():
    # Initialize evironment
    pypruss.modprobe()
    pypruss.init()		# Init the PRU
    pypruss.open(0)		# Open PRU event 0 which is PRU0_ARM_INTERRUPT
    pypruss.pruintc_init()  # Init the interrupt controller

    # Configure PRU Registers
    pypruss.pru_write_memory(0, 0, [0, ])

    # Execute the PRU program
    a = time.time()
    pypruss.exec_program(0, "./bin/timer_app.bin")  # Load firmware on PRU0

    # Wait for PRU to finish its job.
    pypruss.wait_for_event(0)  # Wait for event 0 which is conn to PRU0_ARM_INTERUPT
    loop_time = time.time() - a

    # Once signal has been received, clean up house
    pypruss.clear_event(0)  # Clear the event
    pypruss.exit()		# Exit PRU

    print("That's a %ds loop you have there." % loop_time)
    print("Test completed: PRU was successfully opened and closed.")
Esempio n. 9
0
ddr_size = pypruss.ddr_size()

print "DDR memory address is 0x%x and the size is 0x%x"%(ddr_addr, ddr_size)

ddr_offset  = ddr_addr-0x10000000
ddr_filelen = ddr_size+0x10000000
ddr_start 	= 0x10000000
ddr_end 	= 0x10000000+ddr_size

pypruss.init()		# Init the PRU
pypruss.open(0)		# Open PRU event 0 which is PRU0_ARM_INTERRUPT
pypruss.pruintc_init()	# Init the interrupt controller
pypruss.pru_write_memory(0, 0, [ddr_addr, ddr_addr+ddr_size-4])	# Put the ddr address in the first region 
pypruss.exec_program(0, "./ddr_write.bin")	# Load firmware "ddr_write.bin" on PRU 0
pypruss.wait_for_event(0)	# Wait for event 0 which is connected to PRU0_ARM_INTERRUPT
pypruss.clear_event(0)		# Clear the event
pypruss.exit()			# Exit PRU

with open("/dev/mem", "r+b") as f:	# Open the physical memory device
	ddr_mem = mmap.mmap(f.fileno(), ddr_filelen, offset=ddr_offset) # mmap the right area

read_back = struct.unpack("L", ddr_mem[ddr_start:ddr_start+4])[0]	# Parse the data
read_back2 = struct.unpack("L", ddr_mem[ddr_end-4:ddr_end])[0]		# Parse the data

print "The first 4 bytes of DDR memory reads "+hex(read_back)
print "The last 4 bytes of DDR memory reads "+hex(read_back2)

ddr_mem.close()								# Close the memory 
f.close()								# Close the file

Esempio n. 10
0
 def close( self ):
     if( self.clear_leds_at_end ):
         self.clear()
     pypruss.exit()
Esempio n. 11
0
''' blinkled.py - test script for the PyPRUSS library
It blinks the user leds ten times'''

import pypruss

pypruss.modprobe() 			  				       	# This only has to be called once pr boot
pypruss.init()										# Init the PRU
pypruss.open(0)										# Open PRU event 0 which is PRU0_ARM_INTERRUPT
pypruss.pruintc_init()								# Init the interrupt controller
pypruss.exec_program(0, "./blinkled.bin")			# Load firmware "blinkled.bin" on PRU 0
pypruss.wait_for_event(0)							# Wait for event 0 which is connected to PRU0_ARM_INTERRUPT
pypruss.clear_event(0)								# Clear the event
pypruss.pru_disable(0)								# Disable PRU 0, this is already done by the firmware
pypruss.exit()										# Exit, don't know what this does. 
Esempio n. 12
0
from __future__ import print_function

import pypruss

print("Running modprobe")
pypruss.modprobe(1000)
print("modprobe ok")

pypruss.init()
print("init ok")

pypruss.open(0)
print("open ok")

pypruss.pruintc_init()
print("intc ok")

print("ddr addr is " + hex(pypruss.ddr_addr()))
print("ddr size is " + hex(pypruss.ddr_size()))

pypruss.exit()
print("exit ok")

pypruss.modunprobe()
print("modunprobe ok")
Esempio n. 13
0
RAM0_START = 0x00000000
RAM1_START = 0x00002000
RAM2_START = 0x00012000


with open("/dev/mem", "r+b") as f:	       
    ddr_mem = mmap.mmap(f.fileno(), PRU_ICSS_LEN, offset=PRU_ICSS) 
    ddr_mem[RAM0_START:RAM0_START+4] = struct.pack('L', 0)
    ddr_mem[RAM1_START:RAM1_START+4] = struct.pack('L', 0)
    ddr_mem[RAM2_START:RAM2_START+4] = struct.pack('L', 0)

pypruss.init()								# Init the PRU
pypruss.open(0)								# Open PRU event 0 which is PRU0_ARM_INTERRUPT
pypruss.pruintc_init()						# Init the interrupt controller
pypruss.exec_program(1, "./mem_read.bin")	# Load firmware "mem_write.bin" on PRU 0
pypruss.wait_for_event(0)					# Wait for event 0 which is connected to PRU0_ARM_INTERRUPT
pypruss.clear_event(0)						# Clear the event
pypruss.exit()								# Exit



with open("/dev/mem", "r+b") as f:	       
    ddr_mem = mmap.mmap(f.fileno(), PRU_ICSS_LEN, offset=PRU_ICSS) 
    local = struct.unpack('L', ddr_mem[RAM0_START:RAM0_START+4])
    print hex(local[0])
    local = struct.unpack('L', ddr_mem[RAM1_START:RAM1_START+4])
    print hex(local[0])
    shared = struct.unpack('L', ddr_mem[RAM2_START:RAM2_START+4])
    print hex(shared[0])
Esempio n. 14
0
 def stop(self):
     pypruss.pru_disable(1)				# Disable PRU 1, this is already done by the firmware
     pypruss.exit()
     self.data = None
	print percentChange
	#Now we've compared. Let's write the most recent speed to our file.
	f = open('speed.txt', 'w')
	f.write (speed[0])
	f.close()


	pypruss.modprobe() 			  				       	# This only has to be called once pr boot
	pypruss.init()										# Init the PRU
	pypruss.open(0)										# Open PRU event 0 which is PRU0_ARM_INTERRUPT
	pypruss.pruintc_init()								# Init the interrupt controller

	if percentChange < -5:
		pypruss.exec_program(0,"./red.bin")
	else: 
		if percentChange < 0:
			pypruss.exec_program(0,"./orange.bin")
		else:
			if percentChange > 0:
				pypruss.exec_program(0,"./green.bin")
			else:
				pypruss.exec_program(0,"./other.bin")   #should never hit this
		
	pypruss.wait_for_event(0)							# Wait for event 0 which is connected to PRU0_ARM_INTERRUPT
	pypruss.clear_event(0)								# Clear the event
	pypruss.pru_disable(0)								# Disable PRU 0, this is already done by the firmware
	pypruss.exit()									# Exits pypruss 
	time.sleep(interval)                        						# restarts speed evaluation after 'interval' seconds

Esempio n. 16
0
def cleanup(signum, frame):
    pypruss.pru_disable(0)
    pypruss.exit()                                # Exit
    sys.exit()
Esempio n. 17
0
File: Pru.py Progetto: zittix/redeem
 def force_exit(self):
     self.running = False  
     pypruss.pru_disable(0)                                  # Disable PRU 0, this is already done by the firmware
     pypruss.exit()                                          # Exit, don't know what this does.