Added files via upload

Add new mode for DMR Deviation Calibration.
This commit is contained in:
g4eml 2016-04-13 16:16:31 +01:00
parent 94454a9b30
commit 203b36cf59
7 changed files with 145 additions and 9 deletions

55
CalDMR.cpp Normal file
View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
*
* 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.
*/
#include "Config.h"
#include "Globals.h"
#include "CalDMR.h"
CCalDMR::CCalDMR() :
m_transmit(false)
{
}
void CCalDMR::process()
{
if (m_transmit)
{
dmrTX.setCal(true);
dmrTX.process();
}
else
{
dmrTX.setCal(false);
return;
}
}
uint8_t CCalDMR::write(const uint8_t* data, uint8_t length)
{
if (length != 1U)
return 4U;
m_transmit = data[0U] == 1U;
return 0U;
}

36
CalDMR.h Normal file
View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
*
* 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(CALDMR_H)
#define CALDMR_H
#include "Config.h"
#include "DMRDefines.h"
class CCalDMR {
public:
CCalDMR();
void process();
uint8_t write(const uint8_t* data, uint8_t length);
private:
bool m_transmit;
};
#endif

View File

@ -97,6 +97,10 @@ void CDMRTX::process()
m_state = DMRTXSTATE_CACH1; m_state = DMRTXSTATE_CACH1;
break; break;
case DMRTXSTATE_CAL:
createCal();
break;
default: default:
createCACH(0U, 1U); createCACH(0U, 1U);
m_state = DMRTXSTATE_SLOT1; m_state = DMRTXSTATE_SLOT1;
@ -192,6 +196,15 @@ void CDMRTX::setStart(bool start)
m_count = 0U; m_count = 0U;
} }
void CDMRTX::setCal(bool start)
{
m_state = start ? DMRTXSTATE_CAL : DMRTXSTATE_IDLE;
m_count = 0U;
}
void CDMRTX::writeByte(uint8_t c, uint8_t control) void CDMRTX::writeByte(uint8_t c, uint8_t control)
{ {
q15_t inBuffer[DMR_RADIO_SYMBOL_LENGTH * 4U + 1U]; q15_t inBuffer[DMR_RADIO_SYMBOL_LENGTH * 4U + 1U];
@ -278,6 +291,17 @@ void CDMRTX::createData(uint8_t slotIndex)
m_poPtr = 0U; m_poPtr = 0U;
} }
void CDMRTX::createCal()
{
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
m_poBuffer[i] = 0x5F; //+3+3-3-3 pattern for deviation cal.
m_markBuffer[i] = MARK_NONE;
}
m_poLen = DMR_FRAME_LENGTH_BYTES;
m_poPtr = 0U;
}
void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex) void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
{ {
if (m_cachPtr >= 12U) if (m_cachPtr >= 12U)

View File

@ -29,7 +29,8 @@ enum DMRTXSTATE {
DMRTXSTATE_SLOT1, DMRTXSTATE_SLOT1,
DMRTXSTATE_CACH1, DMRTXSTATE_CACH1,
DMRTXSTATE_SLOT2, DMRTXSTATE_SLOT2,
DMRTXSTATE_CACH2 DMRTXSTATE_CACH2,
DMRTXSTATE_CAL
}; };
class CDMRTX { class CDMRTX {
@ -41,6 +42,7 @@ public:
uint8_t writeShortLC(const uint8_t* data, uint8_t length); uint8_t writeShortLC(const uint8_t* data, uint8_t length);
void setStart(bool start); void setStart(bool start);
void setCal(bool start);
void process(); void process();
@ -66,6 +68,7 @@ private:
void createData(uint8_t slotIndex); void createData(uint8_t slotIndex);
void createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex); void createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex);
void createCal();
void writeByte(uint8_t c, uint8_t control); void writeByte(uint8_t c, uint8_t control);
}; };

View File

