Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. from uio.utils import fix_ctypes_struct
  4. from uio.ti.icss import Icss
  5. import ctypes
  6. from ctypes import c_uint32 as u32, c_uint16 as u16, c_int32 as int32
  7. from time import sleep
  8. from sys import exit
  9.  
  10. pruss = Icss( "/dev/uio/pruss/module" )
  11. pruss.initialize()
  12. ddr = pruss.ddr
  13. pruss.uart.initialize(baudrate = 460800)
  14.  
  15.  
  16. core_1 = pruss.core1
  17. core_1.load( 'fw-c/stream.out' )
  18.  
  19.  
  20. core_0 = pruss.core0
  21. core_0.load( 'fw/decoder.bin' )
  22.  
  23. class Message( ctypes.Structure ):
  24. _fields_ = [
  25. ( 'id', u32 ),
  26. ('timestamp',u32),
  27. ('position', u32),
  28. ('force', int32),
  29. ]
  30.  
  31. # used to communicate ddr layout to C program
  32. class DDRLayout( ctypes.Structure ):
  33. _fields_ = [
  34. ( 'msgbuf', u32 ),
  35. ( 'num_msgs', u16 ),
  36. ( 'msg_size', u16 ),
  37. ]
  38.  
  39. # volatile variables in pruss shared memory
  40. class SharedVars( ctypes.Structure ):
  41. _fields_ = [
  42. ( 'abort_file', u32 ),
  43. ( 'abort_line', u32 ),
  44. ( 'ridx', u16 ),
  45. ]
  46.  
  47. # if you don't want the ringbuffer at the start of the ddr region, specify offset here
  48. MSGBUF_OFFSET = 0
  49.  
  50. # you can use a fixed ringbuffer size:
  51. #NUM_MSGS = 1024
  52. # or you can scale the ringbuffer to fit the size of the ddr region:
  53. NUM_MSGS = ( ddr.size - MSGBUF_OFFSET - ctypes.sizeof( u16 ) ) // ctypes.sizeof( Message )
  54. NUM_MSGS = min( NUM_MSGS, 65535 ) # make sure number of messages fits in u16
  55.  
  56. # map shared memory variables
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement