upsilon/linux/test.mpy

42 lines
853 B
Plaintext

from micropython import const
import machine
from time import sleep_us
dac_sel = const(4026531844)
dac_arm = const(4026531852)
dac_fin = const(4026531848)
dac_from = const(4026531856)
dac_to = const(4026531860)
adc_fin = const(4026531864)
adc_arm = const(4026531868)
adc_dat = const(4026531872)
adc_sel = const(4026531840)
machine.mem8[dac_sel] = 1
def dac_comm(val):
machine.mem32[dac_to] = val
machine.mem8[dac_arm] = 1
while machine.mem8[dac_fin] == 0:
pass
machine.mem8[dac_arm] = 0
def dac_read(val):
dac_comm(1 << 23 | val)
dac_comm(0)
v = bin(machine.mem32[dac_from])
print(v, len(v) - 2)
# dac_comm(0b11010010001)
dac_comm(1 << 22 | 1 << 2)
dac_comm(1 << 21 | (1 << 1))
dac_read(1 << 21)
machine.mem8[adc_sel] = 1
def adc_read():
machine.mem8[adc_arm] = 1
sleep_us(5)
machine.mem8[adc_arm] = 0
return machine.mem32[adc_dat]