renamed the profiling/machdep functions
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 13 Aug 2014 08:41:01 +0000 (08:41 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 13 Aug 2014 08:41:01 +0000 (08:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1795 01035d8c-6547-0410-b346-abe4f91aad63

14 files changed:
codec2-dev/src/codec2.c
codec2-dev/src/fdmdv.c
codec2-dev/src/machdep.h
codec2-dev/src/nlp.c
codec2-dev/src/quantise.c
codec2-dev/stm32/Makefile
codec2-dev/stm32/src/codec2_profile.c
codec2-dev/stm32/src/fdmdv_profile.c
codec2-dev/stm32/src/fft_test.c
codec2-dev/stm32/src/machdep.h [deleted file]
codec2-dev/stm32/src/power_ut.c
codec2-dev/stm32/src/sm1000_main.c
codec2-dev/stm32/src/stm32f4_machdep.c [new file with mode: 0644]
codec2-dev/stm32/src/stm32f4_timer.c [deleted file]

index 09dd757874b7eea94abe654aff010ad281414b6e..a167f76303068a9c31972ed4f99ac42edadb631a 100644 (file)
@@ -974,7 +974,7 @@ void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[])
     int     Wo_index, e_index;
     int     i;
     unsigned int nbit = 0;
-    #ifdef TIMER
+    #ifdef PROFILE
     unsigned int quant_start;
     #endif
 
@@ -1005,8 +1005,8 @@ void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[])
     Wo_index = encode_Wo(model.Wo);
     pack_natural_or_gray(bits, &nbit, Wo_index, WO_BITS, c2->gray);
 
-    #ifdef TIMER
-    quant_start = machdep_timer_sample();
+    #ifdef PROFILE
+    quant_start = machdep_profile_sample();
     #endif
     e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD);
     e_index = encode_energy(e);
@@ -1016,8 +1016,8 @@ void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[])
     for(i=0; i<LSP_SCALAR_INDEXES; i++) {
        pack_natural_or_gray(bits, &nbit, lsp_indexes[i], lsp_bits(i), c2->gray);
     }
-    #ifdef TIMER
-    machdep_timer_sample_and_log(quant_start, "    quant/packing"); 
+    #ifdef PROFILE
+    machdep_profile_sample_and_log(quant_start, "    quant/packing"); 
     #endif
 
     assert(nbit == (unsigned)codec2_bits_per_frame(c2));
@@ -1046,7 +1046,7 @@ void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char *
     int     i,j;
     unsigned int nbit = 0;
     float   weight;
-    TIMER_VAR(recover_start);
+    PROFILE_VAR(recover_start);
     
     assert(c2 != NULL);
 
@@ -1092,7 +1092,7 @@ void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char *
     /* Wo, energy, and LSPs are sampled every 40ms so we interpolate
        the 3 frames in between */
 
-    TIMER_SAMPLE(recover_start);
+    PROFILE_SAMPLE(recover_start);
     for(i=0, weight=0.25; i<3; i++, weight += 0.25) {
        interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight);
         interp_Wo2(&model[i], &c2->prev_model_dec, &model[3], weight);
@@ -1107,7 +1107,7 @@ void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char *
                   c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); 
        apply_lpc_correction(&model[i]);
     }
-    TIMER_SAMPLE_AND_LOG2(recover_start, "    recover"); 
+    PROFILE_SAMPLE_AND_LOG2(recover_start, "    recover"); 
     #ifdef DUMP
     dump_lsp_(&lsps[3][0]);
     dump_ak_(&ak[3][0], LPC_ORD);
@@ -1318,25 +1318,25 @@ void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char *
 void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, float ak[])
 {
     int     i;
-    TIMER_VAR(phase_start, pf_start, synth_start);
+    PROFILE_VAR(phase_start, pf_start, synth_start);
 
     #ifdef DUMP
     dump_quantised_model(model);
     #endif
 
-    TIMER_SAMPLE(phase_start);
+    PROFILE_SAMPLE(phase_start);
 
     phase_synth_zero_order(c2->fft_fwd_cfg, model, ak, &c2->ex_phase, LPC_ORD);
 
-    TIMER_SAMPLE_AND_LOG(pf_start,phase_start, "    phase_synth"); 
+    PROFILE_SAMPLE_AND_LOG(pf_start,phase_start, "    phase_synth"); 
 
     postfilter(model, &c2->bg_est);
 
-    TIMER_SAMPLE_AND_LOG(synth_start, pf_start, "    postfilter"); 
+    PROFILE_SAMPLE_AND_LOG(synth_start, pf_start, "    postfilter"); 
 
     synthesise(c2->fft_inv_cfg, c2->Sn_, model, c2->Pn, 1);
 
-    TIMER_SAMPLE_AND_LOG2(synth_start, "    synth"); 
+    PROFILE_SAMPLE_AND_LOG2(synth_start, "    synth"); 
 
     ear_protection(c2->Sn_, N);
 
@@ -1369,7 +1369,7 @@ void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[])
     COMP    Ew[FFT_ENC];
     float   pitch;
     int     i;
-    TIMER_VAR(dft_start, nlp_start, model_start, two_stage, estamps);
+    PROFILE_VAR(dft_start, nlp_start, model_start, two_stage, estamps);
 
     /* Read input speech */
 
@@ -1378,14 +1378,14 @@ void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[])
     for(i=0; i<N; i++)
       c2->Sn[i+M-N] = speech[i];
 
-    TIMER_SAMPLE(dft_start);
+    PROFILE_SAMPLE(dft_start);
     dft_speech(c2->fft_fwd_cfg, Sw, c2->Sn, c2->w);
-    TIMER_SAMPLE_AND_LOG(nlp_start, dft_start, "    dft_speech");
+    PROFILE_SAMPLE_AND_LOG(nlp_start, dft_start, "    dft_speech");
 
     /* Estimate pitch */
 
     nlp(c2->nlp,c2->Sn,N,P_MIN,P_MAX,&pitch,Sw, c2->W, &c2->prev_Wo_enc);
-    TIMER_SAMPLE_AND_LOG(model_start, nlp_start, "    nlp"); 
+    PROFILE_SAMPLE_AND_LOG(model_start, nlp_start, "    nlp"); 
 
     model->Wo = TWO_PI/pitch;
     model->L = PI/model->Wo;
@@ -1393,12 +1393,12 @@ void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[])
     /* estimate model parameters */
 
     two_stage_pitch_refinement(model, Sw);
-    TIMER_SAMPLE_AND_LOG(two_stage, model_start, "    two_stage"); 
+    PROFILE_SAMPLE_AND_LOG(two_stage, model_start, "    two_stage"); 
     estimate_amplitudes(model, Sw, c2->W, 0);
-    TIMER_SAMPLE_AND_LOG(estamps, two_stage, "    est_amps"); 
+    PROFILE_SAMPLE_AND_LOG(estamps, two_stage, "    est_amps"); 
     est_voicing_mbe(model, Sw, c2->W, Sw_, Ew);
     c2->prev_Wo_enc = model->Wo;
-    TIMER_SAMPLE_AND_LOG2(estamps, "    est_voicing"); 
+    PROFILE_SAMPLE_AND_LOG2(estamps, "    est_voicing"); 
     #ifdef DUMP
     dump_model(model);
     #endif
index 2f6bf61fc99e57fa8f02f18cf7eee492d4a56743..2841f74d27a6cbe05692fe05aafc62391588e4c2 100644 (file)
@@ -553,16 +553,16 @@ void fdmdv_mod(struct FDMDV *fdmdv, COMP tx_fdm[], int tx_bits[], int *sync_bit)
 {
     COMP          tx_symbols[NC+1];
     COMP          tx_baseband[NC+1][M];
-    TIMER_VAR(mod_start, tx_filter_start, fdm_upconvert_start);
+    PROFILE_VAR(mod_start, tx_filter_start, fdm_upconvert_start);
 
-    TIMER_SAMPLE(mod_start);
+    PROFILE_SAMPLE(mod_start);
     bits_to_dqpsk_symbols(tx_symbols, fdmdv->Nc, fdmdv->prev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, fdmdv->old_qpsk_mapping);
     memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(fdmdv->Nc+1));
-    TIMER_SAMPLE_AND_LOG(tx_filter_start, mod_start, "    bits_to_dqpsk_symbols"); 
+    PROFILE_SAMPLE_AND_LOG(tx_filter_start, mod_start, "    bits_to_dqpsk_symbols"); 
     tx_filter(tx_baseband, fdmdv->Nc, tx_symbols, fdmdv->tx_filter_memory);
-    TIMER_SAMPLE_AND_LOG(fdm_upconvert_start, tx_filter_start, "    tx_filter"); 
+    PROFILE_SAMPLE_AND_LOG(fdm_upconvert_start, tx_filter_start, "    tx_filter"); 
     fdm_upconvert(tx_fdm, fdmdv->Nc, tx_baseband, fdmdv->phase_tx, fdmdv->freq, &fdmdv->fbb_phase_tx, fdmdv->fbb_rect);
-    TIMER_SAMPLE_AND_LOG2(fdm_upconvert_start, "    fdm_upconvert"); 
+    PROFILE_SAMPLE_AND_LOG2(fdm_upconvert_start, "    fdm_upconvert"); 
 
     *sync_bit = fdmdv->tx_pilot_bit;
 }
@@ -1001,7 +1001,7 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
     COMP  rx_baseband[NFILTER+M];
     COMP  f_rect;
 
-    //TIMER_VAR(windback_start,  downconvert_start, filter_start);
+    //PROFILE_VAR(windback_start,  downconvert_start, filter_start);
 
     /* update memory of rx_fdm */
 
@@ -1025,12 +1025,12 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
           phase continuity.
         */
 
-        //TIMER_SAMPLE(windback_start);
+        //PROFILE_SAMPLE(windback_start);
         windback_phase           = -freq_pol[c]*NFILTER;
         windback_phase_rect.real = cosf(windback_phase);
         windback_phase_rect.imag = sinf(windback_phase);
         phase_rx[c]              = cmult(phase_rx[c],windback_phase_rect);
-        //TIMER_SAMPLE_AND_LOG(downconvert_start, windback_start, "        windback"); 
+        //PROFILE_SAMPLE_AND_LOG(downconvert_start, windback_start, "        windback"); 
     
         /* down convert all samples in buffer */
 
@@ -1048,7 +1048,7 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
             phase_rx[c]    = cmult(phase_rx[c], f_rect);
             rx_baseband[i] = cmult(rx_fdm_mem[i],cconj(phase_rx[c]));
         }
-        //TIMER_SAMPLE_AND_LOG(filter_start, downconvert_start, "        downconvert"); 
+        //PROFILE_SAMPLE_AND_LOG(filter_start, downconvert_start, "        downconvert"); 
  
         /* now we can filter this carrier's P symbols */
 
@@ -1064,7 +1064,7 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
            rx_filt[c][k].imag = fir_filter(&rx_baseband[st+i].imag, (float*)gt_alpha5_root, dec_rate);
            #endif
         }
-        //TIMER_SAMPLE_AND_LOG2(filter_start, "        filter"); 
+        //PROFILE_SAMPLE_AND_LOG2(filter_start, "        filter"); 
 
         /* normalise digital oscilators as the magnitude can drift over time */
 
@@ -1478,8 +1478,8 @@ void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[],
     COMP          rx_symbols[NC+1];
     float         env[NT*P];
     int           sync_bit;
-    TIMER_VAR(demod_start, fdmdv_freq_shift_start, down_convert_and_rx_filter_start);
-    TIMER_VAR(rx_est_timing_start, qpsk_to_bits_start, snr_update_start, freq_state_start);
+    PROFILE_VAR(demod_start, fdmdv_freq_shift_start, down_convert_and_rx_filter_start);
+    PROFILE_VAR(rx_est_timing_start, qpsk_to_bits_start, snr_update_start, freq_state_start);
 
     /* shift down to complex baseband */
 
@@ -1487,23 +1487,23 @@ void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[],
 
     /* freq offset estimation and correction */
    
-    TIMER_SAMPLE(demod_start);
+    PROFILE_SAMPLE(demod_start);
     foff_coarse = rx_est_freq_offset(fdmdv, rx_fdm_bb, *nin);
-    TIMER_SAMPLE_AND_LOG(fdmdv_freq_shift_start, demod_start, "    rx_est_freq_offset"); 
+    PROFILE_SAMPLE_AND_LOG(fdmdv_freq_shift_start, demod_start, "    rx_est_freq_offset"); 
     
     if (fdmdv->sync == 0)
        fdmdv->foff = foff_coarse;
     fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm_bb, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin);
-    TIMER_SAMPLE_AND_LOG(down_convert_and_rx_filter_start, fdmdv_freq_shift_start, "    fdmdv_freq_shift"); 
+    PROFILE_SAMPLE_AND_LOG(down_convert_and_rx_filter_start, fdmdv_freq_shift_start, "    fdmdv_freq_shift"); 
        
     /* baseband processing */
 
     rxdec_filter(rx_fdm_filter, rx_fdm_fcorr, fdmdv->rxdec_lpf_mem, *nin);
     down_convert_and_rx_filter(rx_filt, fdmdv->Nc, rx_fdm_filter, fdmdv->rx_fdm_mem, fdmdv->phase_rx, fdmdv->freq, 
                                fdmdv->freq_pol, *nin, M/Q);
-    TIMER_SAMPLE_AND_LOG(rx_est_timing_start, down_convert_and_rx_filter_start, "    down_convert_and_rx_filter"); 
+    PROFILE_SAMPLE_AND_LOG(rx_est_timing_start, down_convert_and_rx_filter_start, "    down_convert_and_rx_filter"); 
     fdmdv->rx_timing = rx_est_timing(rx_symbols, fdmdv->Nc, rx_filt, fdmdv->rx_filter_mem_timing, env, *nin);   
-    TIMER_SAMPLE_AND_LOG(qpsk_to_bits_start, rx_est_timing_start, "    rx_est_timing"); 
+    PROFILE_SAMPLE_AND_LOG(qpsk_to_bits_start, rx_est_timing_start, "    rx_est_timing"); 
     
     /* Adjust number of input samples to keep timing within bounds */
 
@@ -1518,14 +1518,14 @@ void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[],
     foff_fine = qpsk_to_bits(rx_bits, &sync_bit, fdmdv->Nc, fdmdv->phase_difference, fdmdv->prev_rx_symbols, rx_symbols, 
                              fdmdv->old_qpsk_mapping);
     memcpy(fdmdv->prev_rx_symbols, rx_symbols, sizeof(COMP)*(fdmdv->Nc+1));
-    TIMER_SAMPLE_AND_LOG(snr_update_start, qpsk_to_bits_start, "    qpsk_to_bits"); 
+    PROFILE_SAMPLE_AND_LOG(snr_update_start, qpsk_to_bits_start, "    qpsk_to_bits"); 
     snr_update(fdmdv->sig_est, fdmdv->noise_est, fdmdv->Nc, fdmdv->phase_difference);
-    TIMER_SAMPLE_AND_LOG(freq_state_start, snr_update_start, "    snr_update"); 
+    PROFILE_SAMPLE_AND_LOG(freq_state_start, snr_update_start, "    snr_update"); 
 
     /* freq offset estimation state machine */
 
     fdmdv->sync = freq_state(reliable_sync_bit, sync_bit, &fdmdv->fest_state, &fdmdv->timer, fdmdv->sync_mem);
-    TIMER_SAMPLE_AND_LOG2(freq_state_start, "    freq_state"); 
+    PROFILE_SAMPLE_AND_LOG2(freq_state_start, "    freq_state"); 
     fdmdv->foff  -= TRACK_COEFF*foff_fine;
 }
 
index ef2e64943e6464a6ea13e289bd9c631afd1880dd..4dff9ba52f5dd12ecc9cb03410c45b876366966b 100644 (file)
@@ -4,7 +4,8 @@
   AUTHOR......: David Rowe
   DATE CREATED: May 2 2013
 
-  Machine dependant functions.
+  Machine dependant functions, e.g. profiling that requires access to a clock
+  counter register.
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef __MACHDEP__
 #define __MACHDEP__
 
-#ifdef TIMER
-#define TIMER_VAR(...) unsigned int __VA_ARGS__
-#define TIMER_SAMPLE(timestamp) timestamp = machdep_timer_sample()
-#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \
-    timestamp = machdep_timer_sample_and_log(prev_timestamp, label)
-#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label) \
-    machdep_timer_sample_and_log(prev_timestamp, label)
+#ifdef PROFILE
+#define PROFILE_VAR(...) unsigned int __VA_ARGS__
+#define PROFILE_SAMPLE(timestamp) timestamp = machdep_profile_sample()
+#define PROFILE_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \
+    timestamp = machdep_profile_sample_and_log(prev_timestamp, label)
+#define PROFILE_SAMPLE_AND_LOG2(prev_timestamp, label) \
+    machdep_profile_sample_and_log(prev_timestamp, label)
 #else
-#define TIMER_VAR(...)
-#define TIMER_SAMPLE(timestamp)
-#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label)
-#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label)
+#define PROFILE_VAR(...)
+#define PROFILE_SAMPLE(timestamp)
+#define PROFILE_SAMPLE_AND_LOG(timestamp, prev_timestamp, label)
+#define PROFILE_SAMPLE_AND_LOG2(prev_timestamp, label)
 #endif
 
-void         machdep_timer_init(void);
-void         machdep_timer_reset(void);
-unsigned int machdep_timer_sample(void);
-unsigned int machdep_timer_sample_and_log(unsigned int start, char s[]);
-void         machdep_timer_print_logged_samples(void);
+void         machdep_profile_init(void);
+void         machdep_profile_reset(void);
+unsigned int machdep_profile_sample(void);
+unsigned int machdep_profile_sample_and_log(unsigned int start, char s[]);
+void         machdep_profile_print_logged_samples(void);
 
 #endif
index 7d842e536c3dd12d55329b53004e443937c7e96d..9ed0561625247b1e41521ee7620bf8e91300c610 100644 (file)
@@ -29,7 +29,7 @@
 #include "nlp.h"
 #include "dump.h"
 #include "kiss_fft.h"
-#undef TIMER
+#undef PROFILE
 #include "machdep.h"
 
 #include <assert.h>
@@ -236,13 +236,13 @@ float nlp(
     int    gmax_bin;
     int    m, i,j;
     float  best_f0;
-    TIMER_VAR(start, tnotch, filter, peakpick, window, fft, magsq, shiftmem);
+    PROFILE_VAR(start, tnotch, filter, peakpick, window, fft, magsq, shiftmem);
     
     assert(nlp_state != NULL);
     nlp = (NLP*)nlp_state;
     m = nlp->m;
 
-    TIMER_SAMPLE(start);
+    PROFILE_SAMPLE(start);
 
     /* Square, notch filter at DC, and LP filter vector */
 
@@ -264,7 +264,7 @@ float nlp(
                                      exactly sure why. */
     }
 
-    TIMER_SAMPLE_AND_LOG(tnotch, start, "      square and notch");
+    PROFILE_SAMPLE_AND_LOG(tnotch, start, "      square and notch");
 
     for(i=m-n; i<m; i++) {     /* FIR filter vector */
 
@@ -277,7 +277,7 @@ float nlp(
            nlp->sq[i] += nlp->mem_fir[j]*nlp_fir[j];
     }
 
-    TIMER_SAMPLE_AND_LOG(filter, tnotch, "      filter");
+    PROFILE_SAMPLE_AND_LOG(filter, tnotch, "      filter");
  
     /* Decimate and DFT */
 
@@ -288,18 +288,18 @@ float nlp(
     for(i=0; i<m/DEC; i++) {
        fw[i].real = nlp->sq[i*DEC]*nlp->w[i];
     }
-    TIMER_SAMPLE_AND_LOG(window, filter, "      window");
+    PROFILE_SAMPLE_AND_LOG(window, filter, "      window");
     #ifdef DUMP
     dump_dec(Fw);
     #endif
 
     kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw);
-    TIMER_SAMPLE_AND_LOG(fft, window, "      fft");
+    PROFILE_SAMPLE_AND_LOG(fft, window, "      fft");
 
     for(i=0; i<PE_FFT_SIZE; i++)
        Fw[i].real = Fw[i].real*Fw[i].real + Fw[i].imag*Fw[i].imag;
 
-    TIMER_SAMPLE_AND_LOG(magsq, fft, "      mag sq");
+    PROFILE_SAMPLE_AND_LOG(magsq, fft, "      mag sq");
     #ifdef DUMP
     dump_sq(nlp->sq);
     dump_Fw(Fw);
@@ -316,7 +316,7 @@ float nlp(
        }
     }
     
-    TIMER_SAMPLE_AND_LOG(peakpick, magsq, "      peak pick");
+    PROFILE_SAMPLE_AND_LOG(peakpick, magsq, "      peak pick");
 
     //#define POST_PROCESS_MBE
     #ifdef POST_PROCESS_MBE
@@ -325,7 +325,7 @@ float nlp(
     best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, prev_Wo);
     #endif
 
-    TIMER_SAMPLE_AND_LOG(shiftmem, peakpick,  "      post process");
+    PROFILE_SAMPLE_AND_LOG(shiftmem, peakpick,  "      post process");
 
     /* Shift samples in buffer to make room for new samples */
 
@@ -336,9 +336,9 @@ float nlp(
 
     *pitch = (float)SAMPLE_RATE/best_f0;
 
-    TIMER_SAMPLE_AND_LOG2(shiftmem,  "      shift mem");
+    PROFILE_SAMPLE_AND_LOG2(shiftmem,  "      shift mem");
 
-    TIMER_SAMPLE_AND_LOG2(start,  "      nlp int");
+    PROFILE_SAMPLE_AND_LOG2(start,  "      nlp int");
 
     return(best_f0);  
 }
index b3431bd10e39f95b8d61091651ac867c121a53ce..429a6add49dd732e82dc75e1506a6b31dacdbfd1 100644 (file)
@@ -37,7 +37,7 @@
 #include "lpc.h"
 #include "lsp.h"
 #include "kiss_fft.h"
-#undef TIMER
+#undef PROFILE
 #include "machdep.h"
 
 #define LSP_DELTA1 0.01         /* grid spacing for LSP root searches */
@@ -796,9 +796,9 @@ void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, COMP Pw[], float ak[],
     float Pfw;
     float max_Rw, min_Rw;
     float coeff;
-    TIMER_VAR(tstart, tfft1, taw, tfft2, tww, tr);
+    PROFILE_VAR(tstart, tfft1, taw, tfft2, tww, tr);
 
-    TIMER_SAMPLE(tstart);
+    PROFILE_SAMPLE(tstart);
 
     /* Determine LPC inverse filter spectrum 1/A(exp(jw)) -----------*/
 
@@ -816,13 +816,13 @@ void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, COMP Pw[], float ak[],
        x[i].real = ak[i];
     kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)x, (kiss_fft_cpx *)Aw);
 
-    TIMER_SAMPLE_AND_LOG(tfft1, tstart, "        fft1"); 
+    PROFILE_SAMPLE_AND_LOG(tfft1, tstart, "        fft1"); 
 
     for(i=0; i<FFT_ENC/2; i++) {
        Aw[i].real = 1.0/(Aw[i].real*Aw[i].real + Aw[i].imag*Aw[i].imag);
     }
 
-    TIMER_SAMPLE_AND_LOG(taw, tfft1, "        Aw"); 
+    PROFILE_SAMPLE_AND_LOG(taw, tfft1, "        Aw"); 
 
     /* Determine weighting filter spectrum W(exp(jw)) ---------------*/
 
@@ -839,13 +839,13 @@ void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, COMP Pw[], float ak[],
     }
     kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)x, (kiss_fft_cpx *)Ww);
 
-    TIMER_SAMPLE_AND_LOG(tfft2, taw, "        fft2"); 
+    PROFILE_SAMPLE_AND_LOG(tfft2, taw, "        fft2"); 
 
     for(i=0; i<FFT_ENC/2; i++) {
        Ww[i].real = Ww[i].real*Ww[i].real + Ww[i].imag*Ww[i].imag;
     }
 
-    TIMER_SAMPLE_AND_LOG(tww, tfft2, "        Ww"); 
+    PROFILE_SAMPLE_AND_LOG(tww, tfft2, "        Ww"); 
 
     /* Determined combined filter R = WA ---------------------------*/
 
@@ -859,7 +859,7 @@ void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, COMP Pw[], float ak[],
 
     }
 
-    TIMER_SAMPLE_AND_LOG(tr, tww, "        R"); 
+    PROFILE_SAMPLE_AND_LOG(tr, tww, "        R"); 
 
     #ifdef DUMP
     if (dump)
@@ -903,7 +903,7 @@ void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, COMP Pw[], float ak[],
         }    
     }
 
-    TIMER_SAMPLE_AND_LOG2(tr, "        filt"); 
+    PROFILE_SAMPLE_AND_LOG2(tr, "        filt"); 
 }
 
 
@@ -940,9 +940,9 @@ void aks_to_M2(
   float Em;            /* energy in band */
   float Am;            /* spectral amplitude sample */
   float signal, noise;
-  TIMER_VAR(tstart, tfft, tpw, tpf);
+  PROFILE_VAR(tstart, tfft, tpw, tpf);
 
-  TIMER_SAMPLE(tstart);
+  PROFILE_SAMPLE(tstart);
 
   r = TWO_PI/(FFT_ENC);
 
@@ -957,19 +957,19 @@ void aks_to_M2(
     pw[i].real = ak[i];
   kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)pw, (kiss_fft_cpx *)Pw);
   
-  TIMER_SAMPLE_AND_LOG(tfft, tstart, "      fft"); 
+  PROFILE_SAMPLE_AND_LOG(tfft, tstart, "      fft"); 
 
   /* Determine power spectrum P(w) = E/(A(exp(jw))^2 ------------------------*/
 
   for(i=0; i<FFT_ENC/2; i++)
     Pw[i].real = E/(Pw[i].real*Pw[i].real + Pw[i].imag*Pw[i].imag);
 
-  TIMER_SAMPLE_AND_LOG(tpw, tfft, "      Pw"); 
+  PROFILE_SAMPLE_AND_LOG(tpw, tfft, "      Pw"); 
 
   if (pf)
       lpc_post_filter(fft_fwd_cfg, Pw, ak, order, dump, beta, gamma, bass_boost);
 
-  TIMER_SAMPLE_AND_LOG(tpf, tpw, "      LPC post filter"); 
+  PROFILE_SAMPLE_AND_LOG(tpf, tpw, "      LPC post filter"); 
 
   #ifdef DUMP
   if (dump) 
@@ -1014,7 +1014,7 @@ void aks_to_M2(
   }
   *snr = 10.0*log10f(signal/noise);
 
-  TIMER_SAMPLE_AND_LOG2(tpf, "      rec"); 
+  PROFILE_SAMPLE_AND_LOG2(tpf, "      rec"); 
 }
 
 /*---------------------------------------------------------------------------*\
index dcf055a262f10e78bc972f5f383558f1eabe2bb3..d8c69c3217929306ddcd61b7d80afc84bddcf5b1 100644 (file)
@@ -82,7 +82,7 @@ FFT_TEST_SRCS = \
 $(DSPLIB)/Examples/arm_fft_bin_example/arm_fft_bin_data.c \
 fft_test.c \
 src/startup_stm32f4xx.s \
-stm32f4_timer.c \
+stm32f4_machdep.c \
 gdb_stdio.c \
 ../src/kiss_fft.c
 
@@ -109,7 +109,7 @@ OBJS = $(SRCS:.c=.o)
 
 ###################################################
 
-all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf fdmdv_profile.elf sm1000_leds_switches_ut.elf sm1000.elf adcdac_ut.elf
+all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf fdmdv_profile.elf sm1000_leds_switches_ut.elf sm1000.elf adcdac_ut.elf freedv_profile.elf
 
 dl/$(PERIPHLIBZIP):
        mkdir -p dl
@@ -130,14 +130,14 @@ libstm32f4.a: $(PERIPHLIBDIR)
 CODEC2_PROFILE_SRCS=\
 src/codec2_profile.c \
 src/gdb_stdio.c \
-src/stm32f4_timer.c \
+src/stm32f4_machdep.c \
 src/startup_stm32f4xx.s \
 src/init.c \
 src/system_stm32f4xx.c
 CODEC2_PROFILE_SRCS += $(CODEC2_SRCS)
 
 codec2_profile.elf: $(CODEC2_PROFILE_SRCS) 
-       $(CC) $(CFLAGS) -DTIMER $^ -o $@ $(LIBPATHS) $(LIBS)
+       $(CC) $(CFLAGS) -DPROFILE $^ -o $@ $(LIBPATHS) $(LIBS)
 
 fft_test.elf: $(FFT_TEST_SRCS)
        $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS)
@@ -213,7 +213,7 @@ src/debugblinky.c \
 src/system_stm32f4xx.c \
 src/startup_stm32f4xx.s \
 src/init.c \
-src/stm32f4_timer.c \
+src/stm32f4_machdep.c \
 
 POWER_UT_SRCS += $(CODEC2_SRCS)
 
@@ -226,12 +226,12 @@ gdb_stdio.c \
 src/system_stm32f4xx.c \
 src/startup_stm32f4xx.s \
 src/init.c \
-src/stm32f4_timer.c
+src/stm32f4_machdep.c
 
 FDMDV_PROFILE_SRCS += $(CODEC2_SRCS)
 
 fdmdv_profile.elf: $(FDMDV_PROFILE_SRCS)
-       $(CC) $(CFLAGS) -DTIMER $^ -o $@ $(LIBPATHS) $(LIBS)
+       $(CC) $(CFLAGS) -DPROFILE $^ -o $@ $(LIBPATHS) $(LIBS)
 
 SM1000_LEDS_SWITCHES_UT_SRCS=\
 src/sm1000_leds_switches_ut.c \
@@ -263,6 +263,19 @@ src/stm32f4_adc.o: src/stm32f4_adc.c
 sm1000.elf: $(SM1000_SRCS) src/stm32f4_dac.o src/stm32f4_adc.o
        $(CC) $(CFLAGS) -O3 $^ -o $@ $(LIBPATHS) $(LIBS)
 
+FREEDV_PROFILE_SRCS=\
+src/freedv_profile.c \
+src/stm32f4_machdep.c \
+gdb_stdio.c \
+src/system_stm32f4xx.c \
+src/startup_stm32f4xx.s \
+src/init.c 
+
+FREEDV_PROFILE_SRCS += $(CODEC2_SRCS)
+
+freedv_profile.elf: $(FREEDV_PROFILE_SRCS)
+       $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS)
+
 clean:
        rm -f *.o
        rm -f *.elf
index 7a6a28c06df005f9c4a14e9ce6021a92200e791c..c8c6e0ef29810a805161fb603af384178aa58190 100644 (file)
@@ -54,7 +54,7 @@ static void c2demo(int mode, char inputfile[], char outputfile[])
     int            nsam, nbit;\r
     FILE          *fin, *fout;\r
     int            frame;\r
-    TIMER_VAR(enc_start, dec_start);\r
+    PROFILE_VAR(enc_start, dec_start);\r
 \r
     codec2 = codec2_create(mode);\r
     nsam = codec2_samples_per_frame(codec2);\r
@@ -81,15 +81,15 @@ static void c2demo(int mode, char inputfile[], char outputfile[])
     frame = 0;\r
 \r
     while (fread(inbuf, sizeof(short), nsam, fin) == nsam) {\r
-        TIMER_SAMPLE(enc_start);\r
+        PROFILE_SAMPLE(enc_start);\r
         codec2_encode(codec2, bits, inbuf);\r
-        TIMER_SAMPLE_AND_LOG(dec_start, enc_start, "  enc");     \r
+        PROFILE_SAMPLE_AND_LOG(dec_start, enc_start, "  enc");     \r
        codec2_decode(codec2, outbuf, bits);\r
-        TIMER_SAMPLE_AND_LOG2(dec_start, "  dec");     \r
-        TIMER_SAMPLE_AND_LOG2(enc_start, "  enc & dec");     \r
+        PROFILE_SAMPLE_AND_LOG2(dec_start, "  dec");     \r
+        PROFILE_SAMPLE_AND_LOG2(enc_start, "  enc & dec");     \r
         fwrite((char*)outbuf, sizeof(short), nsam, fout);\r
         printf("frame: %d\n", ++frame);\r
-        machdep_timer_print_logged_samples();\r
+        machdep_profile_print_logged_samples();\r
     }\r
 \r
     #ifdef DUMP\r
@@ -159,7 +159,7 @@ void gpio_init() {
 \r
 int main(int argc, char *argv[]) {\r
     gpio_init();\r
-    machdep_timer_init ();\r
+    machdep_profile_init ();\r
  \r
     printf("Starting c2demo\n");\r
 \r
index 988152e430c3f29a914b46eac0389d118d7074ad..06dc512912f05f5d1c403f9a7a77ea02228cb1bc 100644 (file)
@@ -91,9 +91,9 @@ int main(int argc, char *argv[]) {
     int                 i, j, nin, reliable_sync_bit[2], sync_bit, bit_errors, ntest_bits, test_frame_sync;\r
     short              *error_pattern;\r
     struct FDMDV_STATS  stats;\r
-    TIMER_VAR(mod_start, demod_start);\r
+    PROFILE_VAR(mod_start, demod_start);\r
 \r
-    machdep_timer_init ();\r
+    machdep_profile_init ();\r
     fdmdv = fdmdv_create(FDMDV_NC);\r
 \r
     bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv);\r
@@ -110,7 +110,7 @@ int main(int argc, char *argv[]) {
        fdmdv_get_test_bits(fdmdv, tx_bits);\r
        fdmdv_get_test_bits(fdmdv, &tx_bits[bits_per_fdmdv_frame]);\r
 \r
-        TIMER_SAMPLE(mod_start);\r
+        PROFILE_SAMPLE(mod_start);\r
 \r
        fdmdv_mod(fdmdv, tx_fdm, tx_bits, &sync_bit);\r
        assert(sync_bit == 1);\r
@@ -118,7 +118,7 @@ int main(int argc, char *argv[]) {
        assert(sync_bit == 0);\r
         channel_in(tx_fdm, 2*FDMDV_NOM_SAMPLES_PER_FRAME);\r
 \r
-        TIMER_SAMPLE_AND_LOG(demod_start, mod_start, "  mod");     \r
+        PROFILE_SAMPLE_AND_LOG(demod_start, mod_start, "  mod");     \r
 \r
         for(j=0; j<2; j++) {\r
             channel_out(rx_fdm, nin);\r
@@ -131,15 +131,15 @@ int main(int argc, char *argv[]) {
                 fdmdv_put_test_bits(fdmdv, &test_frame_sync, error_pattern, &bit_errors, &ntest_bits, &codec_bits[bits_per_fdmdv_frame]);\r
             }\r
         }\r
-        TIMER_SAMPLE_AND_LOG2(demod_start, "  demod");     \r
-        TIMER_SAMPLE_AND_LOG2(mod_start, "  mod & demod");     \r
+        PROFILE_SAMPLE_AND_LOG2(demod_start, "  demod");     \r
+        PROFILE_SAMPLE_AND_LOG2(mod_start, "  mod & demod");     \r
 \r
         fdmdv_get_demod_stats(fdmdv, &stats);\r
 \r
         printf("frame: %d sync: %d reliable_sync_bit: %d %d SNR: %3.2f test_frame_sync: %d\n", \r
                i, stats.sync, reliable_sync_bit[0], reliable_sync_bit[1], (double)stats.snr_est, \r
                test_frame_sync);\r
-        machdep_timer_print_logged_samples();\r
+        machdep_profile_print_logged_samples();\r
     }\r
 \r
     fdmdv_destroy(fdmdv);\r
index cc25653b5e4b178a4c6f091aeac898a2b686f622..cc838d15deafeab30df1713acb3df5b272999a79 100644 (file)
@@ -119,12 +119,12 @@ int main(void)
         kiss_fft_cfg fft_fwd_cfg;\r
 \r
         SystemInit();\r
-        machdep_timer_init();\r
+        machdep_profile_init();\r
         fft_fwd_cfg = kiss_fft_alloc(fftSize, 0, NULL, NULL);\r
-        kiss_fft_start = machdep_timer_sample();       \r
+        kiss_fft_start = machdep_profile_sample();     \r
         kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)testInput_f32_10khz, \r
                  (kiss_fft_cpx *)kiss_complex_out);\r
-        machdep_timer_sample_and_log(kiss_fft_start, "  kiss_fft");     \r
+        machdep_profile_sample_and_log(kiss_fft_start, "  kiss_fft");     \r
  \r
        status = ARM_MATH_SUCCESS; \r
         \r
@@ -132,10 +132,10 @@ int main(void)
        status = arm_cfft_radix2_init_f32(&S, fftSize, ifftFlag, doBitReverse);          \r
 \r
        /* Process the data through the CFFT/CIFFT module */ \r
-        fft_start = machdep_timer_sample();    \r
+        fft_start = machdep_profile_sample();  \r
         arm_cfft_radix2_f32(&S, testInput_f32_10khz); \r
-        machdep_timer_sample_and_log(fft_start, "  fft");     \r
-        machdep_timer_print_logged_samples();\r
+        machdep_profile_sample_and_log(fft_start, "  fft");     \r
+        machdep_profile_print_logged_samples();\r
 \r
        /* Process the data through the Complex Magnitude Module for  \r
        calculating the magnitude at each bin */ \r
diff --git a/codec2-dev/stm32/src/machdep.h b/codec2-dev/stm32/src/machdep.h
deleted file mode 100644 (file)
index ef2e649..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*---------------------------------------------------------------------------*\
-
-  FILE........: machdep.h
-  AUTHOR......: David Rowe
-  DATE CREATED: May 2 2013
-
-  Machine dependant functions.
-
-\*---------------------------------------------------------------------------*/
-
-/*
-  Copyright (C) 2013 David Rowe
-
-  All rights reserved.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU Lesser General Public License version 2.1, as
-  published by the Free Software Foundation.  This program is
-  distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-  License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __MACHDEP__
-#define __MACHDEP__
-
-#ifdef TIMER
-#define TIMER_VAR(...) unsigned int __VA_ARGS__
-#define TIMER_SAMPLE(timestamp) timestamp = machdep_timer_sample()
-#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \
-    timestamp = machdep_timer_sample_and_log(prev_timestamp, label)
-#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label) \
-    machdep_timer_sample_and_log(prev_timestamp, label)
-#else
-#define TIMER_VAR(...)
-#define TIMER_SAMPLE(timestamp)
-#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label)
-#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label)
-#endif
-
-void         machdep_timer_init(void);
-void         machdep_timer_reset(void);
-unsigned int machdep_timer_sample(void);
-unsigned int machdep_timer_sample_and_log(unsigned int start, char s[]);
-void         machdep_timer_print_logged_samples(void);
-
-#endif
index bc701d54405d75604fd398fa22b12ee2ee8a6677..267d5f9937dc07a8f41f71c0d73d97996aaa5452 100644 (file)
@@ -120,7 +120,7 @@ void gpio_init() {
 int main(int argc, char *argv[]) {\r
     SystemInit();\r
     gpio_init();\r
-    machdep_timer_init ();\r
+    machdep_profile_init ();\r
     adc_open(4*DAC_BUF_SZ);\r
     dac_open(4*DAC_BUF_SZ);\r
 \r
index 138d84ffc2adfe6e5828a929286eb97dafef9cdd..9b6cbbdd1e89f42e26e39a32aea6f22b2795e0ee 100644 (file)
@@ -67,6 +67,7 @@ int main(void) {
        [ ] switch debouncing?\r
        [ ] light led with bit errors\r
        [ ] 16 to 8 kHz rate conversion\r
+       [ ] change freedv_api interface to float[]\r
     */\r
 \r
     /* clear filter memories */\r
