17 from __future__
import print_function
18 from libpruio
import *
48 def load_firmware(IRam):
49 PRUcode = (c_uint32*13)(
65 raise AssertionError(
"failed loading instructions")
69 io =
pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
74 if IO.Errr:
raise AssertionError(
"pruio_new failed (%s)" % IO.Errr)
82 pru_iram = PRUSS0_PRU0_IRAM
84 pru_dram = PRUSS0_PRU0_DRAM
86 pru_intr = PRU0_ARM_INTERRUPT
89 pru_iram = PRUSS0_PRU1_IRAM
90 pru_dram = PRUSS0_PRU1_DRAM
91 pru_intr = PRU0_ARM_INTERRUPT
96 raise AssertionError(
"prussdrv_open failed (%s)" % IO.Errr)
99 load_firmware(pru_iram)
116 if (IO.setPin(io, P8_11, 6)):
117 raise AssertionError(
"P8_11 configuration failed (%s)" % IO.Errr)
122 raise AssertionError(
"failed setting input P9_42 (%s)" % IO.Errr)
124 raise AssertionError(
"config failed (%s)" % IO.Errr)
133 dram = pointer(c_uint32(0))
137 dram[2] = pru_intr + 16
141 print(
"instructions loaded, starting PRU-%d" % pru_num)
143 for i
in range(0, 20):
149 raise AssertionError(
"failed reading input P9_42 (%s)" % IO.Errr)
151 print(
"--> Frequency: %3.0f MHz, Duty:%3.0f %c" %
152 ((f.value * .000001), (d.value * 100),
'%'))
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
char * pruio_cap_Value(pruIo *Io, uint8 Ball, float_t *Hz, float_t *Du)
Wrapper function for CapMod::Value().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
char * pruio_cap_config(pruIo *Io, uint8 Ball, float_t FLow)
Wrapper function for CapMod::config().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().
int32 prussdrv_pru_disable(uint32 prunum)
See prussdrv_pru_disable(BYVAL_AS_UInt32 PruId)
char * prussdrv_pru_resume(uint32 prunum)
See prussdrv_pru_resume(BYVAL_AS_UInt32 PruId)
#define prussdrv_pru_enable(N)
Macro for variadic parameter list.
void prussdrv_pru_clear_event(uint32 host_interrupt, uint32 sysevent)
See prussdrv_pru_clear_event(BYVAL_AS_UInt32 Irq, BYVAL_AS_UInt32 Event)
uint32 prussdrv_pru_wait_event(uint32 host_interrupt)
See prussdrv_pru_wait_event(BYVAL_AS_UInt32 Irq)
int32 prussdrv_open(uint32 host_interrupt)
See prussdrv_open(BYVAL_AS_UInt32 Irq)
int32 prussdrv_pru_write_memory(uint32 pru_ram_id, uint32 wordoffset, const uint32 *memarea, uint32 bytelength)
See prussdrv_pru_write_memory(BYVAL_AS_UInt32 RamId, BYVAL_AS_UInt32 Offs, BYVAL_AS_CONST_UInt32_PTR ...
int32 prussdrv_map_prumem(uint32 pru_ram_id, void **address)
See prussdrv_map_prumem(BYVAL_AS_UInt32 RamId, BYVAL_AS_ANY_PTR_PTR Addr)