Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phaser/LEDs: add global getter and individual getter/setter helpers #1863

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Highlights:
- Expose the DAC coarse mixer and ``sif_sync``
- Exposes upconverter calibration and enabling/disabling of upconverter LO & RF outputs.
- Add helpers to align Phaser updates to the RTIO timeline (``get_next_frame_mu()``)
- Add helpers to manipulate front panel LEDs
* ``get()``, ``get_mu()``, ``get_att()``, and ``get_att_mu()`` functions added for AD9910 and AD9912
* On Kasli, the number of FIFO lanes in the scalable events dispatcher (SED) can now be configured in
the JSON hardware description file.
Expand Down
41 changes: 40 additions & 1 deletion artiq/coredevice/phaser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from artiq.language.core import kernel, delay_mu, delay
from artiq.coredevice.rtio import rtio_output, rtio_input_data, rtio_input_timestamp
from artiq.language.units import us, ns, ms, MHz
from artiq.language.types import TInt32
from artiq.language.types import TInt32, TBool
from artiq.coredevice.dac34h84 import DAC34H84
from artiq.coredevice.trf372017 import TRF372017

Expand Down Expand Up @@ -408,6 +408,45 @@ def set_leds(self, leds):
"""
self.write8(PHASER_ADDR_LED, leds)

@kernel
def get_leds(self) -> TInt32:
"""Get the state of the front panel LEDs.

:return: LED settings (6 bit)
"""
state = self.read8(PHASER_ADDR_LED)
delay(20*us) # slack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks arbitrary and other drivers e.g. TTL, Sampler do not integrate such slack.

return state

@kernel
def set_led(self, led: TInt32, on: TBool = True):
"""Set the state of one front panel LED.

:param led: index of the LED to set (0-5)
:param on: whether to turn the LED on or off
"""
if led < 0 or led > 6:
raise ValueError("LED index out of bounds")

state = self.get_leds()
state &= ~(1 << led)
if on:
state |= (1 << led)
self.set_leds(state)

@kernel
def get_led(self, led: TInt32) -> TBool:
"""Get the state of one front panel LED.

:param led: index of the LED to query (0-5)
:return: whether the LED is on
"""
if led < 0 or led > 6:
raise ValueError("LED index out of bounds")

state = self.get_leds()
return bool((state >> led) & 1)

@kernel
def set_fan_mu(self, pwm):
"""Set the fan duty cycle.
Expand Down