mirror of
https://github.com/g4klx/MMDVM_HS.git
synced 2025-12-06 07:02:00 +01:00
Optimizing ZUMspot debug messages
This commit is contained in:
parent
60c5b4654e
commit
30bd83dab2
46
ADF7021.cpp
46
ADF7021.cpp
|
|
@ -41,7 +41,7 @@ uint32_t ADF7021_RX_REG0;
|
||||||
uint32_t ADF7021_TX_REG0;
|
uint32_t ADF7021_TX_REG0;
|
||||||
uint32_t ADF7021_REG1;
|
uint32_t ADF7021_REG1;
|
||||||
uint32_t div2;
|
uint32_t div2;
|
||||||
float f_div;
|
uint32_t f_div;
|
||||||
|
|
||||||
static void Send_AD7021_control_shift()
|
static void Send_AD7021_control_shift()
|
||||||
{
|
{
|
||||||
|
|
@ -213,9 +213,9 @@ void CIO::ifConf(MMDVM_STATE modemState, bool reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(div2 == 1U)
|
if(div2 == 1U)
|
||||||
f_div = 2.0;
|
f_div = 2U;
|
||||||
else
|
else
|
||||||
f_div = 1.0;
|
f_div = 1U;
|
||||||
|
|
||||||
switch (modemState) {
|
switch (modemState) {
|
||||||
case STATE_DSTAR:
|
case STATE_DSTAR:
|
||||||
|
|
@ -801,39 +801,51 @@ void CIO::setRX(bool doSle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CIO::RXfreq(void)
|
uint32_t CIO::RXfreq()
|
||||||
{
|
{
|
||||||
return (uint32_t)((ADF7021_PFD / f_div) * ((float)m_RX_N_divider + (((float)m_RX_F_divider) / 32768.0)) + 100000.0);
|
return (uint32_t)((float)(ADF7021_PFD / f_div) * ((float)((32768 * m_RX_N_divider) + m_RX_F_divider) / 32768.0)) + 100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CIO::TXfreq(void)
|
uint32_t CIO::TXfreq()
|
||||||
{
|
{
|
||||||
return (uint32_t)((ADF7021_PFD / f_div) * ((float)m_TX_N_divider + (((float)m_TX_F_divider) / 32768.0)));
|
return (uint32_t)((float)(ADF7021_PFD / f_div) * ((float)((32768 * m_TX_N_divider) + m_TX_F_divider) / 32768.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CIO::devDSTAR(void)
|
uint16_t CIO::devDSTAR()
|
||||||
{
|
{
|
||||||
return (uint16_t)(ADF7021_PFD * (((float)ADF7021_DEV_DSTAR) / f_div) / 65536.0);
|
return (uint16_t)((ADF7021_PFD * ADF7021_DEV_DSTAR) / (f_div * 65536));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CIO::devDMR(void)
|
uint16_t CIO::devDMR()
|
||||||
{
|
{
|
||||||
return (uint16_t)(ADF7021_PFD * (((float)ADF7021_DEV_DMR) / f_div) / 65536.0);
|
return (uint16_t)((ADF7021_PFD * ADF7021_DEV_DMR) / (f_div * 65536));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CIO::devYSF_H(void)
|
uint16_t CIO::devYSF_H()
|
||||||
{
|
{
|
||||||
return (uint16_t)(ADF7021_PFD * (((float)ADF7021_DEV_YSF_H) / f_div) / 65536.0);
|
return (uint16_t)((ADF7021_PFD * ADF7021_DEV_YSF_H) / (f_div * 65536));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CIO::devYSF_L(void)
|
uint16_t CIO::devYSF_L()
|
||||||
{
|
{
|
||||||
return (uint16_t)(ADF7021_PFD * (((float)ADF7021_DEV_YSF_L) / f_div) / 65536.0);
|
return (uint16_t)((ADF7021_PFD * ADF7021_DEV_YSF_L) / (f_div * 65536));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CIO::devP25(void)
|
uint16_t CIO::devP25()
|
||||||
{
|
{
|
||||||
return (uint16_t)(ADF7021_PFD * (((float)ADF7021_DEV_P25) / f_div) / 65536.0);
|
return (uint16_t)((ADF7021_PFD * ADF7021_DEV_P25) / (f_div * 65536));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CIO::printConf()
|
||||||
|
{
|
||||||
|
DEBUG1("ZUMspot configuration:");
|
||||||
|
DEBUG2I("TX freq (Hz):", TXfreq());
|
||||||
|
DEBUG2I("RX freq (Hz):", RXfreq());
|
||||||
|
DEBUG2("D-Star dev (Hz):", devDSTAR());
|
||||||
|
DEBUG2("DMR +1 sym dev (Hz):", devDMR());
|
||||||
|
DEBUG2("YSF_H +1 sym dev (Hz):", devYSF_H());
|
||||||
|
DEBUG2("YSF_L +1 sym dev (Hz):", devYSF_L());
|
||||||
|
DEBUG2("P25 +1 sym dev (Hz):", devP25());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
1
Debug.h
1
Debug.h
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#define DEBUG1(a) serial.writeDebug((a))
|
#define DEBUG1(a) serial.writeDebug((a))
|
||||||
#define DEBUG2(a,b) serial.writeDebug((a),(b))
|
#define DEBUG2(a,b) serial.writeDebug((a),(b))
|
||||||
|
#define DEBUG2I(a,b) serial.writeDebugI((a),(b))
|
||||||
#define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c))
|
#define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c))
|
||||||
#define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d))
|
#define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d))
|
||||||
#define DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e))
|
#define DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e))
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ const uint8_t MARK_NONE = 0x00U;
|
||||||
#include "P25RX.h"
|
#include "P25RX.h"
|
||||||
#include "P25TX.h"
|
#include "P25TX.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
const uint16_t TX_RINGBUFFER_SIZE = 512U;
|
const uint16_t TX_RINGBUFFER_SIZE = 512U;
|
||||||
const uint16_t RX_RINGBUFFER_SIZE = 512U;
|
const uint16_t RX_RINGBUFFER_SIZE = 512U;
|
||||||
|
|
|
||||||
1
IO.h
1
IO.h
|
|
@ -125,6 +125,7 @@ public:
|
||||||
uint16_t devYSF_H(void);
|
uint16_t devYSF_H(void);
|
||||||
uint16_t devYSF_L(void);
|
uint16_t devYSF_L(void);
|
||||||
uint16_t devP25(void);
|
uint16_t devP25(void);
|
||||||
|
void printConf();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t m_RX_N_divider;
|
uint8_t m_RX_N_divider;
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
io.ifConf(STATE_P25, true);
|
io.ifConf(STATE_P25, true);
|
||||||
|
|
||||||
io.start();
|
io.start();
|
||||||
printConf();
|
io.printConf();
|
||||||
|
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
@ -904,6 +904,32 @@ void CSerialPort::writeDebug(const char* text)
|
||||||
writeInt(1U, reply, count, true);
|
writeInt(1U, reply, count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSerialPort::writeDebugI(const char* text, int32_t n1)
|
||||||
|
{
|
||||||
|
if (!m_debug)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8_t reply[130U];
|
||||||
|
|
||||||
|
reply[0U] = MMDVM_FRAME_START;
|
||||||
|
reply[1U] = 0U;
|
||||||
|
reply[2U] = MMDVM_DEBUG1;
|
||||||
|
|
||||||
|
uint8_t count = 3U;
|
||||||
|
for (uint8_t i = 0U; text[i] != '\0'; i++, count++)
|
||||||
|
reply[count] = text[i];
|
||||||
|
|
||||||
|
reply[count++] = ' ';
|
||||||
|
|
||||||
|
i2str(&reply[count], 130U - count, n1);
|
||||||
|
|
||||||
|
count += 9U;
|
||||||
|
|
||||||
|
reply[1U] = count;
|
||||||
|
|
||||||
|
writeInt(1U, reply, count, true);
|
||||||
|
}
|
||||||
|
|
||||||
void CSerialPort::writeDebug(const char* text, int16_t n1)
|
void CSerialPort::writeDebug(const char* text, int16_t n1)
|
||||||
{
|
{
|
||||||
if (!m_debug)
|
if (!m_debug)
|
||||||
|
|
@ -1013,16 +1039,3 @@ void CSerialPort::writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n
|
||||||
|
|
||||||
writeInt(1U, reply, count, true);
|
writeInt(1U, reply, count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSerialPort::printConf()
|
|
||||||
{
|
|
||||||
char buff[60];
|
|
||||||
|
|
||||||
writeDebug("ZUMspot configuration:");
|
|
||||||
writeDebug(buff);
|
|
||||||
writeDebug("D-Star dev (Hz):", io.devDSTAR());
|
|
||||||
writeDebug("DMR +1 sym dev (Hz):", io.devDMR());
|
|
||||||
writeDebug("YSF_H +1 sym dev (Hz):", io.devYSF_H());
|
|
||||||
writeDebug("YSF_L +1 sym dev (Hz):", io.devYSF_L());
|
|
||||||
writeDebug("P25 +1 sym dev (Hz):", io.devP25());
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -46,12 +46,11 @@ public:
|
||||||
|
|
||||||
void writeDebug(const char* text);
|
void writeDebug(const char* text);
|
||||||
void writeDebug(const char* text, int16_t n1);
|
void writeDebug(const char* text, int16_t n1);
|
||||||
|
void writeDebugI(const char* text, int32_t n1);
|
||||||
void writeDebug(const char* text, int16_t n1, int16_t n2);
|
void writeDebug(const char* text, int16_t n1, int16_t n2);
|
||||||
void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3);
|
void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3);
|
||||||
void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3, int16_t n4);
|
void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3, int16_t n4);
|
||||||
|
|
||||||
void printConf();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t m_buffer[256U];
|
uint8_t m_buffer[256U];
|
||||||
uint8_t m_ptr;
|
uint8_t m_ptr;
|
||||||
|
|
|
||||||
25
Utils.cpp
25
Utils.cpp
|
|
@ -56,4 +56,29 @@ uint8_t countBits64(uint64_t bits)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simple functions to convert from int to string
|
||||||
|
// Example from: https://stackoverflow.com/questions/8257714/how-to-convert-an-int-to-string-in-c
|
||||||
|
static uint8_t *i2str_helper(uint8_t *dest, size_t n, int32_t x) {
|
||||||
|
if (n == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (x <= -10) {
|
||||||
|
dest = i2str_helper(dest, n - 1, x / 10);
|
||||||
|
if (dest == NULL) return NULL;
|
||||||
|
}
|
||||||
|
*dest = (uint8_t) ('0' - x % 10);
|
||||||
|
return dest + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *i2str(uint8_t *dest, size_t n, int32_t x) {
|
||||||
|
uint8_t *p = dest;
|
||||||
|
if (n == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
n--;
|
||||||
|
x = -x;
|
||||||
|
p = i2str_helper(p, n, x);
|
||||||
|
if (p == NULL) return NULL;
|
||||||
|
*p = 0;
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue