mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.8 KiB
C
77 lines
1.8 KiB
C
11 years ago
|
/**
|
||
11 years ago
|
*
|
||
11 years ago
|
* \section COPYRIGHT
|
||
11 years ago
|
*
|
||
11 years ago
|
* Copyright 2013-2014 The libLTE Developers. See the
|
||
|
* COPYRIGHT file at the top-level directory of this distribution.
|
||
|
*
|
||
|
* \section LICENSE
|
||
|
*
|
||
|
* This file is part of the libLTE library.
|
||
|
*
|
||
|
* libLTE is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Lesser General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
|
* libLTE is distributed in the hope that it will be useful,
|
||
11 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Lesser General Public License for more details.
|
||
|
*
|
||
11 years ago
|
* A copy of the GNU Lesser General Public License can be found in
|
||
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
11 years ago
|
*/
|
||
|
|
||
11 years ago
|
|
||
11 years ago
|
#include <stdlib.h>
|
||
|
#include <strings.h>
|
||
11 years ago
|
#include <assert.h>
|
||
11 years ago
|
|
||
10 years ago
|
#include "srslte/phy/utils/bit.h"
|
||
|
#include "srslte/phy/modem/mod.h"
|
||
11 years ago
|
|
||
|
/** Low-level API */
|
||
|
|
||
10 years ago
|
int mod_modulate(modem_table_t* q, const uint8_t *bits, cf_t* symbols, uint32_t nbits) {
|
||
10 years ago
|
uint32_t i,j,idx;
|
||
10 years ago
|
uint8_t *b_ptr=(uint8_t*) bits;
|
||
11 years ago
|
j=0;
|
||
|
for (i=0;i<nbits;i+=q->nbits_x_symbol) {
|
||
|
idx = bit_unpack(&b_ptr,q->nbits_x_symbol);
|
||
10 years ago
|
if (idx < q->nsymbols) {
|
||
|
symbols[j] = q->symbol_table[idx];
|
||
|
} else {
|
||
|
return LIBLTE_ERROR;
|
||
|
}
|
||
11 years ago
|
j++;
|
||
|
}
|
||
|
return j;
|
||
11 years ago
|
}
|
||
|
|
||
|
|
||
|
/* High-Level API */
|
||
|
int mod_initialize(mod_hl* hl) {
|
||
11 years ago
|
modem_table_init(&hl->obj);
|
||
10 years ago
|
if (modem_table_lte(&hl->obj,hl->init.std,false)) {
|
||
11 years ago
|
return -1;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
return 0;
|
||
11 years ago
|
}
|
||
|
|
||
|
int mod_work(mod_hl* hl) {
|
||
11 years ago
|
int ret = mod_modulate(&hl->obj,hl->input,hl->output,hl->in_len);
|
||
|
hl->out_len = ret;
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
|
|
||
|
int mod_stop(mod_hl* hl) {
|
||
11 years ago
|
modem_table_free(&hl->obj);
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
|
|
||
|
|