⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v34.c

📁 Linmodem is soft modem source code for embedded system
💻 C
📖 第 1 页 / 共 2 页
字号:
  0.0000000000e+00,  1.0438059849e-03,  0.0000000000e+00,  1.1113855722e-03,  0.0000000000e+00,  1.2232369871e-03,  0.0000000000e+00,  1.3825587134e-03,  0.0000000000e+00,  1.5926453386e-03,  0.0000000000e+00,  1.8569074639e-03,  0.0000000000e+00,  2.1788971424e-03,  0.0000000000e+00,  2.5623400268e-03,  0.0000000000e+00,  3.0111756977e-03,  0.0000000000e+00,  3.5296080377e-03,  0.0000000000e+00,  4.1221680212e-03,  0.0000000000e+00,  4.7937919718e-03,  0.0000000000e+00,  5.5499192449e-03,  0.0000000000e+00,  6.3966145267e-03,  0.0000000000e+00,  7.3407216217e-03,  0.0000000000e+00,  8.3900579330e-03,  0.0000000000e+00,  9.5536620984e-03,  0.0000000000e+00,  1.0842111879e-02,  0.0000000000e+00,  1.2267936058e-02,  0.0000000000e+00,  1.3846153846e-02,  0.0000000000e+00,  1.5594989773e-02,  0.0000000000e+00,  1.7536833977e-02,  0.0000000000e+00,  1.9699551684e-02,  0.0000000000e+00,  2.2118299263e-02,  0.0000000000e+00,  2.4838091053e-02,  0.0000000000e+00,  2.7917505894e-02,  0.0000000000e+00,  3.1434171201e-02,  0.0000000000e+00,  3.5493106154e-02,  0.0000000000e+00,  4.0239829657e-02,  0.0000000000e+00,  4.5881743462e-02,  0.0000000000e+00,  5.2724604849e-02,  0.0000000000e+00,  6.1238171887e-02,  0.0000000000e+00,  7.2182437365e-02,  0.0000000000e+00,  8.6871563629e-02,  0.0000000000e+00,  1.0778971907e-01,  0.0000000000e+00,  1.4026261876e-01,  0.0000000000e+00,  1.9814073999e-01,  0.0000000000e+00,  3.3221536070e-01,  0.0000000000e+00,  9.9962693916e-01,  0.0000000000e+00, -9.9962693916e-01, -0.0000000000e+00, -3.3221536070e-01, -0.0000000000e+00, -1.9814073999e-01, -0.0000000000e+00, -1.4026261876e-01, -0.0000000000e+00, -1.0778971907e-01, -0.0000000000e+00, -8.6871563629e-02, -0.0000000000e+00, -7.2182437365e-02, -0.0000000000e+00, -6.1238171887e-02, -0.0000000000e+00, -5.2724604849e-02, -0.0000000000e+00, -4.5881743462e-02, -0.0000000000e+00, -4.0239829657e-02, -0.0000000000e+00, -3.5493106154e-02, -0.0000000000e+00, -3.1434171201e-02, -0.0000000000e+00, -2.7917505894e-02, -0.0000000000e+00, -2.4838091053e-02, -0.0000000000e+00, -2.2118299263e-02, -0.0000000000e+00, -1.9699551684e-02, -0.0000000000e+00, -1.7536833977e-02, -0.0000000000e+00, -1.5594989773e-02, -0.0000000000e+00, -1.3846153846e-02, -0.0000000000e+00, -1.2267936058e-02, -0.0000000000e+00, -1.0842111879e-02, -0.0000000000e+00, -9.5536620984e-03, -0.0000000000e+00, -8.3900579330e-03, -0.0000000000e+00, -7.3407216217e-03, -0.0000000000e+00, -6.3966145267e-03, -0.0000000000e+00, -5.5499192449e-03, -0.0000000000e+00, -4.7937919718e-03, -0.0000000000e+00, -4.1221680212e-03, -0.0000000000e+00, -3.5296080377e-03, -0.0000000000e+00, -3.0111756977e-03, -0.0000000000e+00, -2.5623400268e-03, -0.0000000000e+00, -2.1788971424e-03, -0.0000000000e+00, -1.8569074639e-03, -0.0000000000e+00, -1.5926453386e-03, -0.0000000000e+00, -1.3825587134e-03, -0.0000000000e+00, -1.2232369871e-03, -0.0000000000e+00, -1.1113855722e-03, -0.0000000000e+00, -1.0438059849e-03,};s16 *v34_rx_filters[12] = {    v34_rx_filter_2400_1600,    v34_rx_filter_2400_1800,    v34_rx_filter_2743_1646,    v34_rx_filter_2743_1829,    v34_rx_filter_2800_1680,    v34_rx_filter_2800_1867,    v34_rx_filter_3000_1800,    v34_rx_filter_3000_2000,    v34_rx_filter_3200_1829,    v34_rx_filter_3200_1920,    v34_rx_filter_3429_1959,    v34_rx_filter_3429_1959,};    static void build_rx_filter(V34DSPState *s){    float a, f_low, f_high;    int i;    s->rx_filter = v34_rx_filters[s->S * 2 + s->use_high_carrier];    /* XXX: temporary hack to synchronize */    if (s->S == V34_S3429)        s->baud_phase = 1;    else        s->baud_phase = 2;    s->baud_num = (s->baud_num * 3);    s->carrier_incr = s->carrier_freq * (float)0x10000 / s->symbol_rate;    s->carrier_phase = 0;    s->rx_buf1_ptr = 0;    s->rx_filter_wsize = (s->baud_denom * RC_FILTER_SIZE) / s->baud_num;    printf("cincr=%d baudincr=%d\n", s->carrier_incr, s->baud_incr);    s->baud_phase = s->baud_phase << 16;    s->baud_num = s->baud_num << 16;    s->baud_denom = s->baud_denom << 16;    /* equalizer : init to identity */    s->eq_filter[EQ_SIZE/2][0] = 0x4000 << 16;    /* XXX: hilbert normalization ? */    for(i=0;i<EQ_SIZE;i++)         s->eq_filter[i][1] = (int)(hilbert[i] * 0.61475 * (0x4000 << 16));        /* adaptation shift : big at the beginning, should be small after. */    s->eq_shift = 0;    /* synchronization : Nyquist filters at the upper & lower frequencies */    a = 0.99;    f_low = 2 * M_PI * (s->carrier_freq - s->symbol_rate / 2.0) /         (3.0 * s->symbol_rate);    f_high = 2 * M_PI * (s->carrier_freq + s->symbol_rate / 2.0) /         (3.0 * s->symbol_rate);    printf("%f %f\n", f_low, f_high);    s->sync_low_coef[0] = (int)(2 * a * cos(f_low) * 0x4000);    s->sync_low_coef[1] = (int)( - a * a * 0x4000);    s->sync_high_coef[0] = (int)(2 * a * cos(f_high) * 0x4000);    s->sync_high_coef[1] = (int)(- a * a * 0x4000);    /* precomputed constants to compute the cross correlation */    s->sync_A = (int)( - a * a * sin(f_high - f_low) * 0x4000);    s->sync_B = (int)( a * sin(f_high) * 0x4000);    s->sync_C = (int)( - a * sin(f_low) * 0x4000);}int V34_init_low(V34DSPState *s, V34State *p, int transmit){  int S,d,e;    /* copy the params */  s->calling = p->calling;  s->S = p->S;  s->expanded_shape = p->expanded_shape;  s->R = p->R;  if (p->use_aux_channel)      s->R += 200;  s->conv_nb_states = p->conv_nb_states;  s->use_non_linear = p->use_non_linear;  s->use_high_carrier = p->use_high_carrier;  memcpy(s->h, p->h, sizeof(s->h));  /* superframe & data frame size */  S = s->S;  if (!s->use_high_carrier) {    d = S_tab[S][2];    e = S_tab[S][3];  } else {    d = S_tab[S][4];    e = S_tab[S][5];  }  s->symbol_rate = 2400.0 * (float)S_tab[S][0] / (float)S_tab[S][1];  s->carrier_freq = s->symbol_rate * (float)d / (float)e;  s->J = S_tab[S][6];  s->P = S_tab[S][7];  s->N = (s->R * 28) / (s->J * 100);   /* max length of a mapping frame (no need for table 8 as in the spec !) */  s->b = s->N / s->P;   if ((s->b * s->P) < s->N) s->b++;  s->r = s->N - (s->b - 1) * s->P;    /* aux channel */  if (p->use_aux_channel)      s->W = 15 - s->J; /* no need to test as in the spec ! */  else      s->W = 0; /* no aux channel */  /* mapping parameters */  s->q = 0;  if (s->b <= 12) {    s->K = 0;  } else {    s->K = s->b - 12;    while (s->K >= 32) {      s->K -= 8;      s->q++;    }  }  /* XXX: use integer arith ! */  if (!s->expanded_shape) {    s->M = (int) ceil(pow(2.0, s->K / 8.0));  } else {    s->M = (int) rint(1.25 * pow(2.0, s->K / 8.0));  }  s->L = 4 * s->M * (1 << s->q);#ifdef DEBUG  printf("S_index=%d (S=%0.0f carrier=%0.0f)\n"         "R=%d J=%d P=%d N=%d b=%d r=%d W=%d\n",          s->S, s->symbol_rate, s->carrier_freq,         s->R, s->J, s->P, s->N, s->b, s->r, s->W);  printf("K=%d q=%d M=%d L=%d\n", s->K, s->q, s->M, s->L);#endif  build_constellation(s);    build_rings(s);  s->baud_num = baud_tab[S][0];  s->baud_denom = baud_tab[S][1];  if (transmit) {      build_tx_filter(s);  } else {      build_rx_filter(s);      agc_init(s);      s->phase_4d = 0;  }  s->Z_1 = 0;  s->U0 = 0; /* trellis coder memory */  memset(s->x, 0, sizeof(s->x));  s->half_data_frame_count = 0;  s->sync_count = 0;  s->conv_reg = 0;  s->scrambler_reg = 0;  s->mapping_frame = 0; /* mapping frame counters */  s->acnt = 0;  s->rcnt = 0;  return 0;}/* shift by n & round toward zero */ static inline int shr_round0(int val, int n){  int offset;  offset = (1 << (n-1)) - 1;  if (val >= 0) {    val = (val + offset) >> n;  } else {    val = -val;    val = (val + offset) >> n;    val = -val;  }  return val;}/* clamp a between -v & v */static inline int clamp(int a, int v){  if (a > v)     return v;  else if (a < -v)     return -v;  else    return a;}/* compute the next state in the trellis (Y[0] is ignored) */static int trellis_next_state(int conv_nb_states, int conv_reg, int trans){    int i,Y0;    int Y[5];        Y[1] = (trans & 1);    Y[2] = ((trans >> 1) & 1);    Y[4] = ((trans >> 2) & 1);    Y[3] = ((trans >> 3) & 1);    Y0 = conv_reg & 1;    switch(conv_nb_states) {    case 16:        /* figure 10 */        conv_reg ^= (Y[1] << 1) | (Y[2] << 2) | ((Y[2] ^ Y0) << 3) | (Y0 << 4);        conv_reg >>= 1;        break;    case 32:        /* figure 11 */        conv_reg ^= (Y[2] << 1) | (Y[4] << 2) | (Y[1] << 3) | (Y[2] << 4) | (Y0 << 5);        conv_reg >>= 1;        break;    default:    case 64:        /* figure 12 */        {            int r[6], s[6], tmp1, tmp2;                        for(i=0;i<6;i++) r[i] = (conv_reg >> i) & 1;                        s[0] = r[1] ^ r[3] ^ Y[2];            s[1] = r[0];            s[2] = r[3];            tmp2 = Y[1] ^ r[4];            s[3] = r[3] ^ tmp2;            tmp1 = r[4] ^ r[5];            s[4] = r[2] ^ Y[3] ^ (r[3] & Y[2]) ^ tmp1;            s[5] = Y[4] ^ tmp1 ^ (r[3] & tmp2);                        conv_reg = 0;            for(i=0;i<6;i++) conv_reg |= s[i] << i;        }        break;    }    return conv_reg;}/* (

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -