Sold slow control/
Fork of S_SCTRL_SMlib by
Revision 11:05bc1c823bc4, committed 2014-10-07
- Comitter:
- NickRyder
- Date:
- Tue Oct 07 21:30:56 2014 +0000
- Parent:
- 10:1cae1504a800
- Commit message:
- Tidying up.
Changed in this revision
S_SCTRL_SM1_hwfunct.cpp | Show annotated file Show diff for this revision Revisions of this file |
S_SCTRL_SM1_hwfunct.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1cae1504a800 -r 05bc1c823bc4 S_SCTRL_SM1_hwfunct.cpp --- a/S_SCTRL_SM1_hwfunct.cpp Sun Oct 05 17:11:18 2014 +0000 +++ b/S_SCTRL_SM1_hwfunct.cpp Tue Oct 07 21:30:56 2014 +0000 @@ -15,95 +15,91 @@ #define MAXLIBVERCHAR 100 // max char for lib version -void assignports(HWlines *hwlines ){ +void assignports(HWlines *hwlines ) { -/// devices -// SPI BI pins -hwlines->msio[0] = new DigitalInOut(ADC_STIO); -hwlines->sclk[0] = new DigitalOut(SCLK); -hwlines->direction[0] = new DigitalOut(DIRECTION); -hwlines->stio_mo[0] = new DigitalOut(STIO_MO); -hwlines->csb1[0] = new DigitalOut(ADC1_CSN); -hwlines->csb2[0] = new DigitalOut(ADC2_CSN); + /// devices + // SPI BI pins + hwlines->msio[0] = new DigitalInOut(ADC_STIO); + hwlines->sclk[0] = new DigitalOut(SCLK); + hwlines->direction[0] = new DigitalOut(DIRECTION); + hwlines->stio_mo[0] = new DigitalOut(STIO_MO); + hwlines->csb1[0] = new DigitalOut(ADC1_CSN); + hwlines->csb2[0] = new DigitalOut(ADC2_CSN); - + // SPI pins + hwlines->mosi[0] = new DigitalOut(MOSI); + hwlines->miso[0] = new DigitalIn(MISO); -// SPI pins -hwlines->mosi[0] = new DigitalOut(MOSI); -hwlines->miso[0] = new DigitalIn(MISO); + hwlines->t_cs[0] = new DigitalOut(TEMP_CSN); + hwlines->tc_cs1[0] = new DigitalOut(TEMP_CABLE_CSN1); + hwlines->tc_cs2[0] = new DigitalOut(TEMP_CABLE_CSN2); + hwlines->dac_cs[0] = new DigitalOut(DAC_DCEN); + hwlines->dac_rst[0] = new DigitalOut(DAC_RSTN); + + // devices -hwlines->t_cs[0] = new DigitalOut(TEMP_CSN); -hwlines->tc_cs1[0] = new DigitalOut(TEMP_CABLE_CSN1); -hwlines->tc_cs2[0] = new DigitalOut(TEMP_CABLE_CSN2); -hwlines->dac_cs[0] = new DigitalOut(DAC_DCEN); -hwlines->dac_rst[0] = new DigitalOut(DAC_RSTN); - - - + // SPI BI pins + hwlines->msio[1] = new DigitalInOut(ADC_2_STIO); + hwlines->sclk[1] = new DigitalOut(SCLK_2); + hwlines->direction[1] = new DigitalOut(DIRECTION2); + hwlines->stio_mo[1] = new DigitalOut(STIO2_MO); + hwlines->csb1[1] = new DigitalOut(ADC1_2_CSN); + hwlines->csb2[1] = new DigitalOut(ADC2_2_CSN); -// devices -// SPI BI pins -hwlines->msio[1] = new DigitalInOut(ADC_2_STIO); -hwlines->sclk[1] = new DigitalOut(SCLK_2); -hwlines->direction[1] = new DigitalOut(DIRECTION2); -hwlines->stio_mo[1] = new DigitalOut(STIO2_MO); -hwlines->csb1[1] = new DigitalOut(ADC1_2_CSN); -hwlines->csb2[1] = new DigitalOut(ADC2_2_CSN); + // SPI pins + hwlines->mosi[1] = new DigitalOut(MOSI_2); + hwlines->miso[1] = new DigitalIn(MISO_2); -// SPI pins -hwlines->mosi[1] = new DigitalOut(MOSI_2); -hwlines->miso[1] = new DigitalIn(MISO_2); - -hwlines->t_cs[1] = new DigitalOut(TEMP_2_CSN); -hwlines->tc_cs1[1] = new DigitalOut(TEMP_2_CABLE_CSN1); -hwlines->tc_cs2[1] = new DigitalOut(TEMP_2_CABLE_CSN2); -hwlines->dac_cs[1] = new DigitalOut(DAC_2_DCEN); -hwlines->dac_rst[1] = new DigitalOut(DAC_2_RSTN); - + hwlines->t_cs[1] = new DigitalOut(TEMP_2_CSN); + hwlines->tc_cs1[1] = new DigitalOut(TEMP_2_CABLE_CSN1); + hwlines->tc_cs2[1] = new DigitalOut(TEMP_2_CABLE_CSN2); + hwlines->dac_cs[1] = new DigitalOut(DAC_2_DCEN); + hwlines->dac_rst[1] = new DigitalOut(DAC_2_RSTN); -//cal -hwlines->cal13[0] = new DigitalOut(CAL_TRIG_1AND3); -hwlines->cal24[0] = new DigitalOut(CAL_TRIG_2AND4); -hwlines->calint[0] = new DigitalOut(SEL_CAL_INT); -hwlines->cal13[1] = new DigitalOut(CAL_TRIG_1AND3); -hwlines->cal24[1] = new DigitalOut(CAL_TRIG_2AND4); -hwlines->calint[1] = new DigitalOut(SEL_2_CAL_INT); + //cal + hwlines->cal13[0] = new DigitalOut(CAL_TRIG_1AND3); + hwlines->cal24[0] = new DigitalOut(CAL_TRIG_2AND4); + hwlines->calint[0] = new DigitalOut(SEL_CAL_INT); + hwlines->cal13[1] = new DigitalOut(CAL_TRIG_1AND3); + hwlines->cal24[1] = new DigitalOut(CAL_TRIG_2AND4); + hwlines->calint[1] = new DigitalOut(SEL_2_CAL_INT); -hwlines->calext = new DigitalOut(SEL_CAL_EXT); -hwlines->calgenext = new DigitalOut(GEN_EXT_CAL); + hwlines->calext = new DigitalOut(SEL_CAL_EXT); + hwlines->calgenext = new DigitalOut(GEN_EXT_CAL); -hwlines->ledred = new DigitalOut(LEDRED); -hwlines->ledgreen = new DigitalOut(LEDGREEN); + hwlines->ledred = new DigitalOut(LEDRED); + hwlines->ledgreen = new DigitalOut(LEDGREEN); -hwlines->ain[0] = new AnalogIn(ADC1); -hwlines->ain[1] = new AnalogIn(ADC2); + hwlines->ain[0] = new AnalogIn(ADC1); + hwlines->ain[1] = new AnalogIn(ADC2); -hwlines->snr[0] = new DigitalIn(AD0); -hwlines->snr[1] = new DigitalIn(AD1); -hwlines->snr[2] = new DigitalIn(AD2); -hwlines->snr[3] = new DigitalIn(AD3); -hwlines->snr[4] = new DigitalIn(AD4); + hwlines->snr[0] = new DigitalIn(AD0); + hwlines->snr[1] = new DigitalIn(AD1); + hwlines->snr[2] = new DigitalIn(AD2); + hwlines->snr[3] = new DigitalIn(AD3); + hwlines->snr[4] = new DigitalIn(AD4); } - - // select intern or extern cal 0 = intern, 1 is extern -void setcalsource( int external, HWlines hwl) { - *(hwl.calext)=0; - *(hwl.calint[0])=0; *(hwl.calint[1])=0; //disable all - if ( external==1 ) {*(hwl.calext)=1; } - else {*(hwl.calint[0])=1; *(hwl.calint[1])=1; } - - +void setcalsource(int external, HWlines hwl) { + *(hwl.calext) = 0; + *(hwl.calint[0]) = 0; + *(hwl.calint[1]) = 0; //disable all + if (external == 1) { + *(hwl.calext) = 1; + } else { + *(hwl.calint[0]) = 1; + *(hwl.calint[1]) = 1; + } } // set the default , save values -void setdefault(HWlines hwl ) { - for ( int i=0;i<2;i++){ +void setdefault(HWlines hwl) { + for (int i = 0; i < 2; i++) { hwl.msio[i]->input(); - *(hwl.direction[i])=RDIR_IN; - *(hwl.stio_mo[i])=LDIR_IN; + *(hwl.direction[i]) = RDIR_IN; + *(hwl.stio_mo[i]) = LDIR_IN; hwl.sclk[i]->write(0); hwl.csb1[i]->write(0); hwl.csb2[i]->write(0); @@ -113,43 +109,39 @@ hwl.dac_cs[i]->write(0); hwl.dac_rst[i]->write(0); } - setcalsource(0,hwl); //intern + setcalsource(0, hwl); //intern } -void set_bi_spi_mo(int masterout, DigitalInOut* msio, DigitalOut* ldir, DigitalOut* rdir){ - // default directions - if( masterout == 0 ) { // master in - msio->input(); - rdir->write(RDIR_IN); - ldir->write(LDIR_IN); - - } - else { //master out - +void set_bi_spi_mo(int masterout, DigitalInOut * msio, DigitalOut * ldir, + DigitalOut * rdir) { + // default directions + if (masterout == 0) { // master in + msio->input(); + rdir->write(RDIR_IN); + ldir->write(LDIR_IN); + } else { //master out ldir->write(LDIR_OUT); msio->output(); rdir->write(RDIR_OUT); } } - - -char libversion[MAXLIBVERCHAR]={'e','m','p','t','y','\0'}; - +char libversion[MAXLIBVERCHAR] = {'e', 'm', 'p', 't', 'y', '\0'}; -char* hwfunct_lib_version(){ - sprintf(libversion,"hw lib versions src : %s header: %s pindef %s,date:%s %s \n\r", - HW_LIB_SRC_VERSION,HW_LIB_HDR_VERSION , PINDEF_VER, __DATE__,__TIME__); +char * hwfunct_lib_version() { + sprintf(libversion, + "hw lib versions src : %s header: %s pindef %s,date:%s %s \n\r", + HW_LIB_SRC_VERSION, HW_LIB_HDR_VERSION, PINDEF_VER, __DATE__, + __TIME__); return libversion; - } -int get_serialnr(HWlines *hwlines ){ - int snr=0; - for( int bitnr=4 ; bitnr >= 0 ;bitnr--){ - snr=snr<<1; - snr|=hwlines->snr[bitnr]->read(); +int get_serialnr(HWlines * hwlines) { + int snr = 0; + for (int bitnr = 4; bitnr >= 0; bitnr--) { + snr = snr << 1; + snr |= hwlines->snr[bitnr]->read(); } return snr; -} +} \ No newline at end of file
diff -r 1cae1504a800 -r 05bc1c823bc4 S_SCTRL_SM1_hwfunct.h --- a/S_SCTRL_SM1_hwfunct.h Sun Oct 05 17:11:18 2014 +0000 +++ b/S_SCTRL_SM1_hwfunct.h Tue Oct 07 21:30:56 2014 +0000 @@ -12,46 +12,45 @@ */ typedef struct { -// BI-SPI -DigitalInOut* msio[2]; -DigitalOut* sclk[2]; -DigitalOut* direction[2]; -DigitalOut* stio_mo[2]; -DigitalOut* csb1[2]; -DigitalOut* csb2[2]; - -// SPI pins -DigitalOut* mosi[2]; -DigitalIn* miso[2]; -DigitalOut* t_cs[2]; -DigitalOut* tc_cs1[2]; -DigitalOut* tc_cs2[2]; -DigitalOut* dac_cs[2]; -DigitalOut* dac_rst[2]; + // BI-SPI + DigitalInOut * msio[2]; + DigitalOut * sclk[2]; + DigitalOut * direction[2]; + DigitalOut * stio_mo[2]; + DigitalOut * csb1[2]; + DigitalOut * csb2[2]; -//cal -DigitalOut* cal13[2]; // physical the same so will point to the same port -DigitalOut* cal24[2]; // physical the same so will point to the same port -DigitalOut* calint[2]; -// not related to connector 1 /2 -DigitalOut* calext; -DigitalOut* calgenext; + // SPI pins + DigitalOut * mosi[2]; + DigitalIn * miso[2]; + DigitalOut * t_cs[2]; + DigitalOut * tc_cs1[2]; + DigitalOut * tc_cs2[2]; + DigitalOut * dac_cs[2]; + DigitalOut * dac_rst[2]; -DigitalOut* ledred; -DigitalOut* ledgreen; + //cal + DigitalOut * cal13[2]; // physical the same so will point to the same port + DigitalOut * cal24[2]; // physical the same so will point to the same port + DigitalOut * calint[2]; + // not related to connector 1 /2 + DigitalOut * calext; + DigitalOut * calgenext; -DigitalIn* snr[5]; - + DigitalOut * ledred; + DigitalOut * ledgreen; + DigitalIn * snr[5]; -AnalogIn* ain[2]; + AnalogIn * ain[2]; } HWlines; -void assignports(HWlines *hwlines ); -void setcalsource( int extcal, HWlines hwl); -void set_bi_spi_mo(int masterout, DigitalInOut* msio, DigitalOut* ldir, DigitalOut* rdir); -void setdefault(HWlines hwl ) ; -char* hwfunct_lib_version(); // returns this lib version info -int get_serialnr(HWlines *hwlines ); // get the electronic serial nr of the board - +void assignports(HWlines * hwlines); +void setcalsource(int extcal, HWlines hwl); +void set_bi_spi_mo(int masterout, DigitalInOut * msio, DigitalOut * ldir, + DigitalOut * rdir); +void setdefault(HWlines hwl); +char * hwfunct_lib_version(); // returns this lib version info +int get_serialnr(HWlines * hwlines); // get the electronic serial nr of the board + #endif \ No newline at end of file