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) // channel mode
// 12-14MHz crystal: this reg is set to crystal freq_khz // 11 - 25kHz channel
// 24-28MHz crystal: this reg is set to crystal freq_khz / 2 // 00 - 12.5kHz channel
void setXtalFreq(uint16_t freq_kHz); // 10,01 - reserved
uint16_t getXtalFreq(); void setChanMode(uint16_t mode);
uint16_t getChanMode();
// adclk frequency (kHz) void setModeTransmit(); // turn off rx, turn on tx
// 12-14MHz crystal: this reg is set to crystal freq_khz / 2 void setModeReceive(); // turn on rx, turn off tx
// 24-28MHz crystal: this reg is set to crystal freq_khz / 4 void setModeOff(); // turn off rx, turn off tx, set pwr_dwn bit
void setAdcClkFreq(uint16_t freq_kHz);
uint16_t getAdcClkFreq();
// clk mode // set tx source
// 12-14MHz: set to 1 // 00 - Mic source
// 24-28MHz: set to 0 // 01 - sine source from tone2
void setClkMode(bool LFClk); // 10 - tx code from GPIO1 code_in (gpio1<1:0> must be set to 01)
bool getClkMode(); // 11 - no tx source
void setTxSource(uint16_t tx_source);
void setTxSourceMic();
void setTxSourceTone1();
void setTxSourceTone2();
void setTxSourceTones();
void setTxSourceNone();
uint16_t getTxSource();
// clk example // PA bias voltage is unused (maybe remove this)
// 12.8MHz clock // set PA_bias voltage
// A1846S_XTAL_FREQ_REG[15:0]= xtal_freq<15:0>=12.8*1000=12800 // 000000: 1.01V
// A1846S_ADCLK_FREQ_REG[12:0] =adclk_freq<15:0>=(12.8/2)*1000=6400 // 000001:1.05V
// A1846S_CLK_MODE_REG[0]= clk_mode =1 // 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();
// TX/RX control // Subaudio settings
// channel mode // Ctcss/cdcss mode sel
// 11 - 25kHz channel // x00=disable,
// 00 - 12.5kHz channel // 001=inner ctcss en,
// 10,01 - reserved // 010= inner cdcss en
void setChanMode(uint16_t mode); // 101= outer ctcss en,
uint16_t getChanMode(); // 110=outer cdcss en
// others =disable
void setCtcssCdcssMode(uint16_t mode);
uint16_t getCtcssCdcssMode();
void setInnerCtcssMode();
void setInnerCdcssMode();
void setOuterCtcssMode();
void setOuterCdcssMode();
void disableCtcssCdcss();
// choose tx or rx // Ctcss_sel
void setTX(bool on_noff); // 1 = ctcss_cmp/cdcss_cmp out via gpio
bool getTX(); // 0 = ctcss/cdcss sdo out vio gpio
void setCtcssSel(bool cmp_nsdo);
bool getCtcssSel();
void setRX(bool on_noff); // Cdcss_sel
bool getRX(); // 1 = long (24 bit) code
// 0 = short(23 bit) code
void setModeTransmit(); // turn off rx, turn on tx void setCdcssSel(bool long_nshort);
void setModeReceive(); // turn on rx, turn off tx bool getCdcssSel();
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 // Cdcss neg_det_en
void enableCdcssNegDet(); void enableCdcssNegDet();
void disableCdcssNegDet(); void disableCdcssNegDet();
bool getCdcssNegDetEnabled(); bool getCdcssNegDetEnabled();
// Cdcss pos_det_en // Cdcss pos_det_en
void enableCdcssPosDet(); void enableCdcssPosDet();
void disableCdcssPosDet(); void disableCdcssPosDet();
bool getCdcssPosDetEnabled(); bool getCdcssPosDetEnabled();
// css_det_en // css_det_en
void enableCssDet(); void enableCssDet();
void disableCssDet(); void disableCssDet();
bool getCssDetEnabled(); bool getCssDetEnabled();
// ctcss freq // ctcss freq
void setCtcss(float freq); void setCtcss(float freq);
void setCtcssFreq(uint16_t freq); void setCtcssFreq(uint16_t freq);
uint16_t getCtcssFreq(); uint16_t getCtcssFreq();
void setCtcssFreqToStandard(); // freq must be 134.4Hz for standard cdcss mode void setCtcssFreqToStandard(); // freq must be 134.4Hz for standard cdcss mode
// cdcss codes // cdcss codes
void setCdcssCode(uint16_t code); void setCdcssCode(uint16_t code);
uint16_t getCdcssCode(); uint16_t getCdcssCode();
// SQ // SQ
void setSQOn(); void setSQOn();
void setSQOff(); void setSQOff();
bool getSQState(); bool getSQState();
// SQ threshold // 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 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(); uint16_t getSQHiThresh();
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 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 getSQLoThresh(); uint16_t getSQLoThresh();
// SQ out select // SQ out select
void setSQOutSel(); void setSQOutSel();
void clearSQOutSel(); void clearSQOutSel();
bool getSQOutSel(); bool getSQOutSel();
// VOX // VOX
void setVoxOn(); void setVoxOn();
void setVoxOff(); void setVoxOff();
bool getVoxOn(); bool getVoxOn();
// Vox Threshold // Vox Threshold
void setVoxOpenThresh(uint16_t vox_open_thresh); // When vssi > th_h_vox, then vox will be 1(unit mV ) void setVoxOpenThresh(uint16_t vox_open_thresh); // When vssi > th_h_vox, then vox will be 1(unit mV )
uint16_t getVoxOpenThresh(); 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 ) 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(); uint16_t getVoxShutThresh();
// Tail Noise // Tail Noise
void enableTailNoiseElim(); void enableTailNoiseElim();
void disableTailNoiseElim(); void disableTailNoiseElim();
bool getTailNoiseElimEnabled(); bool getTailNoiseElimEnabled();
// tail noise shift select // tail noise shift select
// Select ctcss phase shift when use tail eliminating function when TX // Select ctcss phase shift when use tail eliminating function when TX
// 00 = 120 degree shift // 00 = 120 degree shift
// 01 = 180 degree shift // 01 = 180 degree shift
// 10 = 240 degree shift // 10 = 240 degree shift
// 11 = reserved // 11 = reserved
void setShiftSelect(uint16_t shift_sel); void setShiftSelect(uint16_t shift_sel);
uint16_t getShiftSelect(); uint16_t getShiftSelect();
// DTMF // DTMF
void setDTMFC0(uint16_t freq); void setDTMFC0(uint16_t freq);
uint16_t getDTMFC0(); uint16_t getDTMFC0();
void setDTMFC1(uint16_t freq); void setDTMFC1(uint16_t freq);
uint16_t getDTMFC1(); uint16_t getDTMFC1();
void setDTMFC2(uint16_t freq); void setDTMFC2(uint16_t freq);
uint16_t getDTMFC2(); uint16_t getDTMFC2();
void setDTMFC3(uint16_t freq); void setDTMFC3(uint16_t freq);
uint16_t getDTMFC3(); uint16_t getDTMFC3();
void setDTMFC4(uint16_t freq); void setDTMFC4(uint16_t freq);
uint16_t getDTMFC4(); uint16_t getDTMFC4();
void setDTMFC5(uint16_t freq); void setDTMFC5(uint16_t freq);
uint16_t getDTMFC5(); uint16_t getDTMFC5();
void setDTMFC6(uint16_t freq); void setDTMFC6(uint16_t freq);
uint16_t getDTMFC6(); uint16_t getDTMFC6();
void setDTMFC7(uint16_t freq); void setDTMFC7(uint16_t freq);
uint16_t getDTMFC7(); uint16_t getDTMFC7();
// TX FM deviation // TX FM deviation
void setFMVoiceCssDeviation(uint16_t deviation); void setFMVoiceCssDeviation(uint16_t deviation);
uint16_t getFMVoiceCssDeviation(); uint16_t getFMVoiceCssDeviation();
void setFMCssDeviation(uint16_t deviation); void setFMCssDeviation(uint16_t deviation);
uint16_t getFMCssDeviation(); uint16_t getFMCssDeviation();
// RX voice range // RX voice range
void setVolume1(uint16_t volume); void setVolume1(uint16_t volume);
uint16_t getVolume1(); uint16_t getVolume1();
void setVolume2(uint16_t volume); void setVolume2(uint16_t volume);
uint16_t getVolume2(); uint16_t getVolume2();
// GPIO // GPIO
void setGpioMode(uint16_t gpio, uint16_t mode); void setGpioMode(uint16_t gpio, uint16_t mode);
void setGpioHiZ(uint16_t gpio); void setGpioHiZ(uint16_t gpio);
void setGpioFcn(uint16_t gpio); void setGpioFcn(uint16_t gpio);
void setGpioLow(uint16_t gpio); void setGpioLow(uint16_t gpio);
void setGpioHi(uint16_t gpio); void setGpioHi(uint16_t gpio);
uint16_t getGpioMode(uint16_t gpio); uint16_t getGpioMode(uint16_t gpio);
uint16_t getGpios(); uint16_t getGpios();
// Int // Int
void enableInterrupt(uint16_t interrupt); void enableInterrupt(uint16_t interrupt);
void disableInterrupt(uint16_t interrupt); void disableInterrupt(uint16_t interrupt);
bool getInterruptEnabled(uint16_t interrupt); bool getInterruptEnabled(uint16_t interrupt);
// ST mode // ST mode
void setStMode(uint16_t mode); void setStMode(uint16_t mode);
uint16_t getStMode(); uint16_t getStMode();
void setStFullAuto(); void setStFullAuto();
void setStRxAutoTxManu(); void setStRxAutoTxManu();
void setStFullManu(); void setStFullManu();
// Pre-emphasis, De-emphasis filter // Pre-emphasis, De-emphasis filter
void bypassPreDeEmph(); void bypassPreDeEmph();
void usePreDeEmph(); void usePreDeEmph();
bool getPreDeEmphEnabled(); bool getPreDeEmphEnabled();
// Read Only Status Registers // Read Only Status Registers
int16_t readRSSI(); int16_t readRSSI();
uint16_t readVSSI(); uint16_t readVSSI();
uint16_t readDTMFIndex(); // may want to split this into two (index1 and index2) uint16_t readDTMFIndex(); // may want to split this into two (index1 and index2)
uint16_t readDTMFCode(); uint16_t readDTMFCode();
// set output power of radio // set output power of radio
void setRfPower(uint8_t pwr); void setRfPower(uint8_t pwr);
@ -513,11 +481,6 @@ class HamShield {
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);
uint32_t findWhitespace(uint32_t start,uint32_t stop, uint8_t dwell, uint16_t step, uint16_t threshold); uint32_t findWhitespace(uint32_t start,uint32_t stop, uint8_t dwell, 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;
@ -555,16 +518,39 @@ class HamShield {
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_ */