Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Production Test Suite - base
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Production Test Suite - base
Commits
7848b484
Commit
7848b484
authored
May 03, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change API and add license and comment to max5442 module.
-> more generic function name.
parent
5978688f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
max5442.py
common/max5442.py
+20
-9
No files found.
common/max5442.py
View file @
7848b484
#!/usr/bin/python
#! /usr/bin/env python
# coding: utf8
# Copyright CERN, 2011
# Author: Matthieu Cattin (CERN)
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 03/05/2012
# Import standard modules
import
sys
import
rr
import
time
# Import specific modules
import
rr
import
spi
import
csr
class
CMAX5442
:
# Class to access the MAX5442 (DAC) chip.
# It uses the SPI class.
class
CMAX5442
:
def
__init__
(
self
,
spi
,
slave
):
self
.
spi
=
spi
self
.
slave
=
slave
#
offset = value to write to the DAC
(2 bytes)
def
set_
offset
(
self
,
offset
):
tx
=
[(
offset
&
0xFF
),
((
offset
&
0xFF00
)
>>
8
)]
#print
('[max5442] Set offset: %.4X') % offset
#
value = DAC digital value
(2 bytes)
def
set_
value
(
self
,
value
):
tx
=
[(
value
&
0xFF
),
((
value
&
0xFF00
)
>>
8
)]
#print
'[max5442] Value to set: %.4X' % value
#for i in range(len(tx)):
# print
('[max5442] tx[%d]: %.2X')
%(i, tx[i])
# print
'[max5442] tx[%d]: %.2X'
%(i, tx[i])
self
.
spi
.
transaction
(
self
.
slave
,
tx
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment