2014-03-08 03:46:19 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \section COPYRIGHT
|
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* Copyright 2013-2015 The srsLTE Developers. See the
|
2014-03-08 03:46:19 -08:00
|
|
|
* COPYRIGHT file at the top-level directory of this distribution.
|
|
|
|
*
|
|
|
|
* \section LICENSE
|
|
|
|
*
|
2015-03-20 05:01:08 -07:00
|
|
|
* This file is part of the srsLTE library.
|
2014-03-08 03:46:19 -08:00
|
|
|
*
|
2015-03-20 05:01:08 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2014-03-08 03:46:19 -08:00
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2015-03-20 05:01:08 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2014-03-08 03:46:19 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
* GNU Affero General Public License for more details.
|
2014-03-08 03:46:19 -08:00
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
2014-03-08 03:46:19 -08:00
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2015-03-18 05:31:13 -07:00
|
|
|
#include "srslte/fec/crc.h"
|
2014-04-17 03:28:21 -07:00
|
|
|
|
2014-03-08 03:46:19 -08:00
|
|
|
typedef struct {
|
2014-06-17 02:11:41 -07:00
|
|
|
int n;
|
|
|
|
int l;
|
2014-10-17 11:44:01 -07:00
|
|
|
uint32_t p;
|
|
|
|
uint32_t s;
|
|
|
|
uint32_t word;
|
2014-03-08 03:46:19 -08:00
|
|
|
}expected_word_t;
|
|
|
|
|
|
|
|
|
|
|
|
static expected_word_t expected_words[] = {
|
2014-05-13 04:41:10 -07:00
|
|
|
|
2015-03-18 05:59:29 -07:00
|
|
|
{5001, 24, SRSLTE_LTE_CRC24A, 1, 0x1C5C97}, // LTE CRC24A (36.212 Sec 5.1.1)
|
|
|
|
{5001, 24, SRSLTE_LTE_CRC24B, 1, 0x36D1F0}, // LTE CRC24B
|
|
|
|
{5001, 16, SRSLTE_LTE_CRC16, 1, 0x7FF4}, // LTE CRC16: 0x7FF4
|
|
|
|
{5001, 8, SRSLTE_LTE_CRC8, 1, 0xF0}, // LTE CRC8 0xF8
|
2014-03-08 03:46:19 -08:00
|
|
|
|
2014-06-17 02:11:41 -07:00
|
|
|
{-1, -1, 0, 0, 0}
|
2014-03-08 03:46:19 -08:00
|
|
|
};
|
|
|
|
|
2014-10-17 11:44:01 -07:00
|
|
|
int get_expected_word(int n, int l, uint32_t p, unsigned int s, unsigned int *word) {
|
2014-06-17 02:11:41 -07:00
|
|
|
int i;
|
|
|
|
i=0;
|
|
|
|
while(expected_words[i].n != -1) {
|
|
|
|
if (expected_words[i].l == l
|
|
|
|
&& expected_words[i].p == p
|
|
|
|
&& expected_words[i].s == s) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (expected_words[i].n == -1) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
if (word) {
|
|
|
|
*word = expected_words[i].word;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-08 03:46:19 -08:00
|
|
|
}
|