Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

timing_nco.h

Go to the documentation of this file.
00001 /*
00002  * SPUC - Signal processing using C++ - A DSP library
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2, or (at your option)
00007  * any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 #ifndef TN
00019 #define TN
00020 namespace SPUC {
00021 #define MAX_STEP 4
00022 #define STEP_BITS 3
00023 #define MASK_HI 65535
00024 #define MASK_HIx 63535
00025 #define MASK_LO  65536
00026 #define MASK_LOd2  32768
00027 #define BITS_USED 16
00032 //
00036 class timing_nco
00037 {
00038  protected:
00039         signed long resid1;
00040         signed long acc;
00041         unsigned long fcw;
00042         unsigned long new_fcw;
00043         signed long phase1;
00044         signed long phase2;
00045         signed long new_phase;
00046         long sample2;
00047 public:
00048         inline timing_nco(void) {
00049                 resid1 = 0;
00050                 acc = MASK_LOd2;
00051                 fcw = new_fcw = phase1 = phase2 = 0; 
00052                 sample2 = 1;}
00053         inline void set_frequency(unsigned long freq) { fcw = freq; }
00054         inline void reset_frequency(unsigned long freq) { new_fcw = fcw = freq; }
00055         inline double get_off1(void) { return((double)phase1/MASK_LO);}
00056         inline double get_off2(void) { return((double)phase2/MASK_LO);}
00057         inline long get_phase1(void) { return(-MAX_STEP+phase1);}
00058         inline long get_phase2(void) { return(-MAX_STEP+phase2);}
00059         long run(long loop_filter_out=0, int load=1);
00060         signed long residual_phase(signed long acc_value);
00061 };
00062 #endif
00063 } // namespace SPUC 

Generated on Fri Sep 16 11:02:24 2005 for spuc by  doxygen 1.4.4