control for DAC AD5384 for the SOLID SM1 Slow Control
Diff: AD5384.h
- Revision:
- 4:bc9ab300ab26
- Parent:
- 3:7ca85ed310e0
--- a/AD5384.h Wed Oct 08 10:43:18 2014 +0000 +++ b/AD5384.h Thu Oct 23 17:14:58 2014 +0000 @@ -5,7 +5,7 @@ #include "SWSPI.h" #include "getVersion.h" -#define VERSION_AD5384_HDR "1.20" +#define VERSION_AD5384_HDR "1.30" /* @@ -16,6 +16,8 @@ * v1.10 initial release versioni * v1.11 added init1 init2 * v1.20 added rst pin + * v1.24 added update shadow registers + * v1.30 added get volt */ class SWSPI; #include "mbed.h" @@ -32,10 +34,15 @@ u32 format_word(u8 mode,u8 ch,u8 rw,u16 data) ; u16 get_reg(u8 mode, u8 ch ); u32 set_reg(u8 mode,u8 ch, u16 value ); + + void update_gain_shadow(u8 ch ) ; + void update_offset_shadow(u8 ch ) ; + void update_dac_shadow(u8 ch ); + public: AD5384(SWSPI *spiinterface ,DigitalOut* chipselect,DigitalOut* reset ); - - u16 dac[40]; + // channel shadow registers + u16 dacr[40]; u16 gain[40]; u16 offset[40]; float volt[40]; @@ -43,6 +50,9 @@ u16 set_dac( u8 ch, u16 dac); u16 get_ch_out_reg(u8 ch) ; u16 set_volt(u8 nr, float vout ); + // if read all reg the gain and offset register is read + // otherwise the shadow register offset and gain are used + float get_volt(u8 nr, bool readallreg=false ); u16 set_gain(u8 ch, u16 gain ); u16 get_gain(u8 ch ); u16 set_offset(u8 ch, u16 gain);