MMDVM/YSFRX.h

70 lines
1.9 KiB
C
Raw Normal View History

2016-01-14 19:57:21 +01:00
/*
2017-01-05 19:59:15 +01:00
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
2016-01-14 19:57:21 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(YSFRX_H)
#define YSFRX_H
#include "Config.h"
#include "YSFDefines.h"
enum YSFRX_STATE {
2017-01-19 20:59:01 +01:00
YSFRXS_NONE,
YSFRXS_DATA
2016-01-14 19:57:21 +01:00
};
class CYSFRX {
public:
CYSFRX();
2017-08-18 11:57:47 +02:00
void samples(const q15_t* samples, uint16_t* rssi, uint8_t length);
2016-01-14 19:57:21 +01:00
void reset();
private:
YSFRX_STATE m_state;
2017-01-17 21:05:20 +01:00
uint32_t m_bitBuffer[YSF_RADIO_SYMBOL_LENGTH];
q15_t m_buffer[YSF_FRAME_LENGTH_SAMPLES];
uint16_t m_bitPtr;
uint16_t m_dataPtr;
uint16_t m_startPtr;
2017-01-17 21:05:20 +01:00
uint16_t m_endPtr;
uint16_t m_syncPtr;
2017-01-19 20:59:01 +01:00
uint16_t m_minSyncPtr;
uint16_t m_maxSyncPtr;
2017-01-17 21:05:20 +01:00
q31_t m_maxCorr;
2016-01-14 19:57:21 +01:00
uint16_t m_lostCount;
uint8_t m_countdown;
q15_t m_centre[16U];
2017-01-17 21:05:20 +01:00
q15_t m_centreVal;
q15_t m_threshold[16U];
2017-01-17 21:05:20 +01:00
q15_t m_thresholdVal;
uint8_t m_averagePtr;
2017-01-10 20:20:16 +01:00
uint32_t m_rssiAccum;
uint16_t m_rssiCount;
2016-01-14 19:57:21 +01:00
void processNone(q15_t sample);
void processData(q15_t sample);
bool correlateSync();
2017-02-12 19:44:45 +01:00
void calculateLevels(uint16_t start, uint16_t count);
void samplesToBits(uint16_t start, uint16_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold);
void writeRSSIData(uint8_t* data);
2016-01-14 19:57:21 +01:00
};
#endif