mrfioc2  2.3.0
Macros | Functions
FracSynthControlWord.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <epicsTypes.h>
#include <debugPrint.h>
#include <mrfCommon.h>
#include <epicsExport.h>
#include <mrfFracSynth.h>
#include <mrfFracSynth.c>
Include dependency graph for FracSynthControlWord.c:

Go to the source code of this file.

Macros

#define HOST_BUILD
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ HOST_BUILD

#define HOST_BUILD

Definition at line 92 of file FracSynthControlWord.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 103 of file FracSynthControlWord.c.

103  {
104 
105  /*---------------------
106  * Local Variables
107  */
108  int badArgs = 1; /* True if we could not parse the argument list */
109  epicsUInt32 controlWord = 0; /* Genearated SY87739L control word */
110  epicsFloat64 DesiredFreq; /* Frequency we wish to create a control word for */
111  epicsFloat64 EffectiveFreq; /* Freq. actually generated by the control word */
112  epicsFloat64 Error; /* Error between the desired and actual freqs. */
113  char *tailPtr; /* Pointer to tail of parsed control word string */
114 
115  /*---------------------
116  * Make sure we were passed only one argument.
117  * If so, see if we can parse it as a floating point value.
118  */
119  if (argc == 2) {
120  DesiredFreq = strtod (argv[1], &tailPtr);
121 
122  /*---------------------
123  * If we successfully parsed the desired frequency,
124  * try to compute a control word that will generate it.
125  */
126  if ((errno == OK) && (tailPtr != argv[1])) {
127  controlWord = FracSynthControlWord (DesiredFreq, MRF_FRAC_SYNTH_REF, DP_NONE, &Error);
128  badArgs = 0;
129 
130  /*---------------------
131  * Abort if we could not successfully create a control word for this frequency
132  */
133  if (controlWord == 0) {
134  printf ("Unable to create a control word for %f MHz.\n", DesiredFreq);
135  return ERROR;
136  }/*end if could not create control word*/
137 
138  /*---------------------
139  * Compute the effective frequency generated by the control word we created and
140  * check it for errors (we don't expect any errors, since we created it, but
141  * you never know....)
142  */
143  EffectiveFreq = FracSynthAnalyze (controlWord, MRF_FRAC_SYNTH_REF, DP_ERROR);
144 
145  /*---------------------
146  * Display the control word, the effective frequency, and the error.
147  */
148  printf ("Control Word = 0x%08X.\n", controlWord);
149  printf ("Desired Frequency = %f Mhz. Effective Frequency = %f MHz. ",
150  DesiredFreq, EffectiveFreq);
151  printf ("Error = %5.3f ppm.\n", Error);
152 
153  }/*end if control word parse was successful*/
154 
155  }/*end if we had the right number of arguments*/
156 
157  /*---------------------
158  * Print the "Usage" message if we could not parse the argument.
159  */
160  if (badArgs) {
161  printf ("Usage:\n");
162  printf ("FracSynthControlWord <DesiredFreq>\n");
163  printf (" Where <DesiredFreq> is the frequency (in MegaHertz)\n");
164  printf (" that you wish to generate an SY87739L control word for.\n");
165  }/*end if could not parse arguments*/
166 
167  /*---------------------
168  * Always return success.
169  */
170  return OK;
171 
172 }/*end main()*/
epicsShareExtern epicsUInt32 FracSynthControlWord(epicsFloat64 DesiredFreq, epicsFloat64 ReferenceFreq, epicsInt32 debugFlag, epicsFloat64 *Error)
Definition: mrfFracSynth.c:552
#define OK
Definition: mrfFracSynth.h:81
#define ERROR
Definition: mrfFracSynth.h:88
#define DP_ERROR
Definition: debugPrint.h:90
#define DP_NONE
Definition: debugPrint.h:88
#define MRF_FRAC_SYNTH_REF
Definition: mrfCommon.h:99
epicsShareExtern epicsFloat64 FracSynthAnalyze(epicsUInt32 ControlWord, epicsFloat64 ReferenceFreq, epicsInt32 PrintFlag)
Definition: mrfFracSynth.c:844