fix file formatting; support modifying ADF7021 gain from the host;

pull/2/head
Bryan Biedenkapp 4 years ago
parent 4db35fc673
commit 91f7c2f8e0

@ -428,15 +428,21 @@ void IO::rf1Conf(DVM_STATE modemState, bool reset)
/* /*
** AGC (Register 9) ** AGC (Register 9)
*/ */
#if defined(AD7021_GAIN_AUTO) switch (m_gainMode) {
AD7021_CONTROL = 0x000231E9; // AGC ON, normal operation case ADF_GAIN_AUTO_LIN:
#elif defined(AD7021_GAIN_AUTO_LIN)
AD7021_CONTROL = 0x100231E9; // AGC ON, LNA high linearity AD7021_CONTROL = 0x100231E9; // AGC ON, LNA high linearity
#elif defined(AD7021_GAIN_LOW) break;
case ADF_GAIN_LOW:
AD7021_CONTROL = 0x120631E9; // AGC OFF, low gain, LNA high linearity AD7021_CONTROL = 0x120631E9; // AGC OFF, low gain, LNA high linearity
#elif defined(AD7021_GAIN_HIGH) break;
case ADF_GAIN_HIGH:
AD7021_CONTROL = 0x00A631E9; // AGC OFF, high gain AD7021_CONTROL = 0x00A631E9; // AGC OFF, high gain
#endif break;
case ADF_GAIN_AUTO:
default:
AD7021_CONTROL = 0x000231E9; // AGC ON, normal operation
break;
}
AD7021_1_IOCTL(); AD7021_1_IOCTL();
/* /*
@ -1015,7 +1021,7 @@ void IO::configureTxRx(DVM_STATE modemState)
ADF7021_REG2 |= (uint32_t)0b110001 << 7; // PA ADF7021_REG2 |= (uint32_t)0b110001 << 7; // PA
ADF7021_REG2 |= (uint32_t)0b10 << 28; // invert data (and RC alpha = 0.5) ADF7021_REG2 |= (uint32_t)0b10 << 28; // invert data (and RC alpha = 0.5)
ADF7021_REG2 |= (uint32_t)(p25Dev / div2) << 19; // deviation ADF7021_REG2 |= (uint32_t)(p25Dev / div2) << 19; // deviation
#if defined(ENABLE_P25_WIDE) || defined(ADF7021_DISABLE_RC_4FSK) #if defined(ADF7021_DISABLE_RC_4FSK)
ADF7021_REG2 |= (uint32_t)0b011 << 4; // modulation (4FSK) ADF7021_REG2 |= (uint32_t)0b011 << 4; // modulation (4FSK)
#else #else
ADF7021_REG2 |= (uint32_t)0b111 << 4; // modulation (RC 4FSK) ADF7021_REG2 |= (uint32_t)0b111 << 4; // modulation (RC 4FSK)

@ -46,6 +46,8 @@
#define LOW 0 #define LOW 0
#define HIGH 1 #define HIGH 1
#define DEFAULT_FREQUENCY 433075000
/** Band Tables */ /** Band Tables */
/** 136 - 174 mhz */ /** 136 - 174 mhz */
#define VHF_MIN 136000000 #define VHF_MIN 136000000

@ -98,33 +98,20 @@ typedef unsigned long long ulong64_t;
// Allow the P25 protocol // Allow the P25 protocol
#define ENABLE_P25 #define ENABLE_P25
// Enable P25 Wide modulation
// #define ENABLE_P25_WIDE
// Enable ADF7021 support // Enable ADF7021 support
#define ENABLE_ADF7021 #define ENABLE_ADF7021
// Bidirectional Data pin (Enable Standard TX/RX Data Interface of ADF7021) // Bidirectional Data pin (Enable Standard TX/RX Data Interface of ADF7021)
#define BIDIR_DATA_PIN #define BIDIR_DATA_PIN
// Enable full duplex support with dual ADF7021 (valid for homebrew hotspots only)
// #define DUPLEX
// TCXO of the ADF7021 // TCXO of the ADF7021
// For 14.7456 MHz: // For 14.7456 MHz:
#define ADF7021_14_7456 #define ADF7021_14_7456
// For 12.2880 MHz: // For 12.2880 MHz:
// #define ADF7021_12_2880 // #define ADF7021_12_2880
// Configure receiver gain for ADF7021 // Enable full duplex support with dual ADF7021 (valid for homebrew hotspots only)
// AGC automatic, default settings // #define DUPLEX
#define AD7021_GAIN_AUTO
// AGC automatic with high LNA linearity
// #define AD7021_GAIN_AUTO_LIN
// AGC OFF, lowest gain
// #define AD7021_GAIN_LOW
// AGC OFF, highest gain
// #define AD7021_GAIN_HIGH
// Disable TX Raised Cosine filter for 4FSK modulation in ADF7021 // Disable TX Raised Cosine filter for 4FSK modulation in ADF7021
// #define ADF7021_DISABLE_RC_4FSK // #define ADF7021_DISABLE_RC_4FSK
@ -142,14 +129,13 @@ typedef unsigned long long ulong64_t;
// Force the internal L (internal VCO inductor) for UHF 380 and T-band // Force the internal L (internal VCO inductor) for UHF 380 and T-band
#define FORCE_UHF_INTERAL_L #define FORCE_UHF_INTERAL_L
// Enable mode detection
#define ENABLE_SCAN_MODE
// Pass RSSI information to the host // Pass RSSI information to the host
// #define SEND_RSSI_DATA // #define SEND_RSSI_DATA
// Enable for RPi 3B+, USB mode // Enable for RPi 3B+, USB mode
// #define LONG_USB_RESET #if defined(STM32_USB_HOST)
#define LONG_USB_RESET
#endif
const uint8_t BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U }; const uint8_t BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U };

@ -34,14 +34,6 @@
#include "ADF7021.h" #include "ADF7021.h"
#include "IO.h" #include "IO.h"
// ---------------------------------------------------------------------------
// Globals
// ---------------------------------------------------------------------------
uint32_t m_rxFrequency;
uint32_t m_txFrequency;
uint8_t m_rfPower;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Public Class Members // Public Class Members
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -56,7 +48,11 @@ IO::IO():
m_ledValue(true), m_ledValue(true),
m_watchdog(0U), m_watchdog(0U),
m_int1Counter(0U), m_int1Counter(0U),
m_int2Counter(0U) m_int2Counter(0U),
m_rxFrequency(DEFAULT_FREQUENCY),
m_txFrequency(DEFAULT_FREQUENCY),
m_rfPower(0U),
m_gainMode(ADF_GAIN_AUTO)
{ {
initInt(); initInt();
@ -240,9 +236,11 @@ void IO::setMode(DVM_STATE modemState)
/// <param name="rxFreq"></param> /// <param name="rxFreq"></param>
/// <param name="txFreq"></param> /// <param name="txFreq"></param>
/// <param name="rfPower"></param> /// <param name="rfPower"></param>
uint8_t IO::setRFParams(uint32_t rxFreq, uint32_t txFreq, uint8_t rfPower) /// <param name="gainMode"></param>
uint8_t IO::setRFParams(uint32_t rxFreq, uint32_t txFreq, uint8_t rfPower, ADF_GAIN_MODE gainMode)
{ {
m_rfPower = rfPower >> 2; m_rfPower = rfPower >> 2;
m_gainMode = gainMode;
// check frequency ranges // check frequency ranges
if (!( if (!(

22
IO.h

@ -56,12 +56,19 @@
#endif #endif
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Global Externs // Constants
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
extern uint32_t m_rxFrequency; enum ADF_GAIN_MODE {
extern uint32_t m_txFrequency; // AGC automatic, default settings
extern uint8_t m_rfPower; ADF_GAIN_AUTO = 0U,
// AGC automatic with high LNA linearity
ADF_GAIN_AUTO_LIN = 1U,
// AGC OFF, lowest gain
ADF_GAIN_LOW = 2U,
// AGC OFF, highest gain
ADF_GAIN_HIGH = 3U
};
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Class Declaration // Class Declaration
@ -108,7 +115,7 @@ public:
/// <summary></summary> /// <summary></summary>
void setDeviations(uint8_t dmrTXLevel, uint8_t p25TXLevel); void setDeviations(uint8_t dmrTXLevel, uint8_t p25TXLevel);
/// <summary>Sets the RF parameters.</summary> /// <summary>Sets the RF parameters.</summary>
uint8_t setRFParams(uint32_t rxFreq, uint32_t txFreq, uint8_t rfPower); uint8_t setRFParams(uint32_t rxFreq, uint32_t txFreq, uint8_t rfPower, ADF_GAIN_MODE gainMode);
/// <summary>Sets the RF adjustment parameters.</summary> /// <summary>Sets the RF adjustment parameters.</summary>
void setRFAdjust(int8_t dmrDiscBWAdj, int8_t p25DiscBWAdj, int8_t dmrPostBWAdj, int8_t p25PostBWAdj); void setRFAdjust(int8_t dmrDiscBWAdj, int8_t p25DiscBWAdj, int8_t dmrPostBWAdj, int8_t p25PostBWAdj);
@ -183,6 +190,11 @@ private:
volatile uint16_t m_int1Counter; volatile uint16_t m_int1Counter;
volatile uint16_t m_int2Counter; volatile uint16_t m_int2Counter;
uint32_t m_rxFrequency;
uint32_t m_txFrequency;
uint8_t m_rfPower;
ADF_GAIN_MODE m_gainMode;
/// <summary>Helper to check the frequencies are within band ranges of the ADF7021.</summary> /// <summary>Helper to check the frequencies are within band ranges of the ADF7021.</summary>
void checkBand(uint32_t rxFreq, uint32_t txFreq); void checkBand(uint32_t rxFreq, uint32_t txFreq);
#if defined(ZUMSPOT_ADF7021) || defined(LONESTAR_USB) || defined(SKYBRIDGE_HS) #if defined(ZUMSPOT_ADF7021) || defined(LONESTAR_USB) || defined(SKYBRIDGE_HS)

@ -1134,11 +1134,12 @@ void SerialPort::setMode(DVM_STATE modemState)
/// <returns></returns> /// <returns></returns>
uint8_t SerialPort::setRFParams(const uint8_t* data, uint8_t length) uint8_t SerialPort::setRFParams(const uint8_t* data, uint8_t length)
{ {
if (length < 14U) if (length < 15U)
return RSN_ILLEGAL_LENGTH; return RSN_ILLEGAL_LENGTH;
uint32_t rxFreq, txFreq; uint32_t rxFreq, txFreq;
uint8_t rfPower; uint8_t rfPower;
ADF_GAIN_MODE gainMode;
rxFreq = data[1U] << 0; rxFreq = data[1U] << 0;
rxFreq |= data[2U] << 8; rxFreq |= data[2U] << 8;
@ -1176,7 +1177,9 @@ uint8_t SerialPort::setRFParams(const uint8_t* data, uint8_t length)
if (p25PostBWAdj < -128) if (p25PostBWAdj < -128)
return RSN_INVALID_REQUEST; return RSN_INVALID_REQUEST;
gainMode = (ADF_GAIN_MODE)data[14U];
io.setRFAdjust(dmrDiscBWAdj, p25DiscBWAdj, dmrPostBWAdj, p25PostBWAdj); io.setRFAdjust(dmrDiscBWAdj, p25DiscBWAdj, dmrPostBWAdj, p25PostBWAdj);
return io.setRFParams(rxFreq, txFreq, rfPower); return io.setRFParams(rxFreq, txFreq, rfPower, gainMode);
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.