Advertisement
Guest User

Untitled

a guest
May 20th, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. #!/usr/bin/python3
  2. from uio.utils import fix_ctypes_struct
  3. from uio.ti.icss import Icss
  4. import ctypes
  5. from ctypes import c_uint32 as u32, c_uint16 as u16, c_int32 as int32, c_bool as boolean
  6. from time import sleep
  7. from sys import exit
  8.  
  9.  
  10. pruss = Icss( "/dev/uio/pruss/module" )
  11. pruss.initialize()
  12.  
  13. core_0 = pruss.core0
  14. core_1 = pruss.core1
  15.  
  16. core_0.load( 'pulse_train.out' )
  17.  
  18. # volatile variables in pruss shared memory
  19. class SharedVars( ctypes.Structure ):
  20.     _fields_ = [
  21.             ( 'target_pos',  u32 ),
  22.             ( 'current_pos', u32 ),
  23.             ( 'hault_request', boolean ),
  24.         ]
  25.  
  26.  
  27. # map shared memory variables
  28. shmem = core_0.map( SharedVars, 0x10100 )
  29.  
  30.  
  31. # ready, set, go!
  32. shmem.hault_request = False
  33. pruss.ecap.pwm.initialize( 2**32 )
  34. print(f'Initial position {shmem.current_pos} Target = {shmem.target_pos}')
  35. core_0.run()
  36. print('starting PRU0')
  37.  
  38. try:
  39.     shmem.hault_request = False
  40.     shmem.target_pos = 3
  41.     sleep(5)
  42.  
  43. except KeyboardInterrupt:
  44.     pass
  45.  
  46. finally:
  47.  
  48.     print( '', flush=True )
  49.     shmem.hault_request = True
  50.    
  51.     sleep( 0.01 )  # make sure that response has been receivedi
  52.     print(f' ending register 30 {core_0.r30}')
  53.     core_0.r30 |= (1 <<0)
  54.     print(f'testing register 30 {core_0.r30}')
  55.     print(f'Position {shmem.current_pos} Target = {shmem.target_pos}')
  56.    
  57.     print('done hopefully you
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement