Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #!/bin/python
  2.  
  3. from greatfet import GreatFET
  4.  
  5. gf=GreatFET()
  6.  
  7. def reset():
  8. gf.spi.transmit([0xc8])
  9.  
  10. def status():
  11. # Send a NOP and print the status byte response in hex.
  12. print(hex(gf.spi.transmit([0xff])[0]))
  13.  
  14. def ready():
  15. # Send RC_PHY_RDY.
  16. gf.spi.transmit([0xb3])
  17.  
  18. def tx():
  19. # Send RC_TX.
  20. gf.spi.transmit([0xb5])
  21.  
  22. def config_test():
  23. # See Transmit Test Modes on page 71 of data sheet.
  24. gf.spi.transmit([0x1b, 0xf0, 0x21]) # Set tx_fsk_test to unmodulated carrier
  25. gf.spi.transmit([0x19, 0x07, 0xb0]) # buffercfg
  26. gf.spi.transmit([0x19, 0x08, 0x0c]) # Set skip_synth_settle in pkt_cfg
  27.  
  28. # Set up GPIO pins used to configure the TX RF switch.
  29. v1=gf.gpio.get_pin('J2_P19')
  30. v2=gf.gpio.get_pin('J2_P23')
  31. v3=gf.gpio.get_pin('J2_P25')
  32. v4=gf.gpio.get_pin('J2_P27')
  33. v1.set_direction(v1.DIRECTION_OUT)
  34. v2.set_direction(v2.DIRECTION_OUT)
  35. v3.set_direction(v3.DIRECTION_OUT)
  36. v4.set_direction(v4.DIRECTION_OUT)
  37.  
  38. # To select the U1 TX path, write 1 to v1 and 0 to the others.
  39. # For U2, write 1 to v2 and 0 to the others, etc.
  40. v1.write(1)
  41. v2.write(0)
  42. v3.write(0)
  43. v4.write(0)
  44.  
  45. # U1 chip select: J2_P9
  46. # U2 chip select: J1_P14
  47. # U3 chip select: J2_P7
  48. # U4 chip select: J1_P34
  49. #
  50. # I've just been testing one chip at a time, so I have connected a jumper wire
  51. # from one of the above pins to J1_P37 (SSEL). Alternatively you can wrap
  52. # spi.transmit() in a function that pulls down the appropriate chip select.
  53.  
  54. status()
  55. reset()
  56. status()
  57. status()
  58. config_test()
  59. ready()
  60. tx()
  61. status()
  62.  
  63. # Status should now be 0xe5 which indicates TX is active. If it doesn't go to
  64. # 0xe5, try again. (For reliability we probably need to confirm prior state
  65. # changes before requesting another.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement