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

Conversation

airwoodix
Copy link
Contributor

@airwoodix airwoodix commented Mar 7, 2022

ARTIQ Pull Request

Description of Changes

Add convenience methods to Phaser coredevice driver for manipulating front panel LEDs.

New methods:

  • get_leds(): retrieve the state of all front panel LEDs on 6 bits
  • set_led(index, state): change the state of a single front panel LED
  • get_led(index): get the state of a single front panel LED

get_leds() includes some slack to compensate for the register delay.

Testing:

The LED wave code in artiq_sinara_tester is simpler with the existing set_leds() method (no modification). This patch was tested manually with the following snippet:

from artiq.experiment import *


class PhaserLEDs(EnvExperiment):
    def build(self):
        self.setattr_device("core")
        self.setattr_device("phaser0")

    @kernel
    def run(self):
        self.core.reset()

        # red LEDs on
        self.phaser0.set_leds(0b101011)
        assert self.phaser0.get_leds() == 0b101011
        delay(1 * s)

        # LED wave
        for _ in range(5):
            for led in range(6):
                for state in [True, False]:
                    self.phaser0.set_led(led, state)
                    assert self.phaser0.get_led(led) is state
                    delay(100 * ms)

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Steps (Choose relevant, delete irrelevant before submitting)

All Pull Requests

  • Use correct spelling and grammar.
  • Update RELEASE_NOTES.rst if there are noteworthy changes, especially if there are changes to existing APIs.
  • Check the copyright situation of your changes and sign off your patches (git commit --signoff, see copyright).

Code Changes

  • Run flake8 to check code style (follow PEP-8 style). flake8 has issues with parsing Migen/gateware code, ignore as necessary.
  • Test your changes or have someone test them. Mention what was tested and how.
  • Add and check docstrings and comments

Git Logistics

  • Split your contribution into logically separate changes (git rebase --interactive). Merge/squash/fixup commits that just fix or amend previous commits. Remove unintended changes & cleanup. See tutorial.
  • Write short & meaningful commit messages. Review each commit for messages (git show). Format:
    topic: description. < 50 characters total.
    
    Longer description. < 70 characters per line
    

Licensing

See copyright & licensing for more info.
ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited and are licensed under LGPLv3+.

: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.

@sbourdeauducq
Copy link
Member

This is not consistent with Zotino, which does not have such functions.
https://github.com/m-labs/artiq/blob/master/artiq/coredevice/zotino.py#L45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants