Commit 7848b484 authored by Matthieu Cattin's avatar Matthieu Cattin

Change API and add license and comment to max5442 module.

-> more generic function name.
parent 5978688f
#!/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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment