// SPDX-License-Identifier: GPL-2.0-only /** * Digital Voice Modem - Hotspot Firmware * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * @package DVM / Hotspot Firmware * @derivedfrom MMDVM_HS (https://github.com/g4klx/MMDVM_HS) * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * * Copyright (C) 2015,2016,2020 Jonathan Naylor, G4KLX * Copyright (C) 2016,2017,2018,2019,2020 Andy Uribe, CA6JAU * Copyright (C) 2017 Danilo, DB4PLE * Copyright (C) 2017-2021 Bryan Biedenkapp, N2PLL * */ #if !defined(__IO_H__) #define __IO_H__ #include "Defines.h" #include "Globals.h" #include "BitBuffer.h" // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- #if defined(DUPLEX) #define CAL_DLY_LOOP 96100U #else #define CAL_DLY_LOOP 104600U #endif enum ADF_GAIN_MODE { // AGC automatic, default settings 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 // Implements the input/output data path with the radio air interface. // --------------------------------------------------------------------------- class DSP_FW_API IO { public: /// Initializes a new instance of the IO class. IO(); /// Starts air interface sampler. void start(); /// Process bits from air interface. void process(); /// Write bits to air interface. void write(uint8_t* data, uint16_t length, const uint8_t* control = NULL); /// Helper to get how much space the transmit ring buffer has for samples. uint16_t getSpace(void) const; /// void setDecode(bool dcd); /// Set modem mode. void setMode(DVM_STATE modemState); /// Hardware interrupt handler. void interrupt1(); #if defined(DUPLEX) /// Hardware interrupt handler. void interrupt2(); #endif /// Sets the ADF7021 RF configuration. void rf1Conf(DVM_STATE modemState, bool reset); #if defined(DUPLEX) /// Sets the ADF7021 RF configuration. void rf2Conf(DVM_STATE modemState); #endif /// void setDeviations(uint8_t dmrTXLevel, uint8_t p25TXLevel, uint8_t nxdnTXLevel); /// Sets the RF parameters. uint8_t setRFParams(uint32_t rxFreq, uint32_t txFreq, uint8_t rfPower, ADF_GAIN_MODE gainMode); /// Sets the RF adjustment parameters. void setRFAdjust(int8_t dmrDiscBWAdj, int8_t p25DiscBWAdj, int8_t nxdnDiscBWAdj, int8_t dmrPostBWAdj, int8_t p25PostBWAdj, int8_t nxdnPostBWAdj); /// Sets the RF AFC adjustment parameters. void setAFCParams(bool afcEnable, uint8_t afcKI, uint8_t afcKP, uint8_t afcRange); /// Flag indicating the TX ring buffer has overflowed. bool hasTXOverflow(void); /// Flag indicating the RX ring buffer has overflowed. bool hasRXOverflow(void); /// void resetWatchdog(void); /// uint32_t getWatchdog(void); /// Gets the CPU type the firmware is running on. uint8_t getCPU() const; /// Gets the unique identifier for the air interface. void getUDID(uint8_t* buffer); /// void updateCal(DVM_STATE modemState); /// void delayBit(void); /// uint16_t readRSSI(void); /// void selfTest(); /// void getIntCounter(uint16_t& int1, uint16_t& int2); #if defined(ZUMSPOT_ADF7021) || defined(LONESTAR_USB) || defined(SKYBRIDGE_HS) /// bool isDualBand(); #endif /// void SCLK(bool on); /// void SDATA(bool on); /// bool SREAD(); /// void SLE1(bool on); #if defined(DUPLEX) /// void SLE2(bool on); /// bool RXD2(); #endif /// void CE(bool on); /// bool RXD1(); /// bool CLK(); private: bool m_started; BitBuffer m_rxBuffer; BitBuffer m_txBuffer; uint32_t m_ledCount; bool m_ledValue; volatile uint32_t m_watchdog; volatile uint16_t m_int1Counter; volatile uint16_t m_int2Counter; uint32_t m_rxFrequency; uint32_t m_txFrequency; uint8_t m_rfPower; ADF_GAIN_MODE m_gainMode; /// Helper to check the frequencies are within band ranges of the ADF7021. void checkBand(uint32_t rxFreq, uint32_t txFreq); #if defined(ZUMSPOT_ADF7021) || defined(LONESTAR_USB) || defined(SKYBRIDGE_HS) /// void setBandVHF(bool enable); /// bool hasSingleADF7021(); #endif /// void configureBand(); /// void configureTxRx(DVM_STATE modemState); /// void setTX(); /// void setRX(bool doSle = true); /// void delayIfCal(); /// void delayReset(); /// void delayUS(uint32_t us); // Hardware specific routines /// Initializes hardware interrupts. void initInt(); /// Starts hardware interrupts. void startInt(); /// void setTXDInt(bool on); #if defined(BIDIR_DATA_PIN) /// void setDataDirOut(bool dir); /// void setRXDInt(bool on); #endif /// void setLEDInt(bool on); /// void setPTTInt(bool on); /// void setCOSInt(bool on); /// void setDMRInt(bool on); /// void setP25Int(bool on); /// void setNXDNInt(bool on); }; #endif