Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
AD7390.cpp
00001 # include "AD7390.h" 00002 #include "mbed.h" 00003 00004 AD7390::AD7390(SPI& _spi, PinName resetpin, PinName latchpin) : //Mosi, sclk 2x digital out refV 00005 spi(_spi),reset(resetpin), latch(latchpin){ 00006 } 00007 void AD7390::Init(int Frequency) 00008 { 00009 //Vout = (Vref*D)/2^n 00010 spi.frequency(Frequency); 00011 spi.format(12,0); 00012 latch = 1; 00013 reset = 0; 00014 reset = 1; 00015 } 00016 00017 void AD7390::Reset() 00018 { 00019 reset = 0; 00020 reset = 1; 00021 } 00022 void AD7390::Latch() 00023 { 00024 latch = 0; 00025 latch = 1; 00026 } 00027 void AD7390::Write(float Volts, float RefV) //write will require seperate latch after 00028 { 00029 unsigned int send = 0x0000; 00030 send = (unsigned int) (4096/RefV)*Volts; 00031 spi.write(send); 00032 } 00033 void AD7390::WriteL(float volts, float RefV) //Same as write but with latch attached 00034 { 00035 unsigned int Send = 0x0000; 00036 Send = (unsigned int) (4096/RefV)*volts; //parse float into unsigned int to send to DAC 00037 spi.write(Send); 00038 latch = 0; 00039 latch = 1; 00040 } 00041 00042 00043 00044
Generated on Thu Jul 14 2022 20:50:24 by
1.7.2