@ -39,7 +39,9 @@ enum MMDVM_STATE {
STATE_DSTAR = 1, STATE_DSTAR = 1,
STATE_DMR = 2, STATE_DMR = 2,
STATE_YSF = 3, STATE_YSF = 3,
STATE_DMRCAL = 98,
STATE_CALIBRATE = 99 STATE_CALIBRATE = 99
}; };
#include "SerialPort.h" #include "SerialPort.h"
@ -52,6 +54,7 @@ enum MMDVM_STATE {
#include "YSFTX.h" #include "YSFTX.h"
#include "CalRX.h" #include "CalRX.h"
#include "CalTX.h" #include "CalTX.h"
#include "CalDMR.h"
#include "Debug.h" #include "Debug.h"
#include "IO.h" #include "IO.h"
@ -87,6 +90,7 @@ extern CYSFTX ysfTX;
extern CCalRX calRX; extern CCalRX calRX;
extern CCalTX calTX; extern CCalTX calTX;
extern CCalDMR calDMR;
#endif #endif

View File

@ -43,6 +43,7 @@ CYSFTX ysfTX;
CCalRX calRX; CCalRX calRX;
CCalTX calTX; CCalTX calTX;
CCalDMR calDMR;
CSerialPort serial; CSerialPort serial;
CIO io; CIO io;
@ -70,5 +71,9 @@ void loop()
if (m_modemState == STATE_CALIBRATE) if (m_modemState == STATE_CALIBRATE)
calTX.process(); calTX.process();
if (m_modemState == STATE_DMRCAL)
calDMR.process();
} }

View File

@ -57,7 +57,7 @@ const uint8_t MMDVM_DEBUG3 = 0xF3U;
const uint8_t MMDVM_DEBUG4 = 0xF4U; const uint8_t MMDVM_DEBUG4 = 0xF4U;
const uint8_t MMDVM_DEBUG5 = 0xF5U; const uint8_t MMDVM_DEBUG5 = 0xF5U;
const uint8_t HARDWARE[] = "MMDVM 20160412 48kHz (D-Star/DMR/System Fusion)"; const uint8_t HARDWARE[] = "MMDVM 20160413 48kHz (D-Star/DMR/System Fusion)";
const uint8_t PROTOCOL_VERSION = 1U; const uint8_t PROTOCOL_VERSION = 1U;
@ -191,7 +191,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
MMDVM_STATE modemState = MMDVM_STATE(data[3U]); MMDVM_STATE modemState = MMDVM_STATE(data[3U]);
if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_CALIBRATE) if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_CALIBRATE && modemState != STATE_DMRCAL)
return 4U; return 4U;
if (modemState == STATE_DSTAR && !dstarEnable) if (modemState == STATE_DSTAR && !dstarEnable)
return 4U; return 4U;
@ -252,7 +252,7 @@ uint8_t CSerialPort::setMode(const uint8_t* data, uint8_t length)
if (modemState == m_modemState) if (modemState == m_modemState)
return 0U; return 0U;
if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_CALIBRATE) if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_CALIBRATE && modemState != STATE_DMRCAL)
return 4U; return 4U;
if (modemState == STATE_DSTAR && !m_dstarEnable) if (modemState == STATE_DSTAR && !m_dstarEnable)
return 4U; return 4U;
@ -293,6 +293,13 @@ void CSerialPort::setMode(MMDVM_STATE modemState)
dstarRX.reset(); dstarRX.reset();
ysfRX.reset(); ysfRX.reset();
break; break;
case STATE_DMRCAL:
DEBUG1("Mode set to DMR Calibrate");
dmrIdleRX.reset();
dmrRX.reset();
dstarRX.reset();
ysfRX.reset();
break;
default: default:
DEBUG1("Mode set to Idle"); DEBUG1("Mode set to Idle");
// STATE_IDLE // STATE_IDLE
@ -377,6 +384,8 @@ void CSerialPort::process()
case MMDVM_CAL_DATA: case MMDVM_CAL_DATA:
if (m_modemState == STATE_CALIBRATE) if (m_modemState == STATE_CALIBRATE)
err = calTX.write(m_buffer + 3U, m_len - 3U); err = calTX.write(m_buffer + 3U, m_len - 3U);
if (m_modemState == STATE_DMRCAL)
err= calDMR.write(m_buffer +3U,m_len -3U);
if (err == 0U) { if (err == 0U) {
sendACK(); sendACK();
} else { } else {