Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python
- from greatfet import GreatFET
- gf=GreatFET()
- def reset():
- gf.spi.transmit([0xc8])
- def status():
- # Send a NOP and print the status byte response in hex.
- print(hex(gf.spi.transmit([0xff])[0]))
- def ready():
- # Send RC_PHY_RDY.
- gf.spi.transmit([0xb3])
- def tx():
- # Send RC_TX.
- gf.spi.transmit([0xb5])
- def config_test():
- # See Transmit Test Modes on page 71 of data sheet.
- gf.spi.transmit([0x1b, 0xf0, 0x21]) # Set tx_fsk_test to unmodulated carrier
- gf.spi.transmit([0x19, 0x07, 0xb0]) # buffercfg
- gf.spi.transmit([0x19, 0x08, 0x0c]) # Set skip_synth_settle in pkt_cfg
- # Set up GPIO pins used to configure the TX RF switch.
- v1=gf.gpio.get_pin('J2_P19')
- v2=gf.gpio.get_pin('J2_P23')
- v3=gf.gpio.get_pin('J2_P25')
- v4=gf.gpio.get_pin('J2_P27')
- v1.set_direction(v1.DIRECTION_OUT)
- v2.set_direction(v2.DIRECTION_OUT)
- v3.set_direction(v3.DIRECTION_OUT)
- v4.set_direction(v4.DIRECTION_OUT)
- # To select the U1 TX path, write 1 to v1 and 0 to the others.
- # For U2, write 1 to v2 and 0 to the others, etc.
- v1.write(1)
- v2.write(0)
- v3.write(0)
- v4.write(0)
- # U1 chip select: J2_P9
- # U2 chip select: J1_P14
- # U3 chip select: J2_P7
- # U4 chip select: J1_P34
- #
- # I've just been testing one chip at a time, so I have connected a jumper wire
- # from one of the above pins to J1_P37 (SSEL). Alternatively you can wrap
- # spi.transmit() in a function that pulls down the appropriate chip select.
- status()
- reset()
- status()
- status()
- config_test()
- ready()
- tx()
- status()
- # Status should now be 0xe5 which indicates TX is active. If it doesn't go to
- # 0xe5, try again. (For reliability we probably need to confirm prior state
- # changes before requesting another.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement