ad9915.h
3.62 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
/*
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};
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