Blame view

include/ad9915.h 3.93 KB
dfa91a3bc   pyb   libad9915 : add i...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  /*
  dds initialisation et SPI 
  */
  
  #include <stdint.h>
  #include <unistd.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <getopt.h>
  #include <fcntl.h>
  #include <sys/ioctl.h>
  #include <linux/types.h>
  #include <linux/spi/spidev.h>
  /* memory management */
  #include <sys/mman.h>
  #include "spi.h"
  #include <string.h>
  #include <math.h>
  #include <time.h>
  
  
  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};
09ecc607d   bachi   mise a jour avec ...
28
29
30
  static const char CFR4Start[] =  {0x00, 0x05, 0x21, 0x20}; 
  //static const char CFR4Start[] =  {0x20, 0x21, 0x05, 0x00};
  
dfa91a3bc   pyb   libad9915 : add i...
31
32
33
34
35
36
37
38
39
40
41
  
  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 Send_Reset(int f_dds);
  void Send_IO_Update (int f_dds);    //Send the update to set the control registers
  void write_register (int fd, unsigned char addr, unsigned char d3, unsigned char d2, unsigned char d1, unsigned char d0);
09ecc607d   bachi   mise a jour avec ...
42
43
  void read_register (int fd, unsigned char addr, uint32_t *readword);
  void read_register_ini (int fd,unsigned char addr);
dfa91a3bc   pyb   libad9915 : add i...
44
45
46
47
48
49
  void Initialize_DDS (int fd, int f_dds);
  void Calibrate_DAC(int fd, int f_dds);
  void basic_setup(int fd, int f_dds, uint16_t ampWord, uint16_t phaseWord);
  void modulus_setup(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);
09ecc607d   bachi   mise a jour avec ...
50
  void checkSize(void);
dfa91a3bc   pyb   libad9915 : add i...
51
52
53
54
  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);
  
09ecc607d   bachi   mise a jour avec ...
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  //------------ DRCTL
  
  void Send_CTRL_UP(int fp);
  void Send_CTRL_DOWN(int fp);
  void Send_HOLD(int fp);
  void Send_UNHOLD(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 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);
  
  //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
  
  // fonctions rampes softwares
  
  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);
  
  // fin fonctoins rampes softwares