Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from uio.utils import fix_ctypes_struct
- from uio.ti.icss import Icss
- import ctypes
- from ctypes import c_uint32 as u32, c_uint16 as u16, c_int32 as int32, c_bool as boolean
- from time import sleep
- from sys import exit
- pruss = Icss( "/dev/uio/pruss/module" )
- pruss.initialize()
- core_0 = pruss.core0
- core_1 = pruss.core1
- core_0.load( 'pulse_train.out' )
- # volatile variables in pruss shared memory
- class SharedVars( ctypes.Structure ):
- _fields_ = [
- ( 'target_pos', u32 ),
- ( 'current_pos', u32 ),
- ( 'hault_request', boolean ),
- ]
- # map shared memory variables
- shmem = core_0.map( SharedVars, 0x10100 )
- # ready, set, go!
- shmem.hault_request = False
- pruss.ecap.pwm.initialize( 2**32 )
- print(f'Initial position {shmem.current_pos} Target = {shmem.target_pos}')
- core_0.run()
- print('starting PRU0')
- try:
- shmem.hault_request = False
- shmem.target_pos = 3
- sleep(5)
- except KeyboardInterrupt:
- pass
- finally:
- print( '', flush=True )
- shmem.hault_request = True
- sleep( 0.01 ) # make sure that response has been receivedi
- print(f' ending register 30 {core_0.r30}')
- core_0.r30 |= (1 <<0)
- print(f'testing register 30 {core_0.r30}')
- print(f'Position {shmem.current_pos} Target = {shmem.target_pos}')
- print('done hopefully you
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement