diff --git a/include/ad9915.h b/include/ad9915.h index 12c4273..e092a11 100644 --- a/include/ad9915.h +++ b/include/ad9915.h @@ -54,38 +54,38 @@ int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t amp //------------ DRCTL -void Send_CTRL_UP(int fp); -void Send_CTRL_DOWN(int fp); -void Send_HOLD(int fp); -void Send_UNHOLD(int fp); +void sendCtrlUp(int fp); +void SendCtrlDown(int fp); +void SendHold(int fp); +void SendUnhold(int fp); int testRampFreq(int fd, int f_dds, int fp); //-------Profile register mode -int InitialisationProfile (int fd,int f_dds); -int PutFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase); +int initialisationProfileMode (int fd,int f_dds); +int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase); -int PutFrequencyWord(int fd, int f_dds, double freq);//Attention uniquement valable pour fclk = 1 GHz -int PutPhaseWord(int fd, int f_dds, double phase); -int PutAmpWord(int fd, int f_dds, double amplitude); +int putFrequencyWord(int fd, int f_dds,double fclk, double freq); +int putPhaseWord(int fd, int f_dds, double phase); +int putAmpWord(int fd, int f_dds, double amplitude); //fonctions rampes hardwres -int FrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown); -int ContinueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown); -int AmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown); -int ContinueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown); -int PhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown); -int ContinuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown); +int frequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown); +int continueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown); +int amplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown); +int continueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown); +int phaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown); +int continuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown); //fin fonctions rampes hardwares // fonctions rampes softwares -int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFin); +int rampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFin); -int RampPhaseFromSoft(int fd, int f_dds,double DeltaTimeUp,double PhiIni, double PhiFin); +int rampPhaseFromSoft(int fd, int f_dds,double DeltaTimeUp,double PhiIni, double PhiFin); // fin fonctoins rampes softwares diff --git a/src/ad9915.c b/src/ad9915.c index 8b1b9c7..6ed1d6e 100644 --- a/src/ad9915.c +++ b/src/ad9915.c @@ -7,7 +7,7 @@ #define debug //fonction reset -void Send_Reset(int f_dds) +void sendReset(int f_dds) { char reset='2'; write(f_dds,&reset,sizeof(reset)); //reset @@ -15,7 +15,7 @@ void Send_Reset(int f_dds) } //fonction ioupdate -void Send_IO_Update(int f_dds) +void sendIOUpdate(int f_dds) { char update='1'; write(f_dds,&update,sizeof(update)); //reset @@ -23,7 +23,7 @@ void Send_IO_Update(int f_dds) } //fonction write register -void write_register (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0) +void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0) { unsigned char tx[5]={0}; tx[0]=addr; @@ -38,7 +38,7 @@ void write_register (int fd, unsigned char addr, unsigned char d3, unsigned cha //fonction read register -void read_register (int fd,unsigned char addr, uint32_t *readword) +void readRegister (int fd,unsigned char addr, uint32_t *readword) { unsigned char tx[1] = {0}; unsigned char rx[4] = {0}; @@ -54,7 +54,7 @@ void read_register (int fd,unsigned char addr, uint32_t *readword) } //fonction read register -void read_register_ini (int fd, unsigned char addr) +void readRegisterIni (int fd, unsigned char addr) { unsigned char tx[1] = {0}; unsigned char rx[4] = {0}; @@ -62,58 +62,58 @@ void read_register_ini (int fd, unsigned char addr) tx[0]=addr; spi_put_multiple(fd,tx,1,rx,4); printf("TX:%x RX:%x %x %x %x\n",tx[0],rx[0],rx[1],rx[2],rx[3]); - // Send_IO_Update (f_dds); //Send the update to set the control registers + // sendIOUpdate (f_dds); //Send the update to set the control registers } //initialisation du dds -void Initialize_DDS (int fd, int f_dds) +void initializeDDS (int fd, int f_dds) { - Send_Reset(f_dds); - write_register(fd,CFRAddress[0],CFR1Start[0], CFR1Start[1], CFR1Start[2], CFR1Start[3]); - Send_IO_Update (f_dds); //Send the update to set the control registers - write_register(fd,CFRAddress[1], CFR2Start[0], CFR2Start[1], CFR2Start[2], CFR2Start[3]); - Send_IO_Update (f_dds); - write_register(fd,CFRAddress[2], CFR3Start[0], CFR3Start[1], CFR3Start[2], CFR3Start[3]); - Send_IO_Update (f_dds); - write_register(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); - Send_IO_Update (f_dds); - write_register(fd,USR0Address, 0xA2, 0x00, 0x08, 0x00); - Send_IO_Update (f_dds); + sendReset(f_dds); + writeRegister(fd,CFRAddress[0],CFR1Start[0], CFR1Start[1], CFR1Start[2], CFR1Start[3]); + sendIOUpdate (f_dds); //Send the update to set the control registers + writeRegister(fd,CFRAddress[1], CFR2Start[0], CFR2Start[1], CFR2Start[2], CFR2Start[3]); + sendIOUpdate (f_dds); + writeRegister(fd,CFRAddress[2], CFR3Start[0], CFR3Start[1], CFR3Start[2], CFR3Start[3]); + sendIOUpdate (f_dds); + writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); + sendIOUpdate (f_dds); + writeRegister(fd,USR0Address, 0xA2, 0x00, 0x08, 0x00); + sendIOUpdate (f_dds); } //calibration du dac -void Calibrate_DAC (int fd, int f_dds) +void calibrateDAC (int fd, int f_dds) { - write_register(fd,CFRAddress[3], DACCalEnable[0], DACCalEnable[1], DACCalEnable[2], DACCalEnable[3]); - Send_IO_Update (f_dds); - write_register(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); - Send_IO_Update (f_dds); + writeRegister(fd,CFRAddress[3], DACCalEnable[0], DACCalEnable[1], DACCalEnable[2], DACCalEnable[3]); + sendIOUpdate (f_dds); + writeRegister(fd,CFRAddress[3], CFR4Start[0], CFR4Start[1], CFR4Start[2], CFR4Start[3]); + sendIOUpdate (f_dds); } -void modulus_setup(int fd, int f_dds) +void modulusSetup(int fd, int f_dds) { - write_register(fd,0x00,0x00, 0x01, 0x01, 0x0a); //OSK enable //0x08 - //write_register(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable de base - Send_IO_Update (f_dds); - write_register(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp - Send_IO_Update (f_dds); + writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x0a); //OSK enable //0x08 + //writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable de base + sendIOUpdate (f_dds); + writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp + sendIOUpdate (f_dds); } -void basic_setup(int fd, int f_dds,uint16_t ampWord, uint16_t phaseWord) +void basicSetup(int fd, int f_dds,uint16_t ampWord, uint16_t phaseWord) { - write_register(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable - Send_IO_Update (f_dds); - write_register(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp - Send_IO_Update (f_dds); - write_register(fd,0x04,0x19, 0x99, 0x99, 0x99); //ftw - Send_IO_Update (f_dds); - write_register(fd,0x05,0xC0, 0x00, 0x00, 0x00); //A - Send_IO_Update (f_dds); - write_register(fd,0x06,0x00, 0x00, 0x00, 0x05); //B - Send_IO_Update (f_dds); - //write_register(fd,0x0c, 0x0F, 0xFF, 0x00, 0x00); // amp (12b) ph(16) - write_register(fd,0x0c, (uint8_t)((ampWord>>8) & 0x0F), (uint8_t)(ampWord & 0xFF), (uint8_t)((phaseWord>>8) & 0xFF), (uint8_t)(phaseWord & 0xFF)); // amp (12b) ph(16) - Send_IO_Update (f_dds); + writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable + sendIOUpdate (f_dds); + writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp + sendIOUpdate (f_dds); + writeRegister(fd,0x04,0x19, 0x99, 0x99, 0x99); //ftw + sendIOUpdate (f_dds); + writeRegister(fd,0x05,0xC0, 0x00, 0x00, 0x00); //A + sendIOUpdate (f_dds); + writeRegister(fd,0x06,0x00, 0x00, 0x00, 0x05); //B + sendIOUpdate (f_dds); + //writeRegister(fd,0x0c, 0x0F, 0xFF, 0x00, 0x00); // amp (12b) ph(16) + writeRegister(fd,0x0c, (uint8_t)((ampWord>>8) & 0x0F), (uint8_t)(ampWord & 0xFF), (uint8_t)((phaseWord>>8) & 0xFF), (uint8_t)(phaseWord & 0xFF)); // amp (12b) ph(16) + sendIOUpdate (f_dds); } void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B) @@ -123,24 +123,24 @@ void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int //uint16_t ampWord = 0x00000FFF; //uint32_t phaseAmpWord = phaseWord | ampWord<<16; - //write_register(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable - //Send_IO_Update(f_dds); - //write_register(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp - //Send_IO_Update(f_dds); - write_register(fd,0x04,ftw>>24&0xFF, ftw>>16&0xFF, ftw>>8&0xFF, ftw&0xFF); //ftw - Send_IO_Update(f_dds); - write_register(fd,0x05,A>>24&0xFF,A>>16&0xFF, A>>8&0xFF, A&0xFF); //A - Send_IO_Update(f_dds); - write_register(fd,0x06,B>>24&0xFF,B>>16&0xFF, B>>8&0xFF, B&0xFF); //B - Send_IO_Update(f_dds); - // write_register(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16) - //Send_IO_Update(f_dds); + //writeRegister(fd,0x00,0x00, 0x01, 0x01, 0x08); //OSK enable + //sendIOUpdate(f_dds); + //writeRegister(fd,0x01,0x00, 0x89, 0x09, 0x00); //enable program modulus and digital ramp + //sendIOUpdate(f_dds); + writeRegister(fd,0x04,ftw>>24&0xFF, ftw>>16&0xFF, ftw>>8&0xFF, ftw&0xFF); //ftw + sendIOUpdate(f_dds); + writeRegister(fd,0x05,A>>24&0xFF,A>>16&0xFF, A>>8&0xFF, A&0xFF); //A + sendIOUpdate(f_dds); + writeRegister(fd,0x06,B>>24&0xFF,B>>16&0xFF, B>>8&0xFF, B&0xFF); //B + sendIOUpdate(f_dds); + // writeRegister(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16) + //sendIOUpdate(f_dds); } void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord) { - write_register(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16) - Send_IO_Update(f_dds); + writeRegister(fd,0x0c, phaseAmpWord>>24&0xFF, phaseAmpWord>>16&0xFF,phaseAmpWord>>8&0xFF,phaseAmpWord&0xFF); // amp (12b) ph(16) + sendIOUpdate(f_dds); } /* @@ -148,7 +148,7 @@ void getAmpPhaseWord(int fd) { // unsigned char rx[5]={0}; unsigned char* pt; - read_register(fd,0x0c,rx); // amp (12b) ph(16) + readRegister(fd,0x0c,rx); // amp (12b) ph(16) rx[0]=*pt; rx[1]=*(pt+1); rx[2]=*(pt+2); @@ -205,28 +205,28 @@ int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t amp return EXIT_SUCCESS; } -void Send_CTRL_UP(int fp) +void sendCtrlUp(int fp) { char DRCTLOn='0';//pente positive write(fp,&DRCTLOn,sizeof(DRCTLOn)); // sleep(0.1); } -void Send_CTRL_DOWN(int fp) +void sendCtrlDown(int fp) { char DRCTLOn='2';//pente negative write(fp,&DRCTLOn,sizeof(DRCTLOn)); //reset sleep(0.1); } -void Send_HOLD(int fp) +void sendHold(int fp) { char DRHOLDOn ='1';//rampe bloquée write(fp,&DRHOLDOn,sizeof(DRHOLDOn)); //reset sleep(0.1); } -void Send_UNHOLD(int fp) +void sendUnhold(int fp) { char DRHOLDOn ='3';//rampe debloquée write(fp,&DRHOLDOn,sizeof(DRHOLDOn)); //reset @@ -239,20 +239,20 @@ int testRampFreq(int fd, int f_dds, int fp) //3-Rampe de pente positive + debloquage - Send_CTRL_DOWN(fp);//rampe up - Send_UNHOLD(fp); + sendCtrlDown(fp);//rampe up + sendUnhold(fp); - Send_Reset(f_dds); + sendReset(f_dds); //Initialize_DDS (fd, f_dds); //0- paramètre de bases - write_register(fd,0x00,0x00,0x01,0x01,0x0a);//OSKenable+Read&write - Send_IO_Update(f_dds); - read_register_ini(fd,0x00); + writeRegister(fd,0x00,0x00,0x01,0x01,0x0a);//OSKenable+Read&write + sendIOUpdate(f_dds); + readRegisterIni(fd,0x00); - write_register(fd,0x01,0x00, 0x00, 0x09, 0x00); // enable amp ramp - Send_IO_Update(f_dds); - read_register_ini(fd,0x00); + writeRegister(fd,0x01,0x00, 0x00, 0x09, 0x00); // enable amp ramp + sendIOUpdate(f_dds); + readRegisterIni(fd,0x00); //1- Donner une frequence f_dds de 1.1e7 Hz sachant que f_clk=1e9 Hz; // => Le mot a donner est (p.19) : FTW=(f_dds/f_clk)*2³² @@ -265,16 +265,16 @@ int testRampFreq(int fd, int f_dds, int fp) - write_register(fd,0x0b,0x02,0xd0,0xe5,0x60);//mot de frequence - Send_IO_Update(f_dds); - write_register(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle - Send_IO_Update(f_dds); + writeRegister(fd,0x0b,0x02,0xd0,0xe5,0x60);//mot de frequence + sendIOUpdate(f_dds); + writeRegister(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle + sendIOUpdate(f_dds); printf("Les mots de frequences, d'amplitudes et de phases sont envoyes\n"); printf("Lecture registre de frequence: 0x0b\n"); - read_register_ini(fd,0x0b); + readRegisterIni(fd,0x0b); printf("Lecture registre de amp et phase: 0x0c\n"); - read_register_ini(fd,0x0c); + readRegisterIni(fd,0x0c); Calibrate_DAC (fd,f_dds); printf("\n\n ----------------------- \n\n"); @@ -283,12 +283,12 @@ int testRampFreq(int fd, int f_dds, int fp) /* //2- Taille des dt - write_register(fd,0x08,0xFF,0xFF,0xFF,0xFF); //+dt max, -dt max (+dt = -dt) - Send_IO_Update(f_dds); + writeRegister(fd,0x08,0xFF,0xFF,0xFF,0xFF); //+dt max, -dt max (+dt = -dt) + sendIOUpdate(f_dds); printf("Les mots de dt sont envoyes\n"); printf("Lecture dans le registre 0x08 : taille dt\n"); - read_register_ini (fd,0x08); + readRegisterIni (fd,0x08); @@ -299,30 +299,30 @@ int testRampFreq(int fd, int f_dds, int fp) //3- STEP SIZE :dphi // en theorie dphi =2.25e-28 degrees - write_register(fd,0x06,0x00,0x00,0x00,0x01); - Send_IO_Update(f_dds); + writeRegister(fd,0x06,0x00,0x00,0x00,0x01); + sendIOUpdate(f_dds); - write_register(fd,0x07,0x00,0x00,0x00,0x01); - Send_IO_Update(f_dds); + writeRegister(fd,0x07,0x00,0x00,0x00,0x01); + sendIOUpdate(f_dds); //printf("\n\n ----------------------- \n\n"); printf("Les mots de dphi sont envoyes\n"); printf("Lecture dans les registres 0x06 et 0x07 : taille dt\n"); - read_register_ini (fd,0x06); - read_register_ini (fd,0x07); + readRegisterIni (fd,0x06); + readRegisterIni (fd,0x07); printf("\n\n ----------------------- \n\n"); //4- Ecrire les extremums de la rampe - write_register(fd,0x04,0x00,0x00,0x00,0x01);//0 rad - Send_IO_Update(f_dds); - write_register(fd,0x05,0xFF,0xFF,0xFF,0xFF);//2*pi rad - Send_IO_Update(f_dds); + writeRegister(fd,0x04,0x00,0x00,0x00,0x01);//0 rad + sendIOUpdate(f_dds); + writeRegister(fd,0x05,0xFF,0xFF,0xFF,0xFF);//2*pi rad + sendIOUpdate(f_dds); printf("Les mots des frontieres sont envoyes\n"); printf("Lecture dans les registres 0x04 et 0x05 : taille dt\n"); - read_register_ini (fd,0x04); - read_register_ini (fd,0x05); + readRegisterIni (fd,0x04); + readRegisterIni (fd,0x05); //3-Rampe de pente positive ou négative @@ -330,14 +330,14 @@ int testRampFreq(int fd, int f_dds, int fp) //4-ecriture dans le registre 0x01 - write_register(fd,0x01,0x00, 0xa8, 0x09, 0x00); // enable amp ramp - Send_IO_Update(f_dds); + writeRegister(fd,0x01,0x00, 0xa8, 0x09, 0x00); // enable amp ramp + sendIOUpdate(f_dds); printf("Lecture dans le registre 0x01 : \n"); - read_register_ini (fd,0x01); + readRegisterIni (fd,0x01); // printf("Les mots de dt sont envoyes\n"); printf("Lecture dans le registre 0x08 : taille dt\n"); - read_register_ini (fd,0x08); + readRegisterIni (fd,0x08); */ @@ -346,7 +346,7 @@ int testRampFreq(int fd, int f_dds, int fp) //---------------rajout 8/1 -int PutAmpWord(int fd, int f_dds, double amplitude) +int putAmpWord(int fd, int f_dds, double amplitude) { uint16_t PhaseWord = 0x0000; uint16_t AmpWord = 0x0000; @@ -354,18 +354,18 @@ int PutAmpWord(int fd, int f_dds, double amplitude) AmpWord = rint(amplitude*(pow(2.0,12.0)-1)/100); - read_register(fd,0x0c,&ReadPhaseAmpWord); + readRegister(fd,0x0c,&ReadPhaseAmpWord); PhaseWord = ReadPhaseAmpWord&0xFFFF; - write_register(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); - Send_IO_Update(f_dds); + writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); + sendIOUpdate(f_dds); return 0; } -int PutPhaseWord(int fd, int f_dds, double phase) +int putPhaseWord(int fd, int f_dds, double phase) { uint16_t PhaseWord = 0x0000; uint16_t AmpWord = 0x0000; @@ -373,63 +373,63 @@ int PutPhaseWord(int fd, int f_dds, double phase) PhaseWord = rint(phase*(pow(2.0,16.0)-1)/360); - read_register(fd,0x0c,&ReadPhaseAmpWord); + readRegister(fd,0x0c,&ReadPhaseAmpWord); AmpWord = ReadPhaseAmpWord>>16&0xFFFF; - write_register(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); - Send_IO_Update(f_dds); + writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); + sendIOUpdate(f_dds); return 0; } -int PutFrequencyWord(int fd, int f_dds, double fout)//Attention uniquement valable pour fclk = 1 GHz +int putFrequencyWord(int fd, int f_dds, double fclk,double fout)//Attention uniquement valable pour fclk = 1 GHz { uint32_t FTWR = 0x00000000; - FTWR = rint((fout/1e9)*pow(2.0,32.0)); - write_register(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence - Send_IO_Update(f_dds); + FTWR = rint((fout/fclk)*pow(2.0,32.0)); + writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence + sendIOUpdate(f_dds); return 0; } -int PutFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase)//n'existe pas dans le mode profile enable +int putFrequencyAmpPhaseWord(int fd, int f_dds, double fout, double fclk,double amp, double phase)//n'existe pas dans le mode profile enable { uint32_t FTWR = 0x00000000; FTWR = rint((fout/fclk)*pow(2.0,32.0)); - write_register(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence + writeRegister(fd,0x0b,FTWR>>24&0xFF,FTWR>>16&0xFF,FTWR>>8&0xFF,FTWR&0xFF);//mot de frequence - Send_IO_Update(f_dds); + sendIOUpdate(f_dds); -// write_register(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle -// Send_IO_Update(f_dds); +// writeRegister(fd,0x0c,0x0F,0xFF,0x00,0x00); //mot de amp et de phase : amp max, phase nulle +// sendIOUpdate(f_dds); - PutPhaseWord(fd,f_dds,phase); - PutAmpWord(fd,f_dds,amp); + putPhaseWord(fd,f_dds,phase); + putAmpWord(fd,f_dds,amp); return 0; } -int InitialisationProfile (int fd,int f_dds) +int initialisationProfileMode (int fd,int f_dds) { - Send_Reset(f_dds); //les registres sont maintenant par defaut - write_register(fd,0x00,0x00,0x01,0x01,0x0a); //OSK+SDIO input only//ok - Send_IO_Update(f_dds); - write_register(fd,0x01,0x00,0x80,0x09,0x00); // profile mode enable very important - Send_IO_Update(f_dds); - write_register(fd,0x02,0x00,0x00,0x19,0x1c); // default - Send_IO_Update(f_dds); - write_register(fd,0x03,0x01,0x05,0x21,0x20); // calibration 1/2 :enable - Send_IO_Update(f_dds); - write_register(fd,0x03,0x00,0x05,0x21,0x20); // calibration 2/2 :desenable - Send_IO_Update(f_dds); + sendReset(f_dds); //les registres sont maintenant par defaut + writeRegister(fd,0x00,0x00,0x01,0x01,0x0a); //OSK+SDIO input only//ok + sendIOUpdate(f_dds); + writeRegister(fd,0x01,0x00,0x80,0x09,0x00); // profile mode enable very important + sendIOUpdate(f_dds); + writeRegister(fd,0x02,0x00,0x00,0x19,0x1c); // default + sendIOUpdate(f_dds); + writeRegister(fd,0x03,0x01,0x05,0x21,0x20); // calibration 1/2 :enable + sendIOUpdate(f_dds); + writeRegister(fd,0x03,0x00,0x05,0x21,0x20); // calibration 2/2 :desenable + sendIOUpdate(f_dds); return 0; } @@ -444,7 +444,7 @@ int InitialisationProfile (int fd,int f_dds) //1-rampe de frequence //rampe simple de fréquence -int FrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) +int frequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) { //calcul de N => N=DeltaF/df = DeltaT/dt @@ -504,12 +504,12 @@ int FrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, do //4.1 Limit register uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0)); - write_register(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence - Send_IO_Update(f_dds); + writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence + sendIOUpdate(f_dds); uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0)); - write_register(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence - Send_IO_Update(f_dds); + writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence + sendIOUpdate(f_dds); //4.2 dfUP et dfDown @@ -519,10 +519,10 @@ int FrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, do uint32_t Word_df_up = rint(df_up*pow(2.0,32.0)/fclk); uint32_t Word_df_down = rint(df_down*pow(2.0,32.0)/fclk); - write_register(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down + sendIOUpdate(f_dds); //4.3 dtUp et dtDown @@ -533,13 +533,13 @@ int FrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, do Word_dt_up = rint(dtUp*fclk/24); Word_dt_down = rint(dtDown*fclk/24); - write_register(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt - Send_IO_Update(f_dds); + writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt + sendIOUpdate(f_dds); //5 Start of the ramp - write_register(fd,0x01,0x00,0x08,0x09,0x00); //rampe simple - Send_IO_Update(f_dds); + writeRegister(fd,0x01,0x00,0x08,0x09,0x00); //rampe simple + sendIOUpdate(f_dds); return 0; @@ -550,7 +550,7 @@ int FrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, do //rampe continue de fréquence -int ContinueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) +int continueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double dfDown, double FreqMax,double FreqMin, double DeltaTimeUp, double DeltaTimeDown) { //calcul de N => N=DeltaF/df = DeltaT/dt @@ -610,12 +610,12 @@ int ContinueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double df //4.1 Limit register uint32_t FTWRmin = rint((FreqMin/fclk)*pow(2.0,32.0)); - write_register(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence - Send_IO_Update(f_dds); + writeRegister(fd,0x04,FTWRmin>>24&0xFF,FTWRmin>>16&0xFF,FTWRmin>>8&0xFF,FTWRmin&0xFF);//mot de frequence + sendIOUpdate(f_dds); uint32_t FTWRmax = rint((FreqMax/fclk)*pow(2.0,32.0)); - write_register(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence - Send_IO_Update(f_dds); + writeRegister(fd,0x05,FTWRmax>>24&0xFF,FTWRmax>>16&0xFF,FTWRmax>>8&0xFF,FTWRmax&0xFF);//mot de frequence + sendIOUpdate(f_dds); //4.2 dfUP et dfDown @@ -625,10 +625,10 @@ int ContinueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double df uint32_t Word_df_up = rint(df_up*pow(2.0,32.0)/fclk); uint32_t Word_df_down = rint(df_down*pow(2.0,32.0)/fclk); - write_register(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_df_up>>24&0xFF,Word_df_up>>16&0xFF,Word_df_up>>8&0xFF,Word_df_up&0xFF); //df_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_df_down>>24&0xFF,Word_df_down>>16&0xFF,Word_df_down>>8&0xFF,Word_df_down&0xFF);//df_down + sendIOUpdate(f_dds); //4.3 dtUp et dtDown @@ -639,13 +639,13 @@ int ContinueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double df Word_dt_up = rint(dtUp*fclk/24); Word_dt_down = rint(dtDown*fclk/24); - write_register(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt - Send_IO_Update(f_dds); + writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt + sendIOUpdate(f_dds); //5 Start of the ramp - write_register(fd,0x01,0x00,0x8e,0x29,0x00); //rampe triangulaire - Send_IO_Update(f_dds); + writeRegister(fd,0x01,0x00,0x8e,0x29,0x00); //rampe triangulaire + sendIOUpdate(f_dds); return 0; @@ -656,7 +656,7 @@ int ContinueFrequencySweep (int fd, int f_dds,double fclk,double dfUp, double df //2-rampe d'amplitude -int AmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) +int amplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) { @@ -742,10 +742,10 @@ int AmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, do uint32_t WordAmin = rint(AMin*4095/100); uint32_t WordAmax= rint(AMax*4095/100); - write_register(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 - Send_IO_Update(f_dds); - write_register(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 - Send_IO_Update(f_dds); + writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 + sendIOUpdate(f_dds); + writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 + sendIOUpdate(f_dds); //4.2 dAUP et dADown @@ -753,10 +753,10 @@ int AmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, do uint32_t Word_dA_up = rint(dAUp*4095/100); uint32_t Word_dA_down = rint(dADown*4095/100); - write_register(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down + sendIOUpdate(f_dds); //4.3 dtUp et dtDown @@ -764,19 +764,19 @@ int AmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, do uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); - write_register(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt - Send_IO_Update(f_dds); + writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt + sendIOUpdate(f_dds); //5 Start of the ramp - write_register(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante - //write_register(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue - Send_IO_Update(f_dds); + writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante + //writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue + sendIOUpdate(f_dds); return EXIT_SUCCESS; } -int ContinueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) +int continueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dADown, double AMax,double AMin, double DeltaTimeUp, double DeltaTimeDown) { @@ -862,10 +862,10 @@ int ContinueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dA uint32_t WordAmin = rint(AMin*4095/100); uint32_t WordAmax= rint(AMax*4095/100); - write_register(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 - Send_IO_Update(f_dds); - write_register(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 - Send_IO_Update(f_dds); + writeRegister(fd,0x04,WordAmin>>24&0xFF,WordAmin>>16&0xFF,WordAmin>>8&0xFF,WordAmin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 + sendIOUpdate(f_dds); + writeRegister(fd,0x05,WordAmax>>24&0xFF,WordAmax>>16&0xFF,WordAmax>>8&0xFF,WordAmax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 + sendIOUpdate(f_dds); //4.2 dAUP et dADown @@ -873,10 +873,10 @@ int ContinueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dA uint32_t Word_dA_up = rint(dAUp*4095/100); uint32_t Word_dA_down = rint(dADown*4095/100); - write_register(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_dA_up>>24&0xFF,Word_dA_up>>16&0xFF,Word_dA_up>>8&0xFF,Word_dA_up&0xFF); //dA_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_dA_down>>24&0xFF,Word_dA_down>>16&0xFF,Word_dA_down>>8&0xFF,Word_dA_down&0xFF);//dA_down + sendIOUpdate(f_dds); //4.3 dtUp et dtDown @@ -884,14 +884,14 @@ int ContinueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dA uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); - write_register(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt - Send_IO_Update(f_dds); + writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt + sendIOUpdate(f_dds); //5 Start of the ramp - //write_register(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante - write_register(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue - Send_IO_Update(f_dds); + //writeRegister(fd,0x01,0x00,0x28,0x09,0x00); //rampe simple montante + writeRegister(fd,0x01,0x00,0xAE,0x29,0x00); //rampe continue + sendIOUpdate(f_dds); return EXIT_SUCCESS; } @@ -899,7 +899,7 @@ int ContinueAmplitudeSweep (int fd, int f_dds,double fclk,double dAUp, double dA //3-rampe de ĥase -int PhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) +int phaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) { @@ -995,10 +995,10 @@ int PhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, do printf("WordPhimax = %.32x\n",WordPhimax); - write_register(fd,0x04,WordPhimin>>24&0xFF,WordPhimin>>16&0xFF,WordPhimin>>8&0xFF,WordPhimin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 - Send_IO_Update(f_dds); - write_register(fd,0x05,WordPhimax>>24&0xFF,WordPhimax>>16&0xFF,WordPhimax>>8&0xFF,WordPhimax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 - Send_IO_Update(f_dds); + writeRegister(fd,0x04,WordPhimin>>24&0xFF,WordPhimin>>16&0xFF,WordPhimin>>8&0xFF,WordPhimin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 + sendIOUpdate(f_dds); + writeRegister(fd,0x05,WordPhimax>>24&0xFF,WordPhimax>>16&0xFF,WordPhimax>>8&0xFF,WordPhimax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 + sendIOUpdate(f_dds); //4.2 dphiUP et dphiDown @@ -1012,18 +1012,18 @@ int PhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, do printf("Word_dphi_down = %.32x\n",Word_dphi_down); /* - write_register(fd,0x06,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up>>0&0xFF,Word_dphi_up&0xFF); //dphi_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down>>0&0xFF,Word_dphi_down&0xFF);//dphi_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up>>0&0xFF,Word_dphi_up&0xFF); //dphi_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down>>0&0xFF,Word_dphi_down&0xFF);//dphi_down + sendIOUpdate(f_dds); */ - write_register(fd,0x06,Word_dphi_up>>24&0xFF,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up&0xFF); //dA_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_dphi_down>>24&0xFF,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down&0xFF);//dA_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_dphi_up>>24&0xFF,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up&0xFF); //dA_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_dphi_down>>24&0xFF,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down&0xFF);//dA_down + sendIOUpdate(f_dds); //4.3 dtUp et dtDown @@ -1031,18 +1031,18 @@ int PhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, do uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); - write_register(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt - Send_IO_Update(f_dds); + writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt + sendIOUpdate(f_dds); //5 Start of the ramp - write_register(fd,0x01,0x00,0x18,0x09,0x00); //rampe simple montante - Send_IO_Update(f_dds); + writeRegister(fd,0x01,0x00,0x18,0x09,0x00); //rampe simple montante + sendIOUpdate(f_dds); return EXIT_SUCCESS; } -int ContinuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) +int continuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphiDown, double PhiMax,double PhiMin, double DeltaTimeUp, double DeltaTimeDown) { @@ -1138,10 +1138,10 @@ int ContinuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphi printf("WordPhimax = %.32x\n",WordPhimax); - write_register(fd,0x04,WordPhimin>>24&0xFF,WordPhimin>>16&0xFF,WordPhimin>>8&0xFF,WordPhimin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 - Send_IO_Update(f_dds); - write_register(fd,0x05,WordPhimax>>24&0xFF,WordPhimax>>16&0xFF,WordPhimax>>8&0xFF,WordPhimax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 - Send_IO_Update(f_dds); + writeRegister(fd,0x04,WordPhimin>>24&0xFF,WordPhimin>>16&0xFF,WordPhimin>>8&0xFF,WordPhimin&0xFF); //min => lim-(Amp ) = 0x800 = Amax/2 + sendIOUpdate(f_dds); + writeRegister(fd,0x05,WordPhimax>>24&0xFF,WordPhimax>>16&0xFF,WordPhimax>>8&0xFF,WordPhimax&0xFF);//max => lim+(Amp) = 0xFFF= Amax0 + sendIOUpdate(f_dds); //4.2 dphiUP et dphiDown @@ -1155,18 +1155,18 @@ int ContinuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphi printf("Word_dphi_down = %.32x\n",Word_dphi_down); /* - write_register(fd,0x06,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up>>0&0xFF,Word_dphi_up&0xFF); //dphi_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down>>0&0xFF,Word_dphi_down&0xFF);//dphi_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up>>0&0xFF,Word_dphi_up&0xFF); //dphi_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down>>0&0xFF,Word_dphi_down&0xFF);//dphi_down + sendIOUpdate(f_dds); */ - write_register(fd,0x06,Word_dphi_up>>24&0xFF,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up&0xFF); //dA_up - Send_IO_Update(f_dds); - write_register(fd,0x07,Word_dphi_down>>24&0xFF,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down&0xFF);//dA_down - Send_IO_Update(f_dds); + writeRegister(fd,0x06,Word_dphi_up>>24&0xFF,Word_dphi_up>>16&0xFF,Word_dphi_up>>8&0xFF,Word_dphi_up&0xFF); //dA_up + sendIOUpdate(f_dds); + writeRegister(fd,0x07,Word_dphi_down>>24&0xFF,Word_dphi_down>>16&0xFF,Word_dphi_down>>8&0xFF,Word_dphi_down&0xFF);//dA_down + sendIOUpdate(f_dds); //4.3 dtUp et dtDown @@ -1174,13 +1174,13 @@ int ContinuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphi uint16_t Word_dt_up = rint(dtUp*fclk/24); uint16_t Word_dt_down = rint(dtDown*fclk/24); - write_register(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt - Send_IO_Update(f_dds); + writeRegister(fd,0x08,Word_dt_down>>8&0xFF,Word_dt_down&0xFF,Word_dt_up>>8&0xFF,Word_dt_up&0xFF); // il y a 2 dt + sendIOUpdate(f_dds); //5 Start of the ramp - write_register(fd,0x01,0x00,0x9E,0x29,0x00); //rampe simple montante - Send_IO_Update(f_dds); + writeRegister(fd,0x01,0x00,0x9E,0x29,0x00); //rampe simple montante + sendIOUpdate(f_dds); return EXIT_SUCCESS; } @@ -1190,7 +1190,7 @@ int ContinuePhaseSweep (int fd, int f_dds,double fclk,double dphiUp, double dphi //--------------------------FONCTIONS RAMPES SOFTWARES -int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFin) +int rampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFin) { //On va plutôt fixé dA sinon trop de contrainte : => Besoin d'allocation dynamique @@ -1220,7 +1220,7 @@ int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFi //extraction de la phase initiale et de l'amplitude uint32_t ReadPhaseAmpWord = 0x00000000; - read_register(fd, 0x0c,&ReadPhaseAmpWord); + readRegister(fd, 0x0c,&ReadPhaseAmpWord); printf("ReadPhaseAmpWord = %.8x \n", ReadPhaseAmpWord); uint16_t WordPhaseInitiale = ReadPhaseAmpWord&0xFFFF; @@ -1240,8 +1240,8 @@ int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFi printf("Start of the ramp\n"); for(int i=0;i>8&0xFF,ArrayWordAmp[i]&0xFF,WordPhaseInitiale>>8&0xFF,WordPhaseInitiale&0xFF); - Send_IO_Update(f_dds); + writeRegister(fd,0x0c,ArrayWordAmp[i]>>8&0xFF,ArrayWordAmp[i]&0xFF,WordPhaseInitiale>>8&0xFF,WordPhaseInitiale&0xFF); + sendIOUpdate(f_dds); usleep(1000000*dt); } @@ -1254,11 +1254,11 @@ int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFi AmpWord = rint(amplitude*(pow(2.0,12.0)-1)/100); - read_register(fd,0x0c,&ReadPhaseAmpWord); + readRegister(fd,0x0c,&ReadPhaseAmpWord); PhaseWord = ReadPhaseAmpWord&0xFFFF; - write_register(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); + writeRegister(fd,0x0c,AmpWord>>8&0xFF,AmpWord&0xFF,PhaseWord>>8&0xFF,PhaseWord&0xFF); */ @@ -1289,7 +1289,7 @@ int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFi //extraction de la phase initiale et de l'amplitude uint32_t ReadPhaseAmpWord = 0x00000000; - read_register(fd, 0x0c,&ReadPhaseAmpWord); + readRegister(fd, 0x0c,&ReadPhaseAmpWord); printf("ReadPhaseAmpWord = %.8x \n", ReadPhaseAmpWord); uint16_t WordPhaseInitiale = ReadPhaseAmpWord&0xFFFF; @@ -1313,7 +1313,7 @@ int RampAmpFromSoft(int fd, int f_dds,double DeltaTimeUp,double AIni, double AFi return EXIT_SUCCESS; } -int RampPhaseFromSoft(int fd, int f_dds,double DeltaTimeUp,double PhiIni, double PhiFin) +int rampPhaseFromSoft(int fd, int f_dds,double DeltaTimeUp,double PhiIni, double PhiFin) { //On va plutôt fixé dphi : => Besoin d'allocation dynamique @@ -1343,7 +1343,7 @@ int RampPhaseFromSoft(int fd, int f_dds,double DeltaTimeUp,double PhiIni, double //extraction de l'amplitude uint32_t ReadPhaseAmpWord = 0x00000000; - read_register(fd, 0x0c,&ReadPhaseAmpWord); + readRegister(fd, 0x0c,&ReadPhaseAmpWord); printf("ReadPhaseAmpWord = %.8x \n", ReadPhaseAmpWord); uint16_t WordAmpInitiale = ReadPhaseAmpWord>>16&0xFFFF; @@ -1361,8 +1361,8 @@ int RampPhaseFromSoft(int fd, int f_dds,double DeltaTimeUp,double PhiIni, double printf("Start of the ramp\n"); for(int i=0;i>8&0xFF,WordAmpInitiale&0xFF,ArrayWordPhi[i]>>8&0xFF,ArrayWordPhi[i]&0xFF); - Send_IO_Update(f_dds); + writeRegister(fd,0x0c,WordAmpInitiale>>8&0xFF,WordAmpInitiale&0xFF,ArrayWordPhi[i]>>8&0xFF,ArrayWordPhi[i]&0xFF); + sendIOUpdate(f_dds); usleep(1000000*dt); }