updating squelch and cs options

This commit is contained in:
morgan 2016-06-30 19:33:40 -07:00
parent 75e964289c
commit a92b011492
3 changed files with 34 additions and 31 deletions

View File

@ -119,7 +119,7 @@ volatile long bouncer = 0;
* @see A1846S_DEFAULT_ADDRESS
*/
HamShield::HamShield() {
devAddr = A1846S_DEV_ADDR_SENLOW;
devAddr = A1; // devAddr is the chip select pin used by the HamShield
sHamShield = this;
pinMode(A1, OUTPUT);
@ -129,13 +129,13 @@ HamShield::HamShield() {
}
/** Specific address constructor.
* @param address I2C address
* @param chip select pin for HamShield
* @see A1846S_DEFAULT_ADDRESS
* @see A1846S_ADDRESS_AD0_LOW
* @see A1846S_ADDRESS_AD0_HIGH
*/
HamShield::HamShield(uint8_t address) {
devAddr = address;
HamShield::HamShield(uint8_t cs_pin) {
devAddr = cs_pin;
pinMode(A1, OUTPUT);
digitalWrite(A1, HIGH);
@ -720,7 +720,7 @@ void HamShield::setCdcssCode(uint16_t code) {
uint16_t HamShield::getCdcssCode() {
uint32_t oct_code;
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);
oct_code += radio_i2c_buf[0];
@ -747,23 +747,25 @@ bool HamShield::getSQState(){
}
// SQ threshold
void HamShield::setSQHiThresh(uint16_t sq_hi_threshold){
// Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1/8dB
HSwriteWord(devAddr, A1846S_SQ_OPEN_THRESH_REG, 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 1dB
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);
return radio_i2c_buf[0];
return radio_i2c_buf[0] - 137;
}
void HamShield::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
HSwriteWord(devAddr, A1846S_SQ_SHUT_THRESH_REG, 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 dB
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);
return radio_i2c_buf[0];
return radio_i2c_buf[0] - 137;
}
// SQ out select

View File

@ -242,7 +242,7 @@
#define ROBOT8BW 2
#define SC2-180 55
#define SC2_180 55
#define MARTIN1 44
// RTTY Frequencies
@ -263,7 +263,7 @@ class HamShield {
static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly
HamShield();
HamShield(uint8_t address);
HamShield(uint8_t cs_pin);
void initialize();
bool testConnection();
@ -375,10 +375,10 @@ class HamShield {
bool getSQState();
// 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
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
uint16_t getSQLoThresh();
void setSQHiThresh(int16_t sq_hi_threshold); // Sq detect high th, rssi_cmp will be 1 when rssi>th_h_sq, unit 1dB
int16_t getSQHiThresh();
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
int16_t getSQLoThresh();
// SQ out select
void setSQOutSel();

View File

@ -38,9 +38,9 @@ int8_t HSreadWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data)
sei();
regAddr = regAddr | (1 << 7);
cli();
PORTC &= ~(1<<1); //digitalWrite(nSEN, 0);
sei();
//cli();
digitalWrite(devAddr, 0); //PORTC &= ~(1<<1); //devAddr used as chip select
//sei();
for (int i = 0; i < 8; i++) {
temp = ((regAddr & (0x80 >> i)) != 0);
cli();
@ -76,9 +76,9 @@ int8_t HSreadWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data)
*data |= temp_dat; // digitalRead(DAT);
delayMicroseconds(9);
}
cli();
PORTC |= (1<<1);//digitalWrite(nSEN, 1);
digitalWrite(devAddr, 1); //PORTC |= (1<<1);// CS
cli();
DDRC &= ~((1<<5) | (1<<4)); // set direction all input (for ADC)
sei();
return 1;
@ -124,9 +124,9 @@ bool HSwriteWord(uint8_t devAddr, uint8_t regAddr, uint16_t data)
sei();
regAddr = regAddr & ~(1 << 7);
cli();
PORTC &= ~(1<<1); //digitalWrite(nSEN, 0);
sei();
//cli();
digitalWrite(devAddr, 0); // PORTC &= ~(1<<1); //CS
//sei();
for (int i = 0; i < 8; i++) {
temp_reg = ((regAddr & (0x80 >> i)) != 0);
cli();
@ -159,9 +159,10 @@ bool HSwriteWord(uint8_t devAddr, uint8_t regAddr, uint16_t data)
sei();
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
sei();
return true;