Пример #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. 
Пример #2
0
 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()
Пример #3
0
 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()
Пример #4
0
 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()
Пример #5
0
 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()
Пример #6
0
 def __init__(self, prog):
     self.val = {}
     pypruss.modprobe()
     pypruss.init()
     pypruss.open(event_nr)
     pypruss.pruintc_init()
     pypruss.pru_disable(1)
     self.data = pypruss.map_prumem(pypruss.PRUSS0_PRU1_DATARAM)
     self.write32(COM_RANGE, 0)
     pypruss.exec_program(1, prog)
Пример #7
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()
Пример #8
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()
Пример #9
0
def moveStepper_p9_15(steps):
    pypruss.modprobe()
    pypruss.init()
    pypruss.open(0)  # Open PRU event 0 which is PRU0_ARM_INTERRUPT
    pypruss.pruintc_init()  # Init the interrupt controller

    setSteps(steps)

    pypruss.exec_program(
        0, "./pru/p9_15.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.
Пример #10
0
    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()
Пример #11
0
def end():
    pypruss.pru_disable(0)
    pypruss.exit()
Пример #12
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. 
Пример #13
0
#      self.rest = 0
      pass

steps, speed, acc, dec = (float(arg) for arg in sys.argv[1:5])

if sim:
  fifo = SimFifo()
else:
  fifo = init('./stepper.bin')

stepper = Stepper(fifo)
stepper.move(steps, speed, acc, dec)

if not sim:
  fifo.write([0,0,0,0])

  olda = fifo.front()
  while True:
    a = fifo.front()
    if not olda == a:
      print 'front:',a
      olda = a
    if a == fifo.back:
      break
    time.sleep(0.1)

  pypruss.wait_for_event(0)
  pypruss.clear_event(0)
  pypruss.pru_disable(0)
  pypruss.exit()
Пример #14
0
    def stop_pru(self):

        pypruss.pru_disable(0)
        pypruss.exit()
        return 0
Пример #15
0
 def stop(self):
     logging.debug("[ADC] Stopping the PRUs")
     struct.pack_into('L', self._data, self.PRU0_OFFSET_RES1, 0xdeadbeef)
     time.sleep(0.5)
     pypruss.pru_disable(0)
Пример #16
0
    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
Пример #17
0
 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. 
Пример #18
0
def cleanup(signum, frame):
    pypruss.pru_disable(0)
    pypruss.exit()                                # Exit
    sys.exit()
Пример #19
0
 def stop(self):
     pypruss.pru_disable(1)				# Disable PRU 1, this is already done by the firmware
     pypruss.exit()
     self.data = None
Пример #20
0
def cleanup(signum, frame):
    pypruss.pru_disable(0)
    pypruss.exit()  # Exit
    sys.exit()
Пример #21
0
#!/usr/bin/python
import os
import argparse
import pypruss

from math import ceil

if __name__ == '__main__':
    pru = 0
    firmware = "./clock.bin"
    pypruss.modprobe()                                  # This only has to be called once pr boot
    pypruss.init()                                      # Init the PRU
    pypruss.open(pru)                                   # Open PRU event <num> which is PRU<num>_ARM_INTERRUPT
    pypruss.pruintc_init()                              # Init the interrupt controller
    pypruss.exec_program(pru, firmware)                 # Load firmware on PRU <num>
    pypruss.wait_for_event(pru)                         # Wait for event <num> which is connected to PRU<num>_ARM_INTERRUPT
    pypruss.clear_event(pru)                            # Clear the event
    pypruss.pru_disable(pru)                            # Disable PRU <num>, this is already done by the firmware
    pypruss.exit()                                      # Exit, don't know what this does.