Class for AD7390, a 12 bit SPI driven external DAC from Analog Devices.

Dependencies:   mbed

Datasheet - http://www.analog.com/static/imported-files/data_sheets/AD7390_7391.pdf

Committer:
cassar10
Date:
Sat Apr 05 19:08:44 2014 +0000
Revision:
0:82cd70f9fc3f
Child:
1:19818c103c9c
Class looks to be set up. Need to test and set up a conversion to get correct voltage out.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cassar10 0:82cd70f9fc3f 1 # include "AD7390.h"
cassar10 0:82cd70f9fc3f 2
cassar10 0:82cd70f9fc3f 3 AD7390::AD7390(PinName data, PinName clock, PinName resetpin, PinName latchpin, float RefV) : //Mosi, sclk 2x digital out refV
cassar10 0:82cd70f9fc3f 4 reset(resetpin), latch(latchpin), spi(data, NC, clock)
cassar10 0:82cd70f9fc3f 5 {
cassar10 0:82cd70f9fc3f 6 //Vout = (Vref*D)/2^n
cassar10 0:82cd70f9fc3f 7 spi.format(12,0);
cassar10 0:82cd70f9fc3f 8 latch = 1; //Pull low to pass shift register to DAC register
cassar10 0:82cd70f9fc3f 9 reset = 1; //Pull low to reset
cassar10 0:82cd70f9fc3f 10 }
cassar10 0:82cd70f9fc3f 11
cassar10 0:82cd70f9fc3f 12 void AD7390::Reset() //Reset ADC to 0V by pulling reset pin low
cassar10 0:82cd70f9fc3f 13 {
cassar10 0:82cd70f9fc3f 14 reset = 0;
cassar10 0:82cd70f9fc3f 15 wait_us(25);
cassar10 0:82cd70f9fc3f 16 reset = 1; //Set back to high so it can be written to again
cassar10 0:82cd70f9fc3f 17 }
cassar10 0:82cd70f9fc3f 18 void AD7390::Latch() //Latch data from shift register to DAC
cassar10 0:82cd70f9fc3f 19 {
cassar10 0:82cd70f9fc3f 20 latch = 0;
cassar10 0:82cd70f9fc3f 21 wait_us(25);
cassar10 0:82cd70f9fc3f 22 latch = 1;
cassar10 0:82cd70f9fc3f 23 }
cassar10 0:82cd70f9fc3f 24