Sold slow control/
Fork of S_SCTRL_SMlib by
Diff: S_SCTRL_SM1_hwfunct.cpp
- Revision:
- 0:8d755a0f3ab3
- Child:
- 1:af78e316f889
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/S_SCTRL_SM1_hwfunct.cpp Sun Sep 07 14:39:32 2014 +0000 @@ -0,0 +1,94 @@ +/* hardware functions */ +#include "mbed.h" +#include "S_SCTRL_SM1_PinDef.h" +#include "S_CTRL_SM1_hwfunct.h" + +HWlines hwlines; + +void assignports( ){ + +/// 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_1[0] = new DigitalOut(ADC1_CSN); +hwlines.csb2_1[0] = new DigitalOut(ADC2_CSN); + + + +// 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 +// SPI BI pins +hwlines.msio[1] = new DigitalInOut(ADC_2_STIO); +hwlines.sclk[1] = new DigitalOut(SCLK2); +hwlines.direction[1] = new DigitalOut(DIRECTION2); +hwlines.stio_mo[1] = new DigitalOut(STIO2_MO); +hwlines.csb1_1[1] = new DigitalOut(ADC1_2_CSN); +hwlines.csb2_1[1] = new DigitalOut(ADC2_2_CSN); + +// 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); + + +//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_CAL_INT_2); + +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.ain1 = new AnalogIn(ADC1); +hwlines.ain2 = new AnalogIn(ADC2); + + +} + + + +// select intern or extern cal 0 = intern, 1 is extern +void setcalsource( int extcal, HWlines hwl) { + *(hwl.calext)=0; *(hwl.calint[0])=0; *(hwl.calint[0])=0; //disable all + if ( external==1 ) {*(hwl.calext)=1; } + else {*(hwl.calint[0])=1; *(hwl.calint[0])=1; } + + +} + +// set tje default , save values +void setdefault(HWlines hwl ) { + for ( int i=0;i<2;i++){ + hwl.msio[i]->input(); + *(hwl.direction[i])=LDIR_IN; + *(hwl.stio_mo[i])=RDIR_IN + } + setcalsource(0,hwlines); //intern +} +