2019-08-22 16:07:12 +08:00
|
|
|
import sys, os
|
|
|
|
|
2019-10-03 19:45:50 +08:00
|
|
|
sample_rate = 48e6
|
|
|
|
ref_frequency = 1.97e6
|
2019-08-22 16:07:12 +08:00
|
|
|
|
|
|
|
ref_phase = 0
|
|
|
|
ref_ftw = int(ref_frequency*2**32/sample_rate)
|
|
|
|
|
|
|
|
fp = os.fdopen(sys.stdout.fileno(), "wb")
|
|
|
|
|
|
|
|
while True:
|
|
|
|
sample = 0
|
2019-10-03 19:45:50 +08:00
|
|
|
for _ in range(2):
|
2019-10-08 15:37:41 +08:00
|
|
|
sample <<= 2
|
2019-10-03 19:45:50 +08:00
|
|
|
|
|
|
|
ref_phase = (ref_phase + ref_ftw) & 0xffffffff
|
|
|
|
delta = 0
|
|
|
|
meas_phase = (ref_phase + delta) & 0xffffffff
|
|
|
|
|
|
|
|
if ref_phase >= 0x80000000:
|
|
|
|
sample |= 0x01
|
|
|
|
if meas_phase >= 0x80000000:
|
|
|
|
sample |= 0x02
|
2019-08-22 16:07:12 +08:00
|
|
|
fp.write(bytes([sample]))
|