def __init__(self, pru=0, pru0_fw="arm/pru00.bin", pru1_fw="arm/pru01.bin"): if pru == 0: pru_dataram = pypruss.PRUSS0_PRU0_DATARAM else: pru_dataram = pypruss.PRUSS0_PRU1_DATARAM self._spare = 0 self._ofile = None self._gpsp = None logging.debug("[ADC] setting up power control line") GPIO.setup("P9_18", GPIO.OUT) logging.debug("[ADC] pruss init") pypruss.init() # Init the PRU logging.debug("[ADC] pruss open") ret = pypruss.open(self.PRU_EVTOUT_0) logging.debug("[ADC] pruss intc init") pypruss.pruintc_init() # Init the interrupt controller logging.debug("[ADC] mapping memory") self._data = pypruss.map_prumem(pru_dataram) logging.debug("[ADC] data segment len=%d" % len(self._data)) logging.debug("[ADC] setting tail") self._tail = 0 struct.pack_into('l', self._data, self.PRU0_OFFSET_DRAM_HEAD, self._tail) logging.debug("[ADC] mapping extmem") self._extmem = pypruss.map_extmem() logging.debug("[ADC] ext segment len=%d" % len(self._extmem)) logging.debug("[ADC] setup mem") self.ddrMem = pypruss.ddr_addr() logging.debug("[ADC] V extram_base = 0x%x" % self.ddrMem) self._pru01_phys = int( open("/sys/class/uio/uio1/maps/map1/addr", 'r').read(), 16) struct.pack_into('L', self._data, self.PRU0_OFFSET_SRAM_HEAD, 0) struct.pack_into('L', self._data, self.PRU0_OFFSET_DRAM_PBASE, self._pru01_phys) struct.pack_into('L', self._data, self.PRU0_OFFSET_SPIN_COUNT, 0) struct.pack_into('L', self._data, self.PRU0_OFFSET_RES1, 0x00000000) struct.pack_into('L', self._data, self.PRU0_OFFSET_SPIN_COUNT, 0) struct.pack_into('L', self._data, self.PRU0_OFFSET_SPIN_COUNT, 0) struct.pack_into('L', self._data, self.PRU0_OFFSET_RES2, 0xbabedead) struct.pack_into('L', self._data, self.PRU0_OFFSET_RES3, 0xbeefcafe) logging.debug("[ADC] loading pru01 code") pypruss.exec_program(1, pru1_fw) logging.debug("[ADC] loading pru00 code") pypruss.exec_program(0, pru0_fw)
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)
def setup(this): 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 this.buffer = pypruss.map_prumem(pypruss.PRUSS0_PRU0_DATARAM) pypruss.exec_program(0, "./triac.bin") # Load firmware "blinkled.bin" on PRU 0 this.brightness = [0 for x in range(N_BULBS)] this.writeOffset = 0 this.write()
def __init__(self): pypruss.modprobe(100) print 'Initializing PRU' pypruss.init() print 'successfully initialized!' if pypruss.open(0): print 'PRU open failed' return 1 pypruss.pruintc_init() self.pruData = pypruss.map_prumem(pypruss.PRUSS0_PRU0_DATARAM) pypruss.exec_program(0, "./hcsr04.bin")