diff --git a/HamShield.cpp b/HamShield.cpp index e4ff898..ee9cfd8 100644 --- a/HamShield.cpp +++ b/HamShield.cpp @@ -142,6 +142,11 @@ void HamShield::initialize() { uint16_t tx_data; + pinMode(A1, OUTPUT); + digitalWrite(A1, HIGH); + pinMode(A4, OUTPUT); + pinMode(A5, OUTPUT); + // reset all registers in A1846S softReset(); @@ -990,7 +995,7 @@ bool HamShield::getPreDeEmphEnabled(){ int16_t HamShield::readRSSI(){ HSreadBitsW(devAddr, A1846S_RSSI_REG, A1846S_RSSI_BIT, A1846S_RSSI_LENGTH, radio_i2c_buf); - int16_t rssi = (radio_i2c_buf[0] & 0x3FF) - 137; + int16_t rssi = (radio_i2c_buf[0] & 0xFF); // - 137; return rssi; } uint16_t HamShield::readVSSI(){ diff --git a/HamShield.h b/HamShield.h index 77366a3..a277274 100644 --- a/HamShield.h +++ b/HamShield.h @@ -188,7 +188,7 @@ #define A1846S_VOX_FLAG_BIT 0 // vox out from dsp // Bitfields for A1846S_RSSI_REG -#define A1846S_RSSI_BIT 15 // RSSI readings <9:0> +#define A1846S_RSSI_BIT 15 // RSSI readings <7:0> #define A1846S_RSSI_LENGTH 8 // Bitfields for A1846S_VSSI_REG diff --git a/examples/AFSK-PacketTester/AFSK-PacketTester.ino b/examples/AFSK-PacketTester/AFSK-PacketTester.ino index 95be66b..3089bc7 100644 --- a/examples/AFSK-PacketTester/AFSK-PacketTester.ino +++ b/examples/AFSK-PacketTester/AFSK-PacketTester.ino @@ -8,10 +8,8 @@ #define DDS_REFCLK_DEFAULT 9600 #include -#include #include -//TODO: move these into library #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 @@ -39,8 +37,6 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Serial.begin(115200); - Wire.begin(); - radio.initialize(); radio.frequency(144390); diff --git a/examples/AFSK-SerialMessenger/AFSK-SerialMessenger.ino b/examples/AFSK-SerialMessenger/AFSK-SerialMessenger.ino index 5e35015..ba986da 100644 --- a/examples/AFSK-SerialMessenger/AFSK-SerialMessenger.ino +++ b/examples/AFSK-SerialMessenger/AFSK-SerialMessenger.ino @@ -8,7 +8,6 @@ #define DDS_REFCLK_DEFAULT 9600 #include -#include #include #define PWM_PIN 3 @@ -37,7 +36,7 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Serial.begin(115200); - Wire.begin(); + radio.initialize(); radio.frequency(145570); radio.setRfPower(0); diff --git a/examples/AFSKSend/AFSKSend.ino b/examples/AFSKSend/AFSKSend.ino index 1174ade..858cb97 100644 --- a/examples/AFSKSend/AFSKSend.ino +++ b/examples/AFSKSend/AFSKSend.ino @@ -1,5 +1,4 @@ #include -#include HamShield radio; DDS dds; @@ -13,7 +12,7 @@ DDS dds; void setup() { Serial.begin(9600); - Wire.begin(); + pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); diff --git a/examples/AX25Receive/AX25Receive.ino b/examples/AX25Receive/AX25Receive.ino index b82f446..7b9cc76 100644 --- a/examples/AX25Receive/AX25Receive.ino +++ b/examples/AX25Receive/AX25Receive.ino @@ -1,5 +1,4 @@ #include -#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -22,7 +21,7 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Serial.begin(9600); - Wire.begin(); + Serial.println(F("Radio test connection")); Serial.println(radio.testConnection(), DEC); Serial.println(F("Initialize")); diff --git a/examples/CrystalCalibration/CrystalCalibration.ino b/examples/CrystalCalibration/CrystalCalibration.ino index a6a6f8c..175d5f5 100644 --- a/examples/CrystalCalibration/CrystalCalibration.ino +++ b/examples/CrystalCalibration/CrystalCalibration.ino @@ -3,7 +3,6 @@ #define DDS_DEBUG_SERIAL #include -#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -26,7 +25,7 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Serial.begin(9600); - Wire.begin(); + radio.initialize(); radio.setRfPower(0); radio.setFrequency(145050); diff --git a/examples/DDS/DDS.ino b/examples/DDS/DDS.ino index c995c8b..a843333 100644 --- a/examples/DDS/DDS.ino +++ b/examples/DDS/DDS.ino @@ -1,6 +1,5 @@ #define DDS_REFCLK_DEFAULT 9600 #include -#include #define PWM_PIN 3 @@ -23,7 +22,6 @@ void setup() { // turn on radio digitalWrite(RESET_PIN, HIGH); - Wire.begin(); radio.initialize(); radio.setRfPower(0); radio.setFrequency(145060); diff --git a/examples/FMBeacon/FMBeacon.ino b/examples/FMBeacon/FMBeacon.ino index 78679b3..eac2238 100644 --- a/examples/FMBeacon/FMBeacon.ino +++ b/examples/FMBeacon/FMBeacon.ino @@ -5,9 +5,8 @@ Test beacon will transmit and wait 30 seconds. Beacon will check to see if the channel is clear before it will transmit. */ -// Include the HamSheild and Wire (I2C) libraries +// Include the HamSheild #include -#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -34,9 +33,6 @@ void setup() { // Send a quick serial string Serial.println("HamShield FM Beacon Example Sketch"); - - // Start the Wire (I2C) library - Wire.begin(); // Query the HamShield for status information Serial.print("Radio status: "); diff --git a/examples/FoxHunt/FoxHunt.ino b/examples/FoxHunt/FoxHunt.ino index dd2b906..cd34744 100755 --- a/examples/FoxHunt/FoxHunt.ino +++ b/examples/FoxHunt/FoxHunt.ino @@ -1,7 +1,6 @@ /* Fox Hunt */ #include -//#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -27,7 +26,6 @@ void setup() { pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); - //Wire.begin(); radio.initialize(); radio.frequency(145510); radio.setModeReceive(); diff --git a/examples/FunctionalTest/FunctionalTest.ino b/examples/FunctionalTest/FunctionalTest.ino index c60b2f4..053dc12 100644 --- a/examples/FunctionalTest/FunctionalTest.ino +++ b/examples/FunctionalTest/FunctionalTest.ino @@ -1,7 +1,6 @@ /* HamShield Functional Test */ #include -#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -21,7 +20,6 @@ void setup() { pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); - Wire.begin(); Serial.begin(9600); Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield"); Serial.print("Radio status: "); diff --git a/examples/Gauges/Gauges.ino b/examples/Gauges/Gauges.ino index 4cfc97b..5226796 100755 --- a/examples/Gauges/Gauges.ino +++ b/examples/Gauges/Gauges.ino @@ -7,14 +7,13 @@ Simple gauges for the radio receiver. */ -#include -#include +#include #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 -HAMShield radio; +HamShield radio; void clr() { /* Serial.write(27); @@ -37,7 +36,7 @@ void setup() { analogReference(DEFAULT); Serial.begin(115200); - Wire.begin(); + Serial.print("Radio status: "); int result = radio.testConnection(); Serial.println(result,DEC); diff --git a/examples/HAMBot/HAMBot.ino b/examples/HAMBot/HAMBot.ino index 3a13290..1acdd3c 100755 --- a/examples/HAMBot/HAMBot.ino +++ b/examples/HAMBot/HAMBot.ino @@ -1,15 +1,14 @@ /* Simple DTMF controlled HAM Radio Robot */ #include // include the robot library -#include -#include +#include #include #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 -HAMShield radio; +HamShield radio; void setup() { // NOTE: if not using PWM out, it should be held low to avoid tx noise @@ -24,7 +23,7 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Robot.begin(); - Wire.begin(); + radio.initialize(); radio.frequency(145510); } diff --git a/examples/HandyTalkie/HandyTalkie.ino b/examples/HandyTalkie/HandyTalkie.ino index ab5c9d3..cf19162 100644 --- a/examples/HandyTalkie/HandyTalkie.ino +++ b/examples/HandyTalkie/HandyTalkie.ino @@ -1,9 +1,5 @@ // Hamshield -// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation -// is used in I2Cdev.h -#include "Wire.h" - #include // create object for radio @@ -47,9 +43,6 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Serial.println("beginning radio setup"); - - // join I2C bus (I2Cdev library doesn't do this automatically) - Wire.begin(); // verify connection Serial.println("Testing device connections..."); diff --git a/examples/Identifier/Identifier.ino b/examples/Identifier/Identifier.ino index add371b..1f6f654 100755 --- a/examples/Identifier/Identifier.ino +++ b/examples/Identifier/Identifier.ino @@ -7,8 +7,7 @@ Arduino audio overlay example */ -#include -#include +#include #define DOT 100 @@ -16,7 +15,7 @@ Arduino audio overlay example #define RESET_PIN A3 #define SWITCH_PIN 2 -HAMShield radio; +HamShield radio; const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@", *bitu[] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----.",".-.-.-","--..--","..--..",".----.","-.-.--","-..-.","-.--.","-.--.-",".-...","---...","-.-.-.","-...-",".-.-.","-....-","..--.-",".-..-.","...-..-",".--.-." @@ -40,7 +39,7 @@ void setup() { Serial.begin(9600); Serial.println("starting up.."); - Wire.begin(); + Serial.print("Radio status: "); int result = radio.testConnection(); Serial.println(result,DEC); diff --git a/examples/JustTransmit/JustTransmit.ino b/examples/JustTransmit/JustTransmit.ino index c1dcce5..fd2c1af 100644 --- a/examples/JustTransmit/JustTransmit.ino +++ b/examples/JustTransmit/JustTransmit.ino @@ -1,7 +1,6 @@ /* Just Transmit */ #include -#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -21,7 +20,6 @@ void setup() { pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); - Wire.begin(); Serial.begin(9600); Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield"); Serial.print("Radio status: "); diff --git a/examples/KISS/KISS.ino b/examples/KISS/KISS.ino index eb18a8c..c6680f8 100644 --- a/examples/KISS/KISS.ino +++ b/examples/KISS/KISS.ino @@ -1,5 +1,4 @@ #include -#include #include HamShield radio; @@ -30,7 +29,6 @@ void setup() { // let the AU ot of reset digitalWrite(RESET_PIN, HIGH); - Wire.begin(); radio.initialize(); radio.setSQOff(); radio.setFrequency(144390); diff --git a/examples/Parrot/Parrot.ino b/examples/Parrot/Parrot.ino index d523171..abbbc3e 100755 --- a/examples/Parrot/Parrot.ino +++ b/examples/Parrot/Parrot.ino @@ -6,8 +6,7 @@ A bit robotic and weird */ -#include -#include +#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -16,7 +15,7 @@ A bit robotic and weird #define RATE 500 #define SIZE 1500 -HAMShield radio; +HamShield radio; char sound[SIZE]; unsigned int sample1; @@ -36,7 +35,6 @@ void setup() { pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); - Wire.begin(); // int result = radio.testConnection(); radio.initialize(); radio.setFrequency(446000); diff --git a/examples/SSTV/SSTV.ino b/examples/SSTV/SSTV.ino index 6620947..8cda5c3 100755 --- a/examples/SSTV/SSTV.ino +++ b/examples/SSTV/SSTV.ino @@ -13,10 +13,9 @@ Sends an SSTV test pattern /* Standard libraries and variable init */ -#include -#include +#include -HAMShield radio; +HamShield radio; int16_t rssi; /* get our radio ready */ @@ -33,7 +32,6 @@ void setup() { pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); - Wire.begin(); Serial.begin(9600); Serial.print("Radio status: "); int result = radio.testConnection(); diff --git a/examples/SSTV_M1_Static/SSTV_M1_Static.ino b/examples/SSTV_M1_Static/SSTV_M1_Static.ino index fc5a53f..1618b7b 100644 --- a/examples/SSTV_M1_Static/SSTV_M1_Static.ino +++ b/examples/SSTV_M1_Static/SSTV_M1_Static.ino @@ -2,7 +2,6 @@ #define DDS_REFCLK_DEFAULT (34965/2) #include -#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -31,8 +30,8 @@ void setup() { digitalWrite(RESET_PIN, HIGH); Serial.begin(9600); - Wire.begin(); - // Query the HamShield for status information + + // Query the HamShield for status information Serial.print("Radio status: "); int result = 0; result = radio.testConnection(); diff --git a/examples/SerialTransceiver/SerialTransceiver.ino b/examples/SerialTransceiver/SerialTransceiver.ino index 146c861..530dbee 100644 --- a/examples/SerialTransceiver/SerialTransceiver.ino +++ b/examples/SerialTransceiver/SerialTransceiver.ino @@ -1,6 +1,6 @@ /* -SerialTransceiver is TTL Serial port "glue" to allow desktop or laptop control of the HAMShield +SerialTransceiver is TTL Serial port "glue" to allow desktop or laptop control of the HamShield Commands: @@ -46,7 +46,6 @@ Debug Msg @; 32 character debug message */ -#include "Wire.h" #include "HamShield.h" #define PWM_PIN 3 @@ -85,7 +84,7 @@ void setup() { Serial.begin(115200); Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;"); - Wire.begin(); + int result = radio.testConnection(); Serial.print("*"); Serial.print(result,DEC); diff --git a/examples/SignalTest/SignalTest.ino b/examples/SignalTest/SignalTest.ino index 12461a6..454359b 100755 --- a/examples/SignalTest/SignalTest.ino +++ b/examples/SignalTest/SignalTest.ino @@ -10,15 +10,14 @@ Plays back the current signal strength level and morses out it's call sign at th /* Standard libraries and variable init */ -#include -#include +#include #include #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 -HAMShield radio; +HamShield radio; int16_t rssi; int peak = -150; char sig[8]; @@ -89,7 +88,6 @@ void setup() { pinMode(RESET_PIN, OUTPUT); digitalWrite(RESET_PIN, HIGH); - Wire.begin(); Serial.begin(9600); Serial.print("Radio status: "); int result = radio.testConnection();