Skip to content

Commit

Permalink
Add analog devices python for LLRF
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdewart committed Jul 24, 2019
1 parent 441a141 commit 4687f43
Show file tree
Hide file tree
Showing 4 changed files with 322 additions and 2 deletions.
143 changes: 143 additions & 0 deletions python/surf/devices/analog_devices/_Ad5541.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Title : PyRogue _ad5541 Module
#-----------------------------------------------------------------------------
# File : _ad5541.py
# Created : 2017-01-17
# Last update: 2017-01-17
#-----------------------------------------------------------------------------
# Description:
# PyRogue _ad5541 Module
#-----------------------------------------------------------------------------
# This file is part of 'SLAC Firmware Standard Library'.
# It is subject to the license terms in the LICENSE.txt file found in the
# top-level directory of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of 'SLAC Firmware Standard Library', including this file,
# may be copied, modified, propagated, or distributed except according to
# the terms contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------

import pyrogue as pr

class Ad5541(pr.Device):
def __init__(self,
name = "Ad5541",
description = "Ad5541",
**kwargs):
super().__init__(name=name, description=description, **kwargs)

self.add(pr.RemoteVariable(
name = 'dacRefreshRate',
description = 'DAC Rate (in units of Hz)',
offset = 0x040,
bitSize = 32,
bitOffset = 0,
base = pr.UInt,
mode = 'RO',
))

self.add(pr.RemoteVariable(
name = 'dacData',
description = 'DAC Data',
offset = 0x0C0,
bitSize = 18,
bitOffset = 0,
base = pr.UInt,
mode = 'RO',
))

self.add(pr.RemoteVariable(
name = 'debugMux',
description = 'debugMux',
offset = 0x200,
bitSize = 1,
bitOffset = 0,
base = pr.Bool,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'debugData',
description = 'debugData',
offset = 0x240,
bitSize = 18,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'sdoDisable',
description = 'sdoDisable',
offset = 0x280,
bitSize = 1,
bitOffset = 0,
base = pr.Bool,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'binaryOffset',
description = 'binaryOffset',
offset = 0x284,
bitSize = 1,
bitOffset = 0,
base = pr.Bool,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'dacTriState',
description = 'dacTriState',
offset = 0x288,
bitSize = 1,
bitOffset = 0,
base = pr.Bool,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'opGnd',
description = 'opGnd',
offset = 0x28C,
bitSize = 1,
bitOffset = 0,
base = pr.Bool,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'rbuf',
description = 'rbuf',
offset = 0x290,
bitSize = 1,
bitOffset = 0,
base = pr.Bool,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'halfSckPeriod',
description = 'halfSckPeriod',
offset = 0x294,
bitSize = 32,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'hrdRst',
description = 'hrdRst',
offset = 0x3F8,
bitSize = 1,
bitOffset = 0,
base = pr.UInt,
mode = 'WO',
hidden = False,
))

def hardReset(self):
self.hrdRst.set(1)

137 changes: 137 additions & 0 deletions python/surf/devices/analog_devices/_Adt7420.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Title : PyRogue Analod Deviced ADT7420
#-----------------------------------------------------------------------------
# File : _Adt7420.py
# Created : 2019-07-17
#-----------------------------------------------------------------------------
# Description:
# Analog devices ADT7420 I2C temperature sensor
#-----------------------------------------------------------------------------
# This file is part of the rogue software platform. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
# of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of the rogue software platform, including this file, may be
# copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------

import pyrogue as pr

class Adt7420(pr.Device):
def __init__(self,
name = "Adt7420",
description = "Adt7420",
**kwargs):
super().__init__(name=name, description=description, **kwargs)

self.add(pr.RemoteVariable(
name = 'TempMSByte',
description = 'Temperature value most significant byte (Byte Address = 0x00: AXI-Lite: 0x00)',
offset = 0x0,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RO',
))

self.add(pr.RemoteVariable(
name = 'TempLSByte',
description = 'Temperature value least significant byte (Byte Address = 0x01: AXI-Lite: 0x04)',
offset = 0x4,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RO',
))

self.add(pr.RemoteVariable(
name = 'Status',
description = 'Status Register (Byte Address = 0x02: AXI-Lite: 0x08)',
offset = 0x8,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RO',
))

self.add(pr.RemoteVariable(
name = 'Config',
description = 'Config Register (Byte Address = 0x03: AXI-Lite: 0x0C)',
offset = 0xC,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'THighMSByte',
description = 'THIGH setpoint most significant byte (Byte Address = 0x04: AXI-Lite: 0x10)',
offset = 0x10,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'THighLSByte',
description = 'THIGH setpoint least significant byte (Byte Address = 0x05: AXI-Lite: 0x14)',
offset = 0x14,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'TLowMSByte',
description = 'TLOW setpoint most significant byte (Byte Address = 0x06: AXI-Lite: 0x18)',
offset = 0x18,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'TLowLSByte',
description = 'TLOW setpoint least significant byte (Byte Address = 0x07: AXI-Lite: 0x1C)',
offset = 0x1C,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'TCritMSByte',
description = 'TCRIT setpoint most significant byte (Byte Address = 0x08: AXI-Lite: 0x20)',
offset = 0x20,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'THyst',
description = 'THYST setpoint (Byte Address = 0x0A: AXI-Lite: 0x28)',
offset = 0x28,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))

self.add(pr.RemoteVariable(
name = 'ID',
description = 'ID Register (Byte Address = 0x0B: AXI-Lite: 0x2C)',
offset = 0x2C,
bitSize = 8,
bitOffset = 0,
base = pr.UInt,
mode = 'RO',
))
38 changes: 38 additions & 0 deletions python/surf/devices/analog_devices/_AttHmc624.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Title : PyRogue _hmc624 Module
#-----------------------------------------------------------------------------
# File : _hmc624.py
# Created : 2019-07-16
# Last update: 2019-07-16
#-----------------------------------------------------------------------------
# Description:
# PyRogue _hmc624 Module
#-----------------------------------------------------------------------------
# This file is part of 'SLAC Firmware Standard Library'.
# It is subject to the license terms in the LICENSE.txt file found in the
# top-level directory of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of 'SLAC Firmware Standard Library', including this file,
# may be copied, modified, propagated, or distributed except according to
# the terms contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------

import pyrogue as pr

class AttHmc624(pr.Device):
def __init__(self,
name = "AttHmc624",
description = "Attenuator Hmc624",
**kwargs):
super().__init__(name=name, description=description, **kwargs)

self.add(pr.RemoteVariable(
name = 'SetValue',
description = 'Attenuation Level Active low: D0-0.5bB D1-1dB D2-2dB D3-4dB D4-8dB D5-16dB',
offset = 0x00,
bitSize = 16,
bitOffset = 0,
base = pr.UInt,
mode = 'RW',
))
6 changes: 4 additions & 2 deletions python/surf/devices/analog_devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
## may be copied, modified, propagated, or distributed except according to
## the terms contained in the LICENSE.txt file.
##############################################################################
from surf.devices.analog_devices._Ad9249 import *
from surf.devices.analog_devices._Ad5780 import *
from surf.devices.analog_devices._Ad9249 import *
from surf.devices.analog_devices._Ad5780 import *
from surf.devices.analog_devices._AttHmc624 import *
from surf.devices.analog_devices._Adt7420 import *

0 comments on commit 4687f43

Please sign in to comment.