![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
firmware for the SOLID Slow Control Module for SM1
Dependencies: S_SCTRL_SMlib adc_ad9249 mbed sscm_comm AD5384 SWSPI T_adt7320
Diff: main.cpp
- Revision:
- 8:03f20aed4214
- Parent:
- 7:5f8abd383a7d
- Child:
- 9:20fc5a795ec4
--- a/main.cpp Wed Nov 19 23:18:18 2014 +0000 +++ b/main.cpp Sun Dec 07 22:39:10 2014 +0000 @@ -22,10 +22,11 @@ * v 1.65 added heartbeat on / off, added set cal level * v 1.66 implemented real temperature readout * v 1.70 implemented set_volt and get_volt commands - * v 1.72 implemented setbias , get bias volt + * v 1.72 implemented setbias , get bias volt dummy + * v 1.73 implemented setbias , get bias volt via Deimos32 class */ -#define VERSION "1.72" +#define VERSION "1.73" #include "SWSPI_BI.h" @@ -100,7 +101,7 @@ adt7320 temp[2][3]= { adt7320(&spi, hwl.t_cs[0]),adt7320(&spi, hwl.tc_cs1[0]),adt7320(&spi, hwl.tc_cs2[0]), adt7320(&spi2, hwl.t_cs[1]),adt7320(&spi2, hwl.tc_cs1[1]),adt7320(&spi2, hwl.tc_cs2[1]) }; - + Deimos32* deimos[2] = { 0,0}; pc.printf("\nSOLID SLOW CONTROL for SM1 version %s %s %s \n\r",VERSION,__DATE__,__TIME__ ); @@ -164,14 +165,26 @@ // set output register bias channel if (!strcmp( cmd.cmd, "sbid")) { cmd.ch=DACBIASCH;dac[cmd.con-1][cmd.devnr-1].set_dac(cmd.ch-1,cmd.datain);cmd.dataout=cmd.datain;cmd.status=0;goto DACENDCMD;} if (!strcmp( cmd.cmd, "gbid")) {cmd.ch=DACBIASCH;do16=dac[cmd.con-1][cmd.devnr-1].get_dac(cmd.ch-1);cmd.dataout=do16;cmd.status=0;goto DACENDCMD;} + if (!strcmp( cmd.cmd, "inhv")) { + if(cmd.con== 0) {cmd.status=100;goto DACENDCMD;} // can not be broadcast ;} + if(cmd.con > 2) {cmd.status=101;goto DACENDCMD;} + float hvnom=u162float( cmd.dataout , cmd.datain); + deimos[cmd.con-1]= new Deimos32(hvnom ,cmd.con-1,&dac[cmd.con-1][cmd.devnr-1]); + cmd.status=0;goto DACENDCMD; + } if (!strcmp( cmd.cmd, "sbia")) { - float biasvolt= u162float( cmd.dataout , cmd.datain); biasvolt=Bias2Dac(biasvolt); - cmd.ch=DACBIASCH; - dac[cmd.con-1][cmd.devnr-1].set_volt(cmd.ch-1,biasvolt);cmd.dataout=cmd.datain;cmd.status=0;goto DACENDCMD; + float biasvolt= u162float( cmd.dataout , cmd.datain); + u8 strtcnt=0; u8 stpcnt=2; + if (cmd.con ==1) stpcnt=1; + if (cmd.con ==2) strtcnt=1; // else it is assumed to be 9 + float retvalue=0; + for ( u8 bcnt=strtcnt ; bcnt < stpcnt; bcnt++) retvalue=-deimos[bcnt]->setHV(biasvolt); + cmd.status=u8(retvalue);goto DACENDCMD; } if (!strcmp( cmd.cmd, "gbia")) { - cmd.ch=DACBIASCH; - float volt=dac[cmd.con-1][cmd.devnr-1].get_volt(cmd.ch-1); + if ( cmd.con ==0 ) cmd.con=1; + + float volt=deimos[cmd.con-1]->getHv(); float2_2u16( volt , cmd.dataout , cmd.datain); cmd.status=0;goto DACENDCMD; }