forked from M-Labs/artiq-zynq
cxp coredevice driver: init
This commit is contained in:
parent
4f9f90adbf
commit
b471db8567
|
@ -0,0 +1,58 @@
|
|||
"""
|
||||
Non-realtime drivers for CXP.
|
||||
"""
|
||||
|
||||
# TODO: add api calls for CTRL packet similar i2c
|
||||
# TODO: add timing critical trigger ack
|
||||
|
||||
|
||||
from artiq.language.core import syscall, kernel
|
||||
from artiq.language.types import TBool, TInt32, TNone
|
||||
from artiq.coredevice.rtio import rtio_output
|
||||
from artiq.experiment import *
|
||||
|
||||
|
||||
class CoaXPress:
|
||||
def __init__(self, channel, core_device="core"):
|
||||
# __device_mgr is private
|
||||
# self.core = dmgr.get(core_device)
|
||||
|
||||
# you can get the channel via `print(len(rtio_channels))` before calling
|
||||
# `rtio_channels.append(rtio.Channel.from_phy(cxp_interface))`
|
||||
self.channel = channel
|
||||
# the first 8 bits is reserved for the rtlink.OInterface.addr not for channel no.
|
||||
self.target_o = channel << 8
|
||||
|
||||
@staticmethod
|
||||
def get_rtio_channels(channel, **kwargs):
|
||||
return [(channel, None)]
|
||||
|
||||
@kernel
|
||||
def trigger(self, linktrig, trigdelay):
|
||||
rtio_output(self.target_o, linktrig | trigdelay << 1)
|
||||
|
||||
|
||||
@syscall(flags={"nounwind", "nowrite"})
|
||||
def cxp_readu32(channel: TInt32, addr: TInt32) -> TNone:
|
||||
raise NotImplementedError("syscall not simulated")
|
||||
|
||||
@syscall(flags={"nounwind", "nowrite"})
|
||||
def cxp_writeu32(channel: TInt32, addr: TInt32, val: TInt32) -> TNone:
|
||||
raise NotImplementedError("syscall not simulated")
|
||||
|
||||
|
||||
|
||||
class IdleKernel(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.setattr_device("led0")
|
||||
|
||||
# declare the class before using it in kernel
|
||||
self.cxp = CoaXPress(0x0)
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
# cxp_readu32(0, 3)
|
||||
# cxp_writeu32(0, 0, 0xABCD)
|
||||
self.cxp.trigger(1, 10)
|
Loading…
Reference in New Issue