forked from M-Labs/artiq
1
0
Fork 0

adc: implement standby & power-down/up

This commit is contained in:
occheung 2023-09-18 19:55:47 -07:00 committed by Sébastien Bourdeauducq
parent 870020bc9f
commit 9e1447d104
1 changed files with 17 additions and 1 deletions

View File

@ -229,6 +229,22 @@ class ADC:
adc_code = self.read24(_AD4115_REG_DATA) adc_code = self.read24(_AD4115_REG_DATA)
return ((adc_code / (1 << 23)) - 1) * 2.5 / 0.1 return ((adc_code / (1 << 23)) - 1) * 2.5 / 0.1
@kernel
def standby(self):
# Selecting internal XO (0b00) also disables clock during standby
self.write16(_AD4115_REG_ADCMODE, 0x8020)
@kernel
def power_down(self):
self.write16(_AD4115_REG_ADCMODE, 0x8030)
@kernel
def exit_power_down(self):
self.reset()
# Although the datasheet claims 500 us reset wait time, only waiting
# for ~500 us can result in DOUT pin stuck in high
delay(2500*us)
@kernel @kernel
def calibrate(self, volts, trigger, config, samples=[-5.0, 0.0, 5.0]): def calibrate(self, volts, trigger, config, samples=[-5.0, 0.0, 5.0]):
assert len(volts) == 16 assert len(volts) == 16