annotate DDS4xAD9912.c @ 22:b7b3b5f1c5a6

Remove unused widgets from N1 measurement panel. Harmonize widgets names
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Thu, 19 Jul 2012 20:01:40 +0200
parents d9aae7d7f2c6
children 0e9f95525a8f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1 #include <utility.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
3 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
4 //
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
5 // Title: DDS4xAD9912.c
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
6 // Purpose:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
7 //
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
8 // Created on: by Volodimer Laurent, modified by YLC
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
9 // Copyright: syrte. All Rights Reserved.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
10 //
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
11 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
12
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
13 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
14 // Include files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
15
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
16 #include "DDS4xAD9912.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
17 #include <userint.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
18 #include <tcpsupp.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
19 #include <ansi_c.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
20
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
21 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
22 // Global functions
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
23
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
24 static int OnTCPEvent(unsigned handle, int xType, int errCode, void *callbackData)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
25 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
26 switch(xType)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
27 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
28 case TCP_DISCONNECT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
29 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
30 case TCP_DATAREADY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
31 ClientTCPRead (handle, Response, sizeof(Response), 0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
32 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
33 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
34 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
35 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
36
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
37
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
38 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
39 // DDS4xAD9912_SendCmd
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
40 //
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
41 // FUNC : envoie une chaine de caracteres sur un port du serveur TCP/IP de la foxboard
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
42 // PARAM : DDSNum contient le numero de la DDS (1,2,3 ou 4)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
43 // PARAM : Buffer contenant la chaîne de caractères à envoyer
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
44 // RETURN : 0 si la connexion et l'ecriture sur le serveur TCP/IP sont OK
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
45 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
46
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
47
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
48 static int DDS4xAD9912_SendCmd(int DDSNum, char * Buffer) // essentially a private function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
49 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
50 int res_1,res_2;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
51
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
52 switch(DDSNum)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
53 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
54 case 1:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
55 res_1=ConnectToTCPServer (&hConv, Port1, Adress, OnTCPEvent, 0, 0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
56 if(res_1 <0) MessagePopup("DDS4xAD9912_1 Serveur", "Connection to server failed !");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
57 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
58 case 2:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
59 res_1=ConnectToTCPServer (&hConv, Port2, Adress, OnTCPEvent, 0, 0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
60 if(res_1 <0) MessagePopup("DDS4xAD9912_2 Serveur", "Connection to server failed !");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
61 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
62
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
63 case 3:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
64 res_1=ConnectToTCPServer (&hConv, Port3, Adress, OnTCPEvent, 0, 0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
65 if(res_1 <0) MessagePopup("DDS4xAD9912_3 Serveur", "Connection to server failed !");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
66 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
67
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
68 case 4:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
69 res_1=ConnectToTCPServer (&hConv, Port4, Adress, OnTCPEvent, 0, 0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
70 if(res_1 <0) MessagePopup("DDS4xAD9912_4 Serveur", "Connection to server failed !");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
71 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
72
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
73 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
74
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
75 res_2=ClientTCPWrite (hConv, Buffer, strlen(Buffer)+1, 0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
76 if(res_2 <0) MessagePopup("DDS Serveur", "Write to server failed !");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
77 DisconnectFromTCPServer (hConv);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
78 return (res_1+res_2) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
79 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
80
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
81
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
82 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
83 // DDS4xAD9912_Reset
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
84 //
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
85 // FUNC : reset des 4 DDS
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
86 // PARAM :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
87 // RETURN : 0 si le reset de la DDS 1 , DDS 2, DDS3 et DDS4 est OK
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
88 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
89
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
90 int DDS4xAD9912_Reset(DDS4xAD9912_Data * Instance)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
91 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
92 int res_1,res_2;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
93
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
94 sprintf(Request,"set;%i;%i",1,17);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
95 res_1 = DDS4xAD9912_SendCmd(1,Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
96 if(res_1 <0) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
97 MessagePopup("DDS Serveur", "DDS4xAD9912_1 Reset failed !") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
98 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
99 else Instance->Frequency1 = 0.0 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
100
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
101 sprintf(Request,"set;%i;%i",1,17);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
102 res_2 = DDS4xAD9912_SendCmd(2,Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
103 if(res_2 <0) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
104 MessagePopup("DDS Serveur", "DDS4xAD9912_2 Reset failed !") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
105 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
106 else Instance->Frequency2 = 0.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
107
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
108 sprintf(Request,"set;%i;%i",1,17);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
109 res_2 = DDS4xAD9912_SendCmd(3,Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
110 if(res_2 <0) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
111 MessagePopup("DDS Serveur", "DDS4xAD9912_3 Reset failed !") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
112 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
113 else Instance->Frequency3 = 0.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
114
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
115 sprintf(Request,"set;%i;%i",1,17);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
116 res_2 = DDS4xAD9912_SendCmd(4,Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
117 if(res_2 <0) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
118 MessagePopup("DDS Serveur", "DDS4xAD9912_4 Reset failed !") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
119 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
120 else Instance->Frequency4 = 0.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
121
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
122
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
123 return (res_1+res_2);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
124 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
125
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
126
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
127 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
128 // DDS4xAD9912_SetFreq
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
129 //
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
130 // FUNC : sort une fréquence sur la DDS1 ,DDS2, DDS3 ou DDS4
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
131 // PARAM : DDSNum contient le numero de la DDS (1, 2 , 3 ou 4)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
132 // RETURN : 0 si la connexion et l'ecriture sur le serveur TCP/IP sont OK
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
133 //==============================================================================
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
134 int DDS4xAD9912_SetFrequency(DDS4xAD9912_Data * Instance, int DDSNum, double Freq)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
135 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
136
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
137 double Word=WORD(Freq,Clk) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
138 double reste ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
139 int res_0 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
140 unsigned char b5,b4,b3,b2,b1,b0 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
141
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
142 b5=(unsigned char)(Word/E40);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
143 b4=(unsigned char)((Word - E40*b5)/E32);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
144 b3=(unsigned char)((Word - E40*b5 - E32*b4)/E24);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
145 b2=(unsigned char)((Word - E40*b5 - E32*b4 - E24*b3)/E16);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
146 b1=(unsigned char)((Word - E40*b5 - E32*b4 - E24*b3 - E16*b2)/E8);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
147 b0=(unsigned char)((Word - E40*b5 - E32*b4 - E24*b3 - E16*b2 - E8*b1)/1.0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
148 reste = (Word - E40*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1-1.0*b0) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
149
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
150 sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",0,10,b5,b4,b3,b2,b1,b0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
151 res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
152 if (res_0 <0) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
153 MessagePopup("DDS Serveur", "SetFrequency function failed !") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
154 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
155 else {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
156 if (DDSNum==1) Instance->Frequency1 = Freq - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
157 if (DDSNum==2) Instance->Frequency2 = Freq - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
158 if (DDSNum==3) Instance->Frequency3 = Freq - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
159 if (DDSNum==4) Instance->Frequency4 = Freq - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
160 } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
161
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
162 sprintf(Request,"set;%i;%i",0,18); // IO_Update logiciel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
163 res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
164 if (res_0 <0) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
165 MessagePopup("DDS Serveur", "IO_Update function failed !") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
166 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
167 return(res_0) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
168
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
169 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
170
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
171
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
172
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
173 int DDS4xAD9912_FrequencyRampe ( DDS4xAD9912_Data * Instance, int DDSNum, double Frequin,double Frequout, double Step )
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
174 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
175 int i=0,imax=0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
176 double Frequactu=0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
177 time_t Time ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
178 double delaysecond=0.01;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
179
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
180
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
181 if ( (Frequout - Frequin)>0)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
182 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
183 if ((Frequout-Frequin) > Step)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
184 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
185 imax= (Frequout-Frequin)/Step ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
186 for (i=0; i<imax;i++)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
187 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
188 Delay(delaysecond);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
189 Frequactu= Frequin+i*Step;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
190 DDS4xAD9912_SetFrequency(Instance, DDSNum, Frequactu);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
191
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
192 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
193 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
194 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
195
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
196 else
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
197 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
198 if ((Frequin-Frequout) > Step)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
199 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
200 imax= (Frequin-Frequout)/Step ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
201 for (i=0; i<imax;i++)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
202 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
203 Delay(delaysecond);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
204 Frequactu= Frequin-i*Step;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
205 DDS4xAD9912_SetFrequency(Instance, DDSNum, Frequactu);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
206 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
207 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
208
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
209 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
210
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
211 DDS4xAD9912_SetFrequency(Instance, DDSNum, Frequout);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
212 return(0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
213
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
214 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
215
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
216 /*Word=WORD(Frequactu,Clk);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
217 b5=(unsigned char)(Word/E48);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
218 b4=(unsigned char)((Word - E48*b5)/E32);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
219 b3=(unsigned char)((Word - E48*b5 -E32*b4)/E24);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
220 b2=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3)/E16);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
221 b1=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3 -E16*b2)/E8);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
222 b0=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1)/1.0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
223 reste = (Word - E48*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1-1.0*b0) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
224 sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",0,10,b5,b4,b3,b2,b1,b0);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
225 res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
226 if (DDSNum==1) Instance->Frequency1 = Frequactu - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
227 if (DDSNum==2) Instance->Frequency2 = Frequactu - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
228 if (DDSNum==3) Instance->Frequency3 = Frequactu - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
229 if (DDSNum==4) Instance->Frequency4 = Frequactu - reste*Clk/E48 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
230 sprintf(Request,"set;%i;%i",0,18);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
231 res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ; */
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
232