made certain library functions private to ensure they aren't improperly called from an arduino sketch

This commit is contained in:
morgan 2015-12-15 14:43:57 -08:00
parent 28f1ff016c
commit c107df93dd
1 changed files with 243 additions and 257 deletions

View File

@ -258,6 +258,9 @@
class HamShield { class HamShield {
public: public:
// public singleton for ISRs to reference
static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly
HamShield(); HamShield();
HamShield(uint8_t address); HamShield(uint8_t address);
@ -268,240 +271,205 @@ class HamShield {
uint16_t readCtlReg(); uint16_t readCtlReg();
void softReset(); void softReset();
// center frequency // restrictions control
void setFrequency(uint32_t freq_khz); void dangerMode();
uint32_t getFrequency(); void safeMode();
// band bool frequency(uint32_t freq_khz);
void setTxBand2m(); uint32_t getFrequency();
void setTxBand1_2m();
void setTxBand70cm();
bool frequency(uint32_t freq_khz);
// xtal frequency (kHz)
// 12-14MHz crystal: this reg is set to crystal freq_khz
// 24-28MHz crystal: this reg is set to crystal freq_khz / 2
void setXtalFreq(uint16_t freq_kHz);
uint16_t getXtalFreq();
// adclk frequency (kHz)
// 12-14MHz crystal: this reg is set to crystal freq_khz / 2
// 24-28MHz crystal: this reg is set to crystal freq_khz / 4
void setAdcClkFreq(uint16_t freq_kHz);
uint16_t getAdcClkFreq();
// clk mode
// 12-14MHz: set to 1
// 24-28MHz: set to 0
void setClkMode(bool LFClk);
bool getClkMode();
// clk example
// 12.8MHz clock
// A1846S_XTAL_FREQ_REG[15:0]= xtal_freq<15:0>=12.8*1000=12800
// A1846S_ADCLK_FREQ_REG[12:0] =adclk_freq<15:0>=(12.8/2)*1000=6400
// A1846S_CLK_MODE_REG[0]= clk_mode =1
// TX/RX control
// channel mode
// 11 - 25kHz channel
// 00 - 12.5kHz channel
// 10,01 - reserved
void setChanMode(uint16_t mode);
uint16_t getChanMode();
// choose tx or rx
void setTX(bool on_noff);
bool getTX();
void setRX(bool on_noff);
bool getRX();
void setModeTransmit(); // turn off rx, turn on tx
void setModeReceive(); // turn on rx, turn off tx
void setModeOff(); // turn off rx, turn off tx, set pwr_dwn bit
// set tx source
// 00 - Mic source
// 01 - sine source from tone2
// 10 - tx code from GPIO1 code_in (gpio1<1:0> must be set to 01)
// 11 - no tx source
void setTxSource(uint16_t tx_source);
void setTxSourceMic();
void setTxSourceTone1();
void setTxSourceTone2();
void setTxSourceTones();
void setTxSourceNone();
uint16_t getTxSource();
// set PA_bias voltage
// 000000: 1.01V
// 000001:1.05V
// 000010:1.09V
// 000100: 1.18V
// 001000: 1.34V
// 010000: 1.68V
// 100000: 2.45V
// 1111111:3.13V
void setPABiasVoltage(uint16_t voltage);
uint16_t getPABiasVoltage();
// Subaudio settings
// Ctcss/cdcss mode sel
// x00=disable,
// 001=inner ctcss en,
// 010= inner cdcss en
// 101= outer ctcss en,
// 110=outer cdcss en
// others =disable
void setCtcssCdcssMode(uint16_t mode);
uint16_t getCtcssCdcssMode();
void setInnerCtcssMode();
void setInnerCdcssMode();
void setOuterCtcssMode();
void setOuterCdcssMode();
void disableCtcssCdcss();
// Ctcss_sel
// 1 = ctcss_cmp/cdcss_cmp out via gpio
// 0 = ctcss/cdcss sdo out vio gpio
void setCtcssSel(bool cmp_nsdo);
bool getCtcssSel();
// Cdcss_sel
// 1 = long (24 bit) code
// 0 = short(23 bit) code
void setCdcssSel(bool long_nshort);
bool getCdcssSel();
// Cdcss neg_det_en
void enableCdcssNegDet();
void disableCdcssNegDet();
bool getCdcssNegDetEnabled();
// Cdcss pos_det_en
void enableCdcssPosDet();
void disableCdcssPosDet();
bool getCdcssPosDetEnabled();
// css_det_en
void enableCssDet();
void disableCssDet();
bool getCssDetEnabled();
// ctcss freq
void setCtcss(float freq);
void setCtcssFreq(uint16_t freq);
uint16_t getCtcssFreq();
void setCtcssFreqToStandard(); // freq must be 134.4Hz for standard cdcss mode
// cdcss codes
void setCdcssCode(uint16_t code);
uint16_t getCdcssCode();
// SQ // channel mode
void setSQOn(); // 11 - 25kHz channel
void setSQOff(); // 00 - 12.5kHz channel
bool getSQState(); // 10,01 - reserved
void setChanMode(uint16_t mode);
// SQ threshold uint16_t getChanMode();
void setSQHiThresh(uint16_t sq_hi_threshold); // Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1/8dB
uint16_t getSQHiThresh(); void setModeTransmit(); // turn off rx, turn on tx
void setSQLoThresh(uint16_t sq_lo_threshold); // Sq detect low th, rssi_cmp will be 0 when rssi<th_l_sq && time delay meet, unit 1/8 dB void setModeReceive(); // turn on rx, turn off tx
uint16_t getSQLoThresh(); void setModeOff(); // turn off rx, turn off tx, set pwr_dwn bit
// SQ out select // set tx source
void setSQOutSel(); // 00 - Mic source
void clearSQOutSel(); // 01 - sine source from tone2
bool getSQOutSel(); // 10 - tx code from GPIO1 code_in (gpio1<1:0> must be set to 01)
// 11 - no tx source
// VOX void setTxSource(uint16_t tx_source);
void setVoxOn(); void setTxSourceMic();
void setVoxOff(); void setTxSourceTone1();
bool getVoxOn(); void setTxSourceTone2();
void setTxSourceTones();
// Vox Threshold void setTxSourceNone();
void setVoxOpenThresh(uint16_t vox_open_thresh); // When vssi > th_h_vox, then vox will be 1(unit mV ) uint16_t getTxSource();
uint16_t getVoxOpenThresh();
void setVoxShutThresh(uint16_t vox_shut_thresh); // When vssi < th_l_vox && time delay meet, then vox will be 0 (unit mV ) // PA bias voltage is unused (maybe remove this)
uint16_t getVoxShutThresh(); // set PA_bias voltage
// 000000: 1.01V
// Tail Noise // 000001:1.05V
void enableTailNoiseElim(); // 000010:1.09V
void disableTailNoiseElim(); // 000100: 1.18V
bool getTailNoiseElimEnabled(); // 001000: 1.34V
// 010000: 1.68V
// tail noise shift select // 100000: 2.45V
// Select ctcss phase shift when use tail eliminating function when TX // 1111111:3.13V
// 00 = 120 degree shift void setPABiasVoltage(uint16_t voltage);
// 01 = 180 degree shift uint16_t getPABiasVoltage();
// 10 = 240 degree shift
// 11 = reserved // Subaudio settings
void setShiftSelect(uint16_t shift_sel);
uint16_t getShiftSelect(); // Ctcss/cdcss mode sel
// x00=disable,
// DTMF // 001=inner ctcss en,
void setDTMFC0(uint16_t freq); // 010= inner cdcss en
uint16_t getDTMFC0(); // 101= outer ctcss en,
void setDTMFC1(uint16_t freq); // 110=outer cdcss en
uint16_t getDTMFC1(); // others =disable
void setDTMFC2(uint16_t freq); void setCtcssCdcssMode(uint16_t mode);
uint16_t getDTMFC2(); uint16_t getCtcssCdcssMode();
void setDTMFC3(uint16_t freq); void setInnerCtcssMode();
uint16_t getDTMFC3(); void setInnerCdcssMode();
void setDTMFC4(uint16_t freq); void setOuterCtcssMode();
uint16_t getDTMFC4(); void setOuterCdcssMode();
void setDTMFC5(uint16_t freq); void disableCtcssCdcss();
uint16_t getDTMFC5();
void setDTMFC6(uint16_t freq); // Ctcss_sel
uint16_t getDTMFC6(); // 1 = ctcss_cmp/cdcss_cmp out via gpio
void setDTMFC7(uint16_t freq); // 0 = ctcss/cdcss sdo out vio gpio
uint16_t getDTMFC7(); void setCtcssSel(bool cmp_nsdo);
bool getCtcssSel();
// TX FM deviation
void setFMVoiceCssDeviation(uint16_t deviation); // Cdcss_sel
uint16_t getFMVoiceCssDeviation(); // 1 = long (24 bit) code
void setFMCssDeviation(uint16_t deviation); // 0 = short(23 bit) code
uint16_t getFMCssDeviation(); void setCdcssSel(bool long_nshort);
bool getCdcssSel();
// RX voice range // Cdcss neg_det_en
void setVolume1(uint16_t volume); void enableCdcssNegDet();
uint16_t getVolume1(); void disableCdcssNegDet();
void setVolume2(uint16_t volume); bool getCdcssNegDetEnabled();
uint16_t getVolume2();
// Cdcss pos_det_en
// GPIO void enableCdcssPosDet();
void setGpioMode(uint16_t gpio, uint16_t mode); void disableCdcssPosDet();
void setGpioHiZ(uint16_t gpio); bool getCdcssPosDetEnabled();
void setGpioFcn(uint16_t gpio);
void setGpioLow(uint16_t gpio); // css_det_en
void setGpioHi(uint16_t gpio); void enableCssDet();
uint16_t getGpioMode(uint16_t gpio); void disableCssDet();
uint16_t getGpios(); bool getCssDetEnabled();
// Int // ctcss freq
void enableInterrupt(uint16_t interrupt); void setCtcss(float freq);
void disableInterrupt(uint16_t interrupt); void setCtcssFreq(uint16_t freq);
bool getInterruptEnabled(uint16_t interrupt); uint16_t getCtcssFreq();
void setCtcssFreqToStandard(); // freq must be 134.4Hz for standard cdcss mode
// ST mode
void setStMode(uint16_t mode); // cdcss codes
uint16_t getStMode(); void setCdcssCode(uint16_t code);
void setStFullAuto(); uint16_t getCdcssCode();
void setStRxAutoTxManu();
void setStFullManu(); // SQ
void setSQOn();
// Pre-emphasis, De-emphasis filter void setSQOff();
void bypassPreDeEmph(); bool getSQState();
void usePreDeEmph();
bool getPreDeEmphEnabled(); // SQ threshold
void setSQHiThresh(uint16_t sq_hi_threshold); // Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1/8dB
// Read Only Status Registers uint16_t getSQHiThresh();
int16_t readRSSI(); void setSQLoThresh(uint16_t sq_lo_threshold); // Sq detect low th, rssi_cmp will be 0 when rssi<th_l_sq && time delay meet, unit 1/8 dB
uint16_t readVSSI(); uint16_t getSQLoThresh();
uint16_t readDTMFIndex(); // may want to split this into two (index1 and index2)
uint16_t readDTMFCode(); // SQ out select
void setSQOutSel();
void clearSQOutSel();
bool getSQOutSel();
// VOX
void setVoxOn();
void setVoxOff();
bool getVoxOn();
// Vox Threshold
void setVoxOpenThresh(uint16_t vox_open_thresh); // When vssi > th_h_vox, then vox will be 1(unit mV )
uint16_t getVoxOpenThresh();
void setVoxShutThresh(uint16_t vox_shut_thresh); // When vssi < th_l_vox && time delay meet, then vox will be 0 (unit mV )
uint16_t getVoxShutThresh();
// Tail Noise
void enableTailNoiseElim();
void disableTailNoiseElim();
bool getTailNoiseElimEnabled();
// tail noise shift select
// Select ctcss phase shift when use tail eliminating function when TX
// 00 = 120 degree shift
// 01 = 180 degree shift
// 10 = 240 degree shift
// 11 = reserved
void setShiftSelect(uint16_t shift_sel);
uint16_t getShiftSelect();
// DTMF
void setDTMFC0(uint16_t freq);
uint16_t getDTMFC0();
void setDTMFC1(uint16_t freq);
uint16_t getDTMFC1();
void setDTMFC2(uint16_t freq);
uint16_t getDTMFC2();
void setDTMFC3(uint16_t freq);
uint16_t getDTMFC3();
void setDTMFC4(uint16_t freq);
uint16_t getDTMFC4();
void setDTMFC5(uint16_t freq);
uint16_t getDTMFC5();
void setDTMFC6(uint16_t freq);
uint16_t getDTMFC6();
void setDTMFC7(uint16_t freq);
uint16_t getDTMFC7();
// TX FM deviation
void setFMVoiceCssDeviation(uint16_t deviation);
uint16_t getFMVoiceCssDeviation();
void setFMCssDeviation(uint16_t deviation);
uint16_t getFMCssDeviation();
// RX voice range
void setVolume1(uint16_t volume);
uint16_t getVolume1();
void setVolume2(uint16_t volume);
uint16_t getVolume2();
// GPIO
void setGpioMode(uint16_t gpio, uint16_t mode);
void setGpioHiZ(uint16_t gpio);
void setGpioFcn(uint16_t gpio);
void setGpioLow(uint16_t gpio);
void setGpioHi(uint16_t gpio);
uint16_t getGpioMode(uint16_t gpio);
uint16_t getGpios();
// Int
void enableInterrupt(uint16_t interrupt);
void disableInterrupt(uint16_t interrupt);
bool getInterruptEnabled(uint16_t interrupt);
// ST mode
void setStMode(uint16_t mode);
uint16_t getStMode();
void setStFullAuto();
void setStRxAutoTxManu();
void setStFullManu();
// Pre-emphasis, De-emphasis filter
void bypassPreDeEmph();
void usePreDeEmph();
bool getPreDeEmphEnabled();
// Read Only Status Registers
int16_t readRSSI();
uint16_t readVSSI();
uint16_t readDTMFIndex(); // may want to split this into two (index1 and index2)
uint16_t readDTMFCode();
// set output power of radio // set output power of radio
void setRfPower(uint8_t pwr); void setRfPower(uint8_t pwr);
@ -512,11 +480,6 @@ class HamShield {
bool setMURSChannel(uint8_t channel); bool setMURSChannel(uint8_t channel);
bool setWXChannel(uint8_t channel); bool setWXChannel(uint8_t channel);
uint8_t scanWXChannel(); uint8_t scanWXChannel();
// restrictions control
void dangerMode();
void safeMode();
// utilities // utilities
uint32_t scanMode(uint32_t start,uint32_t stop, uint8_t speed, uint16_t step, uint16_t threshold); uint32_t scanMode(uint32_t start,uint32_t stop, uint8_t speed, uint16_t step, uint16_t threshold);
@ -526,23 +489,23 @@ class HamShield {
void buttonMode(uint8_t mode); void buttonMode(uint8_t mode);
static void isr_ptt(); static void isr_ptt();
static void isr_reset(); static void isr_reset();
void morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]); void morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]);
uint8_t morseLookup(char letter); uint8_t morseLookup(char letter);
bool waitForChannel(long timeout, long breakwindow, int setRSSI); bool waitForChannel(long timeout, long breakwindow, int setRSSI);
void SSTVVISCode(int code); void SSTVVISCode(int code);
void SSTVTestPattern(int code); void SSTVTestPattern(int code);
void toneWait(uint16_t freq, long timer); void toneWait(uint16_t freq, long timer);
void toneWaitU(uint16_t freq, long timer); void toneWaitU(uint16_t freq, long timer);
bool parityCalc(int code); bool parityCalc(int code);
// void AFSKOut(char buffer[80]); // void AFSKOut(char buffer[80]);
// AFSK routines // AFSK routines
bool AFSKStart(); bool AFSKStart();
bool AFSKEnabled() { return afsk.enabled(); } bool AFSKEnabled() { return afsk.enabled(); }
bool AFSKStop(); bool AFSKStop();
bool AFSKOut(const char *); bool AFSKOut(const char *);
class AFSK afsk; class AFSK afsk;
private: private:
uint8_t devAddr; uint8_t devAddr;
@ -554,17 +517,40 @@ class HamShield {
uint32_t GMRS[]; uint32_t GMRS[];
uint32_t MURS[]; uint32_t MURS[];
uint32_t WX[]; uint32_t WX[];
// public singleton for ISRs to reference // private utility functions
public: // these functions should not be called in the Arduino sketch
static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly // just use the above public functions to do everything
// int8_t A1846S::readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout); void setFrequency(uint32_t freq_khz);
// int8_t A1846S::readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout); void setTxBand2m();
// int8_t A1846S::readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout); void setTxBand1_2m();
// int8_t A1846S::writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout); void setTxBand70cm();
// bool A1846S::writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data);
// bool A1846S::writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); // xtal frequency (kHz)
// 12-14MHz crystal: this reg is set to crystal freq_khz
// 24-28MHz crystal: this reg is set to crystal freq_khz / 2
void setXtalFreq(uint16_t freq_kHz);
uint16_t getXtalFreq();
// adclk frequency (kHz)
// 12-14MHz crystal: this reg is set to crystal freq_khz / 2
// 24-28MHz crystal: this reg is set to crystal freq_khz / 4
void setAdcClkFreq(uint16_t freq_kHz);
uint16_t getAdcClkFreq();
// clk mode
// 12-14MHz: set to 1
// 24-28MHz: set to 0
void setClkMode(bool LFClk);
bool getClkMode();
// choose tx or rx
void setTX(bool on_noff);
bool getTX();
void setRX(bool on_noff);
bool getRX();
}; };
#endif /* _HAMSHIELD_H_ */ #endif /* _HAMSHIELD_H_ */