diff --git a/codec2-dev/stm32/src/stm32f4_machdep.c b/codec2-dev/stm32/src/stm32f4_machdep.c
new file mode 100644 (file)
index 0000000..5dd39c4
--- /dev/null
@@ -0,0 +1,86 @@
+
+/*---------------------------------------------------------------------------*\
+
+  FILE........: stm32f4_machdep.c
+  AUTHOR......: David Rowe
+  DATE CREATED: May 2 2013
+
+  STM32F4 implementation of the machine dependant timer functions,
+  e.g. profiling using a clock cycle counter..
+
+\*---------------------------------------------------------------------------*/
+
+/*
+  Copyright (C) 2013 David Rowe
+
+  All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License version 2.1, as
+  published by the Free Software Foundation.  This program is
+  distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <string.h>
+#include "machdep.h"
+#include "gdb_stdio.h"
+
+volatile unsigned int *DWT_CYCCNT   = (volatile unsigned int *)0xE0001004; 
+volatile unsigned int *DWT_CONTROL  = (volatile unsigned int *)0xE0001000;
+volatile unsigned int *SCB_DEMCR    = (volatile unsigned int *)0xE000EDFC;
+#define CORE_CLOCK 168E6
+#define BUF_SZ     4096
+
+static char buf[BUF_SZ];
+
+void machdep_profile_init(void)
+{
+    static int enabled = 0;
+    if (!enabled) {
+        *SCB_DEMCR = *SCB_DEMCR | 0x01000000;
+        *DWT_CYCCNT = 0; // reset the counter
+        *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter
+        enabled = 1;
+    }
+    *buf = 0;
+}
+
+void machdep_profile_reset(void)
+{
+    *DWT_CYCCNT = 0; // reset the counter
+}
+
+unsigned int machdep_profile_sample(void) {
+    return *DWT_CYCCNT;
+}
+
+/* log to a buffer, we only call printf after timing finished as it is slow */
+
+unsigned int machdep_profile_sample_and_log(unsigned int start, char s[])
+{
+    char  tmp[80];
+    float msec;
+
+    unsigned int dwt = *DWT_CYCCNT - start;
+    msec = 1000.0*(float)dwt/CORE_CLOCK;
+    sprintf(tmp, "%s %5.2f msecs\n",s,(double)msec);
+    if ((strlen(buf) + strlen(tmp)) < BUF_SZ)
+        strcat(buf, tmp);
+    return *DWT_CYCCNT;
+}
+
+void machdep_profile_print_logged_samples(void)
+{
+    gdb_stdio_printf("%s", buf);
+    *buf = 0;
+}
diff --git a/codec2-dev/stm32/src/stm32f4_timer.c b/codec2-dev/stm32/src/stm32f4_timer.c
deleted file mode 100644 (file)
index a2dc146..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*---------------------------------------------------------------------------*\
-
-  FILE........: stm32f4_timer.c
-  AUTHOR......: David Rowe
-  DATE CREATED: May 2 2013
-
-  STM32F4 implementation of the machine dependant timer functions.
-
-\*---------------------------------------------------------------------------*/
-
-/*
-  Copyright (C) 2013 David Rowe
-
-  All rights reserved.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU Lesser General Public License version 2.1, as
-  published by the Free Software Foundation.  This program is
-  distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-  License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <string.h>
-#include "machdep.h"
-#include "gdb_stdio.h"
-
-volatile unsigned int *DWT_CYCCNT   = (volatile unsigned int *)0xE0001004; 
-volatile unsigned int *DWT_CONTROL  = (volatile unsigned int *)0xE0001000;
-volatile unsigned int *SCB_DEMCR    = (volatile unsigned int *)0xE000EDFC;
-#define CORE_CLOCK 168E6
-#define BUF_SZ     4096
-
-static char buf[BUF_SZ];
-
-void machdep_timer_init(void)
-{
-    static int enabled = 0;
-    if (!enabled) {
-        *SCB_DEMCR = *SCB_DEMCR | 0x01000000;
-        *DWT_CYCCNT = 0; // reset the counter
-        *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter
-        enabled = 1;
-    }
-    *buf = 0;
-}
-
-void machdep_timer_reset(void)
-{
-    *DWT_CYCCNT = 0; // reset the counter
-}
-
-unsigned int machdep_timer_sample(void) {
-    return *DWT_CYCCNT;
-}
-
-/* log to a buffer, we only call printf after timing finished as it is slow */
-
-unsigned int machdep_timer_sample_and_log(unsigned int start, char s[])
-{
-    char  tmp[80];
-    float msec;
-
-    unsigned int dwt = *DWT_CYCCNT - start;
-    msec = 1000.0*(float)dwt/CORE_CLOCK;
-    sprintf(tmp, "%s %5.2f msecs\n",s,(double)msec);
-    if ((strlen(buf) + strlen(tmp)) < BUF_SZ)
-        strcat(buf, tmp);
-    return *DWT_CYCCNT;
-}
-
-void machdep_timer_print_logged_samples(void)
-{
-    gdb_stdio_printf("%s", buf);
-    *buf = 0;
-}