/* dds initialisation et SPI */ #include #include #include #include #include #include #include #include #include /* memory management */ #include #include "spi.h" #include #include #include static const char CFRAddress[] = {0x00,0x01,0x02,0x03}; static const char CFR1Start[] ={0x00, 0x01, 0x00, 0x0a}; //static const char CFR1Start[] ={0x00, 0x01, 0x01, 0x08}; //with osk enable static const char CFR2Start[] ={0x00, 0x80, 0x09, 0x00}; //0x80 enable prof mode static const char CFR3Start[] = {0x00, 0x00, 0x19, 0x1C}; static const char CFR4Start[] = {0x00, 0x05, 0x21, 0x20}; //static const char CFR4Start[] = {0x20, 0x21, 0x05, 0x00}; static const char USR0Address = 0x1B; static const char FTW0Address = 0x0b; //profile 0 ftw static const char PA0Address = 0x0c; //profile 0 static const char DACCalEnable[] = {0x01, 0x05, 0x21, 0x20}; //Command to enable the DAC Cal, should be 0x01XXXXXX, where X is the last 6 digits of CFR4Start void sendReset(int f_dds); void sendIOUpdate (int f_dds); //Send the update to set the control registers void writeRegister (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0); void readRegister (int fd, unsigned char addr, uint32_t *readword); void readRegister_ini (int fd,unsigned char addr); void initializeDDS (int fd, int f_dds); void calibrateDAC(int fd, int f_dds); void basicSetup(int fd, int f_dds, uint16_t ampWord, uint16_t phaseWord); void modulusSetup(int fd, int f_dds); void setFreqMM(int fd, int f_dds, unsigned int ftw, unsigned int A, unsigned int B); void setAmpPhaseWord(int fd, int f_dds,unsigned int phaseAmpWord); int openAndSetDdsFreq( char * device, char * gpio_update, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord); int receiveParameterFromPythonServer(char * device, double f_clk, double f_out); int setDdsFreqFull ( int fd, int f_dds, double f_clk, double f_out, uint16_t ampWord, uint16_t phaseWord); //------------ DRCTL 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 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 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); //fin fonctions rampes hardwares