more micropython tests
This commit is contained in:
parent
7458a98a20
commit
f8b7571f97
|
@ -0,0 +1,36 @@
|
||||||
|
from micropython import const
|
||||||
|
from time import sleep_us
|
||||||
|
import machine
|
||||||
|
|
||||||
|
dac_sel = const(4026531844)
|
||||||
|
dac_arm = const(4026531852)
|
||||||
|
dac_fin = const(4026531848)
|
||||||
|
dac_from = const(4026531856)
|
||||||
|
dac_to = const(4026531860)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
def dac_ramp_up(fromval,toval,step,ival):
|
||||||
|
assert step > 0
|
||||||
|
while fromval <= toval:
|
||||||
|
dac_comm(1 << 20 | fromval)
|
||||||
|
sleep_us(ival)
|
||||||
|
fromval = fromval + step
|
|
@ -0,0 +1,41 @@
|
||||||
|
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]
|
|
@ -1,10 +0,0 @@
|
||||||
import machine
|
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
dac_0_arm = Const(4026531852)
|
|
||||||
dac_0_finished = Const(4026531848)
|
|
||||||
|
|
||||||
machine.mem8[dac_0_arm] = 1
|
|
||||||
while machine.mem8[dac_0_finished] != 1:
|
|
||||||
pass
|
|
||||||
machine.mem8[dac_0_arm] = 0
|
|
Loading…
Reference in New Issue