updating squelch and cs options
This commit is contained in:
parent
75e964289c
commit
a92b011492
|
@ -119,7 +119,7 @@ volatile long bouncer = 0;
|
||||||
* @see A1846S_DEFAULT_ADDRESS
|
* @see A1846S_DEFAULT_ADDRESS
|
||||||
*/
|
*/
|
||||||
HamShield::HamShield() {
|
HamShield::HamShield() {
|
||||||
devAddr = A1846S_DEV_ADDR_SENLOW;
|
devAddr = A1; // devAddr is the chip select pin used by the HamShield
|
||||||
sHamShield = this;
|
sHamShield = this;
|
||||||
|
|
||||||
pinMode(A1, OUTPUT);
|
pinMode(A1, OUTPUT);
|
||||||
|
@ -129,13 +129,13 @@ HamShield::HamShield() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Specific address constructor.
|
/** Specific address constructor.
|
||||||
* @param address I2C address
|
* @param chip select pin for HamShield
|
||||||
* @see A1846S_DEFAULT_ADDRESS
|
* @see A1846S_DEFAULT_ADDRESS
|
||||||
* @see A1846S_ADDRESS_AD0_LOW
|
* @see A1846S_ADDRESS_AD0_LOW
|
||||||
* @see A1846S_ADDRESS_AD0_HIGH
|
* @see A1846S_ADDRESS_AD0_HIGH
|
||||||
*/
|
*/
|
||||||
HamShield::HamShield(uint8_t address) {
|
HamShield::HamShield(uint8_t cs_pin) {
|
||||||
devAddr = address;
|
devAddr = cs_pin;
|
||||||
|
|
||||||
pinMode(A1, OUTPUT);
|
pinMode(A1, OUTPUT);
|
||||||
digitalWrite(A1, HIGH);
|
digitalWrite(A1, HIGH);
|
||||||
|
@ -720,7 +720,7 @@ void HamShield::setCdcssCode(uint16_t code) {
|
||||||
uint16_t HamShield::getCdcssCode() {
|
uint16_t HamShield::getCdcssCode() {
|
||||||
uint32_t oct_code;
|
uint32_t oct_code;
|
||||||
HSreadWord(devAddr, A1846S_CDCSS_CODE_HI_REG, radio_i2c_buf);
|
HSreadWord(devAddr, A1846S_CDCSS_CODE_HI_REG, radio_i2c_buf);
|
||||||
oct_code = (radio_i2c_buf[0] << 16);
|
oct_code = ((uint32_t)radio_i2c_buf[0] << 16);
|
||||||
HSreadWord(devAddr, A1846S_CDCSS_CODE_LO_REG, radio_i2c_buf);
|
HSreadWord(devAddr, A1846S_CDCSS_CODE_LO_REG, radio_i2c_buf);
|
||||||
oct_code += radio_i2c_buf[0];
|
oct_code += radio_i2c_buf[0];
|
||||||
|
|
||||||
|
@ -747,23 +747,25 @@ bool HamShield::getSQState(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQ threshold
|
// SQ threshold
|
||||||
void HamShield::setSQHiThresh(uint16_t sq_hi_threshold){
|
void HamShield::setSQHiThresh(int16_t sq_hi_threshold){
|
||||||
// Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1/8dB
|
// Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1dB
|
||||||
HSwriteWord(devAddr, A1846S_SQ_OPEN_THRESH_REG, sq_hi_threshold);
|
uint16_t sq = 137 + sq_hi_threshold;
|
||||||
|
HSwriteWord(devAddr, A1846S_SQ_OPEN_THRESH_REG, sq);
|
||||||
}
|
}
|
||||||
uint16_t HamShield::getSQHiThresh(){
|
int16_t HamShield::getSQHiThresh(){
|
||||||
HSreadWord(devAddr, A1846S_SQ_OPEN_THRESH_REG, radio_i2c_buf);
|
HSreadWord(devAddr, A1846S_SQ_OPEN_THRESH_REG, radio_i2c_buf);
|
||||||
|
|
||||||
return radio_i2c_buf[0];
|
return radio_i2c_buf[0] - 137;
|
||||||
}
|
}
|
||||||
void HamShield::setSQLoThresh(uint16_t sq_lo_threshold){
|
void HamShield::setSQLoThresh(int16_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
|
// Sq detect low th, rssi_cmp will be 0 when rssi<th_l_sq && time delay meet, unit 1 dB
|
||||||
HSwriteWord(devAddr, A1846S_SQ_SHUT_THRESH_REG, sq_lo_threshold);
|
uint16_t sq = 137 + sq_lo_threshold;
|
||||||
|
HSwriteWord(devAddr, A1846S_SQ_SHUT_THRESH_REG, sq);
|
||||||
}
|
}
|
||||||
uint16_t HamShield::getSQLoThresh(){
|
int16_t HamShield::getSQLoThresh(){
|
||||||
HSreadWord(devAddr, A1846S_SQ_SHUT_THRESH_REG, radio_i2c_buf);
|
HSreadWord(devAddr, A1846S_SQ_SHUT_THRESH_REG, radio_i2c_buf);
|
||||||
|
|
||||||
return radio_i2c_buf[0];
|
return radio_i2c_buf[0] - 137;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQ out select
|
// SQ out select
|
||||||
|
|
12
HamShield.h
12
HamShield.h
|
@ -242,7 +242,7 @@
|
||||||
|
|
||||||
|
|
||||||
#define ROBOT8BW 2
|
#define ROBOT8BW 2
|
||||||
#define SC2-180 55
|
#define SC2_180 55
|
||||||
#define MARTIN1 44
|
#define MARTIN1 44
|
||||||
|
|
||||||
// RTTY Frequencies
|
// RTTY Frequencies
|
||||||
|
@ -263,7 +263,7 @@ class HamShield {
|
||||||
static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly
|
static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly
|
||||||
|
|
||||||
HamShield();
|
HamShield();
|
||||||
HamShield(uint8_t address);
|
HamShield(uint8_t cs_pin);
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
bool testConnection();
|
bool testConnection();
|
||||||
|
@ -375,10 +375,10 @@ class HamShield {
|
||||||
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(int16_t sq_hi_threshold); // Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1dB
|
||||||
uint16_t getSQHiThresh();
|
int16_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(int16_t sq_lo_threshold); // Sq detect low th, rssi_cmp will be 0 when rssi<th_l_sq && time delay meet, unit 1dB
|
||||||
uint16_t getSQLoThresh();
|
int16_t getSQLoThresh();
|
||||||
|
|
||||||
// SQ out select
|
// SQ out select
|
||||||
void setSQOutSel();
|
void setSQOutSel();
|
||||||
|
|
|
@ -38,9 +38,9 @@ int8_t HSreadWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data)
|
||||||
sei();
|
sei();
|
||||||
regAddr = regAddr | (1 << 7);
|
regAddr = regAddr | (1 << 7);
|
||||||
|
|
||||||
cli();
|
//cli();
|
||||||
PORTC &= ~(1<<1); //digitalWrite(nSEN, 0);
|
digitalWrite(devAddr, 0); //PORTC &= ~(1<<1); //devAddr used as chip select
|
||||||
sei();
|
//sei();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
temp = ((regAddr & (0x80 >> i)) != 0);
|
temp = ((regAddr & (0x80 >> i)) != 0);
|
||||||
cli();
|
cli();
|
||||||
|
@ -76,9 +76,9 @@ int8_t HSreadWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data)
|
||||||
*data |= temp_dat; // digitalRead(DAT);
|
*data |= temp_dat; // digitalRead(DAT);
|
||||||
delayMicroseconds(9);
|
delayMicroseconds(9);
|
||||||
}
|
}
|
||||||
cli();
|
digitalWrite(devAddr, 1); //PORTC |= (1<<1);// CS
|
||||||
PORTC |= (1<<1);//digitalWrite(nSEN, 1);
|
|
||||||
|
|
||||||
|
cli();
|
||||||
DDRC &= ~((1<<5) | (1<<4)); // set direction all input (for ADC)
|
DDRC &= ~((1<<5) | (1<<4)); // set direction all input (for ADC)
|
||||||
sei();
|
sei();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -124,9 +124,9 @@ bool HSwriteWord(uint8_t devAddr, uint8_t regAddr, uint16_t data)
|
||||||
sei();
|
sei();
|
||||||
regAddr = regAddr & ~(1 << 7);
|
regAddr = regAddr & ~(1 << 7);
|
||||||
|
|
||||||
cli();
|
//cli();
|
||||||
PORTC &= ~(1<<1); //digitalWrite(nSEN, 0);
|
digitalWrite(devAddr, 0); // PORTC &= ~(1<<1); //CS
|
||||||
sei();
|
//sei();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
temp_reg = ((regAddr & (0x80 >> i)) != 0);
|
temp_reg = ((regAddr & (0x80 >> i)) != 0);
|
||||||
cli();
|
cli();
|
||||||
|
@ -159,9 +159,10 @@ bool HSwriteWord(uint8_t devAddr, uint8_t regAddr, uint16_t data)
|
||||||
sei();
|
sei();
|
||||||
delayMicroseconds(10);
|
delayMicroseconds(10);
|
||||||
}
|
}
|
||||||
cli();
|
|
||||||
PORTC |= (1<<1); //digitalWrite(nSEN, 1);
|
|
||||||
|
|
||||||
|
digitalWrite(devAddr, 1); //PORTC |= (1<<1); //CS
|
||||||
|
|
||||||
|
cli();
|
||||||
DDRC &= ~((1<<5) | (1<<4)); // set direction to input for ADC
|
DDRC &= ~((1<<5) | (1<<4)); // set direction to input for ADC
|
||||||
sei();
|
sei();
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue