![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test program to test / develop the SOLID slow control
Dependencies: AD5384 SWSPI S25FL216K S_SCTRL_SMlib T_adt7320 adc_ad9249 sscm_comm mbed
main.cpp
- Committer:
- wbeaumont
- Date:
- 2014-09-23
- Revision:
- 0:35e1c447c9e8
- Child:
- 2:51bbbc3fc8c2
File content as of revision 0:35e1c447c9e8:
#include "mbed.h" #include "mbed.h" #include "SWSPI.h" #include "SWSPI_BI.h" #include "S25FL216K.h" #include "AD5384.h" #include "AD9249.h" #include "S_SCTRL_SM1_PinDef.h" #include "S_SCTRL_SM1_hwfunct.h" #define VERSION 1 #define SUBVERSION 3 #define DEBUGPF(x) printf((x)); // pin function pin id // SPI 1 S25FL216K flash(F_MOSI, F_MISO, F_SCLK,F_CS); Serial pc(USBTX,USBRX); char c='.'; void callback() { // Note: you need to actually read from the serial to clear the RX interrupt c = pc.getc(); printf("%c:",c ); } //++++++++++++++++++++++ int main() { pc.attach(&callback);// handles the input on the RS232 interface HWlines hwl ; assignports( &hwl ); setdefault(hwl ); SWSPI spi(hwl.mosi[0],hwl.miso[0],hwl.sclk[0]); // mosi, miso, sclk SWSPI spi2(hwl.mosi[1],hwl.miso[1],hwl.sclk[1]); // mosi, miso, sclk SWSPI_BI spi_adc(hwl.msio[0],hwl.direction[0],hwl.stio_mo[0] ,hwl.sclk[0]); // msio, dir , sclk SWSPI_BI spi_adc2(hwl.msio[1],hwl.direction[1],hwl.stio_mo[1],hwl.sclk[1]); // msio, dir , sclk AD9249 adc[2][2]={AD9249( &spi_adc,hwl.csb1[0]), AD9249( &spi_adc,hwl.csb2[0]), AD9249( &spi_adc2,hwl.csb1[1]), AD9249 ( &spi_adc2,hwl.csb2[1])}; AD5384 dac[2]={AD5384(&spi,hwl.dac_cs[0]), AD5384(&spi2,hwl.dac_cs[1]) }; //float humi; DEBUGPF("start"); printf(" version %d.%02d compiled %s %s \n\r" , VERSION , SUBVERSION, __DATE__, __TIME__ ); printf(" boardserialnr %d \n\r", get_serialnr(&hwl)); u8 consel1=0; u8 consel2=1; u8 conls=0, conle=0; // connector select loop start , connector select loop stop // cc == connector counter if( consel1==1 && consel2== 0) { conls=0; conle=1;} // only first connector connected else if( consel1==0 && consel2== 1) { conls=1; conle=2;} // only second connector connected else if( consel1==1 && consel2== 1) { conls=0; conle=2;} // else { conls=0; conle=0;} // no connectors connected unsigned char id, grade ; /* for (u8 cc= conls; cc < conle ; cc++) { adc[cc][0].getDevInfo(id,grade);printf(" %d %d ",id, grade); adc[cc][1].getDevInfo(id,grade);printf(" %d %d ",id, grade); }*/ u32 count =0; while(1) { for (u8 cc= conls; cc < conle ; cc++) { u16 rb,rb2; adc[cc][0].getDevId(id); adc[cc][0].getGrade(grade); //adc[cc][0].getDevInfo(id,grade,rb); printf("id %02X grade %02X",id, grade ); printf("\n\r"); adc[cc][0].setPattern1(0x1235); adc[cc][0].setPattern2(0xA5FF); adc[cc][0].readPattern1(rb); adc[cc][0].readPattern2(rb2); printf("pattern1 %04X pattern2 %04X",rb,rb2); printf("\n\r"); // dac[cc].set_volt(count%32,count%163834); } wait(.5);count++; /* DEBUGPF("spi2\n\r"); spi.format(8, 0); spi.frequency(10000000); cs.write(0); spi.write(0x9f); jedecid = (spi.write(0) << 16) | (spi.write(0) << 8) | spi.write(0); cs.write(1); printf( "Jedec %d /n/r", jedecid); DEBUGPF("spi3\n\r"); spi_adc.format(8,0); spi_adc.frequency(10000000); cs_adc.write(0); spi_adc.write(0x9f); jedecid = (spi_adc.write(0) << 16) | (spi_adc.write(0) << 8) | spi_adc.write(0); cs_adc.write(1); char c=0x12; flash.write(0,&c,1); DEBUGPF("dacset"); (void) dac.set_dac(4,2.21); humi=ain1.read(); printf("humid %f \n ",humi); */ } }