12 Commits

Author SHA1 Message Date
Casey Halverson
4f7db1d561 revised lib properties 2017-05-09 13:43:19 -04:00
Casey Halverson
d8d97789d7 Fixed critical define
Fixed a critical define
2017-05-09 13:40:54 -04:00
spaceneedle
d232424bb4 Library properties so Arduino knows to update
Incremented version
2017-05-08 19:23:14 -05:00
spaceneedle
6538ae7db3 Long awaited fix to CTCSS detection and encoding
Two extremely powerful functions:

setCtcssEncoder(float freq)
setCtcssDecoder(float freq)

Yes, that does mean *any* frequency, including non-standard CTCSS tones.

Enjoy.

-Casey
2017-05-08 19:21:18 -05:00
Morgan Redfield
307d33add0 update version to 1.0.3 2017-01-15 12:12:20 -08:00
nick6x
219d89ff60 Merge branch 'master' of https://github.com/EnhancedRadioDevices/HamShield 2017-01-15 12:06:12 -08:00
nick6x
6954402ac6 Clarify example descriptions 2017-01-15 12:05:43 -08:00
morgan
ec0400c1c6 adding narrow/wide band control 2017-01-15 11:31:22 -08:00
morgan
1d02387649 add yaac instructions to example 2016-12-27 12:46:27 -08:00
morgan
4593f1d44c fix KISS example 2016-12-27 12:08:28 -08:00
morgan
292a774a79 make morse dot duration user settable 2016-12-19 11:53:36 -08:00
morgan
5874e6b8e5 make morse tone freq user settable 2016-12-19 11:40:44 -08:00
7 changed files with 301 additions and 98 deletions

View File

@@ -5,9 +5,11 @@
* Connect the HamShield to your Arduino. Screw the antenna * Connect the HamShield to your Arduino. Screw the antenna
* into the HamShield RF jack. Connect the Arduino to wall * into the HamShield RF jack. Connect the Arduino to wall
* power and then to your computer via USB. After uploading * power and then to your computer via USB. After uploading
* this program to your Arduino, open the Serial Monitor. * this program to your Arduino, open the Serial Monitor.
* Type 'h' into the bar at the top of the Serial Monitor * Make sure drop-down menu at the bottom of Serial Monitor
* and click the "Send" button for more instructions. * is set to "Newline". Type 'h' into the bar at the top of
* the Serial Monitor and click the "Send" button for more
* instructions.
*/ */
#define DDS_REFCLK_DEFAULT 38400 #define DDS_REFCLK_DEFAULT 38400

View File

@@ -52,6 +52,9 @@ void setup() {
// Tell the HamShield to start up // Tell the HamShield to start up
radio.initialize(); radio.initialize();
radio.setRfPower(0); radio.setRfPower(0);
radio.setMorseFreq(400);
radio.setMorseDotMillis(200);
// Configure the HamShield to transmit and recieve on 446.000MHz // Configure the HamShield to transmit and recieve on 446.000MHz
radio.frequency(438000); radio.frequency(438000);

View File

@@ -7,16 +7,28 @@
* into the HamShield RF jack. Connect the Arduino to wall * into the HamShield RF jack. Connect the Arduino to wall
* power and then to your computer via USB. Issue commands * power and then to your computer via USB. Issue commands
* via the KISS equipment. * via the KISS equipment.
*
* To use the KISS example with YAAC:
* 1. open the configure YAAC wizard
* 2. follow the prompts and enter in your details until you get to the "Add and Configure Interfaces" window
* 3. Choose "Add Serial KISS TNC Port"
* 4. Choose the COM port for your Arduino
* 5. set baud rate to 9600 (default)
* 6. set it to KISS-only: with no command to enter KISS mode (just leave the box empty)
* 7. Use APRS protocol (default)
* 8. hit the next button and follow directions to finish configuration
*/ */
#include <HamShield.h> #include <HamShield.h>
#include <KISS.h> #include <KISS.h>
#include <DDS.h>
#include <packet.h> #include <packet.h>
#include <avr/wdt.h>
HamShield radio; HamShield radio;
DDS dds; DDS dds;
KISS kiss(&Serial, &radio, &dds);
AFSK afsk; AFSK afsk;
KISS kiss(&Serial, &radio, &dds, &afsk);
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@@ -32,27 +44,44 @@ void setup() {
// set up the reset control pin // set up the reset control pin
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, LOW); digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
while (digitalRead(SWITCH_PIN));
// let the AU ot of reset
digitalWrite(RESET_PIN, HIGH);
radio.initialize(); radio.initialize();
radio.setSQOff(); //radio.setSQOff();
radio.setVolume1(0xFF);
radio.setVolume2(0xFF);
radio.setSQHiThresh(-100);
radio.setSQLoThresh(-100);
radio.setSQOn();
radio.frequency(144390); radio.frequency(144390);
dds.start(); dds.start();
afsk.start(&dds); afsk.start(&dds);
delay(100);
radio.setModeReceive();
} }
void loop() { void loop() {
kiss.loop(); kiss.loop();
} }
ISR(ADC_vect) { ISR(TIMER2_OVF_vect) {
kiss.isr(); TIFR2 = _BV(TOV2);
static uint8_t tcnt = 0;
if(++tcnt == 8) {
dds.clockTick();
tcnt = 0;
}
} }
ISR(ADC_vect) {
static uint8_t tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag
dds.clockTick();
if(++tcnt == 1) {
afsk.timer();
tcnt = 0;
}
}

View File

@@ -28,8 +28,8 @@ Power level P<level>; Set the power amp level, 0 = lowest, 15 = highest
Enable Offset R<state>; 1 turns on repeater offset mode, 0 turns off repeater offset mode No Enable Offset R<state>; 1 turns on repeater offset mode, 0 turns off repeater offset mode No
Squelch S<level>; Set the squelch level No Squelch S<level>; Set the squelch level No
TX Offset T<freq>; The absolute frequency of the repeater offset to transmit on in KHz No TX Offset T<freq>; The absolute frequency of the repeater offset to transmit on in KHz No
RSSI ? Respond with the current receive level in - dBm (no sign provided on numerical response) No RSSI ?; Respond with the current receive level in - dBm (no sign provided on numerical response) No
Voice Level ^ Respond with the current voice level (VSSI) Voice Level ^; Respond with the current voice level (VSSI)
Responses: Responses:

View File

@@ -1,5 +1,5 @@
name=HamShield name=HamShield
version=1.0.2 version=1.0.5
author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com> author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com>
maintainer=Morgan Redfield <morgan@enhancedradio.com> maintainer=Morgan Redfield <morgan@enhancedradio.com>
sentence=A library for use with HamShield by Enhanced Radio Devices. sentence=A library for use with HamShield by Enhanced Radio Devices.
@@ -7,4 +7,4 @@ paragraph=
category=Device Control category=Device Control
url=http://www.hamshield.com url=http://www.hamshield.com
architectures=* architectures=*
includes=HamShield.h includes=HamShield.h

View File

@@ -1,4 +1,4 @@
// HamShield library collection // HamShield library collection
// Based on Programming Manual rev. 2.0, 5/19/2011 (RM-MPU-6000A-00) // Based on Programming Manual rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
// 11/22/2013 by Morgan Redfield <redfieldm@gmail.com> // 11/22/2013 by Morgan Redfield <redfieldm@gmail.com>
// 04/26/2015 various changes Casey Halverson <spaceneedle@gmail.com> // 04/26/2015 various changes Casey Halverson <spaceneedle@gmail.com>
@@ -24,6 +24,10 @@ const uint32_t MURS[] PROGMEM = {0,151820,151880,151940,154570,154600};
const uint32_t WX[] PROGMEM = {0,162550,162400,162475,162425,162450,162500,162525}; const uint32_t WX[] PROGMEM = {0,162550,162400,162475,162425,162450,162500,162525};
unsigned int morse_freq = 600;
unsigned int morse_dot_millis = 100;
/* morse code lookup table */ /* morse code lookup table */
// This is the Morse table in reverse binary format. // This is the Morse table in reverse binary format.
// It will occupy 108 bytes of memory (or program memory if defined) // It will occupy 108 bytes of memory (or program memory if defined)
@@ -101,11 +105,11 @@ const uint16_t asciiMorseProgmem[] PROGMEM = {
}; };
#endif // MORSE_TABLE_PROGMEM #endif // MORSE_TABLE_PROGMEM
/* 2200 Hz */ /* 2200 Hz -- This lookup table should be deprecated */
const unsigned char AFSK_mark[] PROGMEM = { 154, 249, 91, 11, 205, 216, 25, 68, 251, 146, 0, 147, 250, 68, 24, 218, 203, 13, 88, 254, 128, 1, 167, 242, 52, 37, 231, 186, 5, 108, 255, 108, 5, 186, 231, 37, 52, 242, 167, 1, 128, 254, 88, 13, 203, 218, 24, 69, 250, 147, 0, 147, 250, 69, 24, 218, 203, 13, 88, 255, 127, 2, 165, 245, 48 }; const unsigned char AFSK_mark[] PROGMEM = { 154, 249, 91, 11, 205, 216, 25, 68, 251, 146, 0, 147, 250, 68, 24, 218, 203, 13, 88, 254, 128, 1, 167, 242, 52, 37, 231, 186, 5, 108, 255, 108, 5, 186, 231, 37, 52, 242, 167, 1, 128, 254, 88, 13, 203, 218, 24, 69, 250, 147, 0, 147, 250, 69, 24, 218, 203, 13, 88, 255, 127, 2, 165, 245, 48 };
/* 1200 Hz */ /* 1200 Hz -- This lookup table should be deprecated */
const unsigned char AFSK_space[] PROGMEM = { 140, 228, 250, 166, 53, 0, 53, 166, 249, 230, 128, 24, 7, 88, 203, 255, 203, 88, 7, 24, 128, 230, 249, 167, 53, 0, 53, 167, 249, 230, 128, 24, 6, 88, 202, 255, 202, 88, 6, 24, 127, 231, 249, 167, 52, 0, 52, 167, 248, 231, 127, 25, 6, 89, 202, 255, 202, 89, 6, 25, 127, 231, 248, 167, 53, 0, 54, 165, 251, 227, 133, 14}; const unsigned char AFSK_space[] PROGMEM = { 140, 228, 250, 166, 53, 0, 53, 166, 249, 230, 128, 24, 7, 88, 203, 255, 203, 88, 7, 24, 128, 230, 249, 167, 53, 0, 53, 167, 249, 230, 128, 24, 6, 88, 202, 255, 202, 88, 6, 24, 127, 231, 249, 167, 52, 0, 52, 167, 248, 231, 127, 25, 6, 89, 202, 255, 202, 89, 6, 25, 127, 231, 248, 167, 53, 0, 54, 165, 251, 227, 133, 14};
@@ -147,10 +151,19 @@ HamShield::HamShield(uint8_t cs_pin) {
digitalWrite(DAT, HIGH); digitalWrite(DAT, HIGH);
} }
/** Power on and prepare for general usage. /** Power on and prepare for general usage.
* *
*/ */
void HamShield::initialize() { void HamShield::initialize() {
initialize(true);
}
/** Power on and prepare for general usage.
*
*/
void HamShield::initialize(bool narrowBand) {
// Note: these initial settings are for UHF 12.5kHz channel // Note: these initial settings are for UHF 12.5kHz channel
// see the A1846S register table and initial settings for more info // see the A1846S register table and initial settings for more info
@@ -179,7 +192,99 @@ void HamShield::initialize() {
tx_data = 0x0AF2; // tx_data = 0x0AF2; //
HSwriteWord(devAddr, 0x33, tx_data); // agc number HSwriteWord(devAddr, 0x33, tx_data); // agc number
// AGC table tx_data = 0x067F; //0x0601; //0x470F;
HSwriteWord(devAddr, 0x41, tx_data); // voice gain tx [6:0]
tx_data = 0x02FF; // using 0x04FF to avoid tx voice delay
HSwriteWord(devAddr, 0x44, tx_data); // tx gain [11:8]
tx_data = 0x7F2F;
HSwriteWord(devAddr, 0x47, tx_data);
tx_data = 0x2C62;
HSwriteWord(devAddr, 0x4F, tx_data);
tx_data = 0x0094;
HSwriteWord(devAddr, 0x53, tx_data); // compressor update time (bits 6:0, 5.12ms per unit)
tx_data = 0x2A18;
HSwriteWord(devAddr, 0x54, tx_data);
tx_data = 0x0081;
HSwriteWord(devAddr, 0x55, tx_data);
tx_data = 0x0B22;
HSwriteWord(devAddr, 0x56, tx_data); // sq detect time
tx_data = 0x1C00;
HSwriteWord(devAddr, 0x57, tx_data);
tx_data = 0x800D;
HSwriteWord(devAddr, 0x58, tx_data);
tx_data = 0x0EDD;
HSwriteWord(devAddr, 0x5A, tx_data); // sq and noise detect times
tx_data = 0x3FFF;
HSwriteWord(devAddr, 0x63, tx_data); // pre-emphasis bypass
// calibration
tx_data = 0x00A4;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x00A6;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x0006;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
// set band width
if (narrowBand) {
setupNarrowBand();
} else {
setupWideBand();
}
delay(100);
/*
// setup default values
frequency(446000);
//setVolume1(0xF);
//setVolume2(0xF);
setModeReceive();
setTxSourceMic();
setRfPower(0);
setSQLoThresh(80);
setSQOn();
*/
}
/** Set up the AU1846 in Narrow Band mode (12.5kHz).
*/
void HamShield::setupNarrowBand() {
uint16_t tx_data;
// setup for 12.5kHz channel width
tx_data = 0x3D37;
HSwriteWord(devAddr, 0x11, tx_data);
tx_data = 0x0100;
HSwriteWord(devAddr, 0x12, tx_data);
tx_data = 0x1100;
HSwriteWord(devAddr, 0x15, tx_data);
tx_data = 0x4495;
HSwriteWord(devAddr, 0x32, tx_data); // agc target power [11:6]
tx_data = 0x2B8E;
HSwriteWord(devAddr, 0x34, tx_data);
tx_data = 0x40C3;
HSwriteWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
tx_data = 0x0407;
HSwriteWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7]
tx_data = 0x28D0;
HSwriteWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting
tx_data = 0x203E;
HSwriteWord(devAddr, 0x48, tx_data);
tx_data = 0x1BB7;
HSwriteWord(devAddr, 0x60, tx_data);
tx_data = 0x0A10; // use 0x1425 if there's an LNA
HSwriteWord(devAddr, 0x62, tx_data);
tx_data = 0x2494;
HSwriteWord(devAddr, 0x65, tx_data);
tx_data = 0xEB2E;
HSwriteWord(devAddr, 0x66, tx_data);
// AGC table
tx_data = 0x0001; tx_data = 0x0001;
HSwriteWord(devAddr, 0x7F, tx_data); HSwriteWord(devAddr, 0x7F, tx_data);
tx_data = 0x000C; tx_data = 0x000C;
@@ -220,84 +325,80 @@ void HamShield::initialize() {
HSwriteWord(devAddr, 0x7F, tx_data); HSwriteWord(devAddr, 0x7F, tx_data);
// end AGC table // end AGC table
tx_data = 0x067F; //0x0601; //0x470F; }
HSwriteWord(devAddr, 0x41, tx_data); // voice gain tx [6:0]
tx_data = 0x02FF; // using 0x04FF to avoid tx voice delay
HSwriteWord(devAddr, 0x44, tx_data); // tx gain [11:8]
tx_data = 0x7F2F;
HSwriteWord(devAddr, 0x47, tx_data);
tx_data = 0x2C62;
HSwriteWord(devAddr, 0x4F, tx_data);
tx_data = 0x0094;
HSwriteWord(devAddr, 0x53, tx_data); // compressor update time (bits 6:0, 5.12ms per unit)
tx_data = 0x2A18;
HSwriteWord(devAddr, 0x54, tx_data);
tx_data = 0x0081;
HSwriteWord(devAddr, 0x55, tx_data);
tx_data = 0x0B22;
HSwriteWord(devAddr, 0x56, tx_data); // sq detect time
tx_data = 0x1C00;
HSwriteWord(devAddr, 0x57, tx_data);
tx_data = 0x800D;
HSwriteWord(devAddr, 0x58, tx_data);
tx_data = 0x0EDD;
HSwriteWord(devAddr, 0x5A, tx_data); // sq and noise detect times
tx_data = 0x3FFF;
HSwriteWord(devAddr, 0x63, tx_data); // pre-emphasis bypass
// calibration
tx_data = 0x00A4;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x00A6;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x0006;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
/** Set up the AU1846 in Wide Band mode (25kHz).
// setup for 12.5kHz channel width */
void HamShield::setupWideBand() {
uint16_t tx_data;
// setup for 25kHz channel width
tx_data = 0x3D37; tx_data = 0x3D37;
HSwriteWord(devAddr, 0x11, tx_data); HSwriteWord(devAddr, 0x11, tx_data);
tx_data = 0x0100; tx_data = 0x0100;
HSwriteWord(devAddr, 0x12, tx_data); HSwriteWord(devAddr, 0x12, tx_data);
tx_data = 0x1100; tx_data = 0x1F00;
HSwriteWord(devAddr, 0x15, tx_data); HSwriteWord(devAddr, 0x15, tx_data);
tx_data = 0x4495; tx_data = 0x7564;
HSwriteWord(devAddr, 0x32, tx_data); // agc target power [11:6] HSwriteWord(devAddr, 0x32, tx_data); // agc target power [11:6]
tx_data = 0x2B8E; tx_data = 0x2B8E;
HSwriteWord(devAddr, 0x34, tx_data); HSwriteWord(devAddr, 0x34, tx_data);
tx_data = 0x40C3; tx_data = 0x44C3;
HSwriteWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting HSwriteWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
tx_data = 0x0407; tx_data = 0x1930;
HSwriteWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7] HSwriteWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7]
tx_data = 0x28D0; tx_data = 0x29D2;
HSwriteWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting HSwriteWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting
tx_data = 0x203E; tx_data = 0x21C0;
HSwriteWord(devAddr, 0x48, tx_data); HSwriteWord(devAddr, 0x48, tx_data);
tx_data = 0x1BB7; tx_data = 0x101E;
HSwriteWord(devAddr, 0x60, tx_data); HSwriteWord(devAddr, 0x60, tx_data);
tx_data = 0x0A10; // use 0x1425 if there's an LNA tx_data = 0x3767; // use 0x1425 if there's an LNA
HSwriteWord(devAddr, 0x62, tx_data); HSwriteWord(devAddr, 0x62, tx_data);
tx_data = 0x2494; tx_data = 0x248A;
HSwriteWord(devAddr, 0x65, tx_data); HSwriteWord(devAddr, 0x65, tx_data);
tx_data = 0xEB2E; tx_data = 0xFFAE;
HSwriteWord(devAddr, 0x66, tx_data); HSwriteWord(devAddr, 0x66, tx_data);
delay(100); // AGC table
tx_data = 0x0001;
/* HSwriteWord(devAddr, 0x7F, tx_data);
// setup default values tx_data = 0x000C;
frequency(446000); HSwriteWord(devAddr, 0x05, tx_data);
//setVolume1(0xF); tx_data = 0x0024;
//setVolume2(0xF); HSwriteWord(devAddr, 0x06, tx_data);
setModeReceive(); tx_data = 0x0214;
setTxSourceMic(); HSwriteWord(devAddr, 0x07, tx_data);
setRfPower(0); tx_data = 0x0224;
setSQLoThresh(80); HSwriteWord(devAddr, 0x08, tx_data);
setSQOn(); tx_data = 0x0314;
*/ HSwriteWord(devAddr, 0x09, tx_data);
tx_data = 0x0324;
HSwriteWord(devAddr, 0x0A, tx_data);
tx_data = 0x0344;
HSwriteWord(devAddr, 0x0B, tx_data);
tx_data = 0x0384;
HSwriteWord(devAddr, 0x0C, tx_data);
tx_data = 0x1384;
HSwriteWord(devAddr, 0x0D, tx_data);
tx_data = 0x1B84;
HSwriteWord(devAddr, 0x0E, tx_data);
tx_data = 0x3F84;
HSwriteWord(devAddr, 0x0F, tx_data);
tx_data = 0xE0EB;
HSwriteWord(devAddr, 0x12, tx_data);
tx_data = 0xF2FE;
HSwriteWord(devAddr, 0x13, tx_data);
tx_data = 0x0A16;
HSwriteWord(devAddr, 0x14, tx_data);
tx_data = 0x2424;
HSwriteWord(devAddr, 0x15, tx_data);
tx_data = 0x2424;
HSwriteWord(devAddr, 0x16, tx_data);
tx_data = 0x2424;
HSwriteWord(devAddr, 0x17, tx_data);
tx_data = 0x0000;
HSwriteWord(devAddr, 0x7F, tx_data);
// end AGC table
} }
/** Verify the I2C connection. /** Verify the I2C connection.
@@ -571,6 +672,35 @@ uint16_t HamShield::getPABiasVoltage(){
} }
*/ */
// Subaudio settings // Subaudio settings
// recommended function for placing CTCSS tone on channel -- schedule remainder for deprecation
// ctcss freq encoder
void HamShield::setCtcssEncoder(float freq) {
int dfreq = freq * 100; // Convert float into whole number (ctcss freq * 100)
setCtcssFreq(dfreq); // program CTCSS frequency buffer
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 10, 1); // program CTCSS frequency buffer into CTCSS encoder (step 1)
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 9, 1); // program CTCSS frequency buffer into CTCSS encoder (step 2)
}
// recommended function for detecting (and requiring) CTCSS to be on channel before audio is unmuted -- schedule remainder for deprecation
// ctcss freq decoder
void HamShield::setCtcssDecoder(float freq) {
int dfreq = freq * 100; // Convert float into whole number (ctcss freq * 100)
setCtcssFreq(dfreq); // program CTCSS frequency buffer
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 10, 1); // program CTCSS frequency buffer into CTCSS encoder (step 1)
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 9, 1); // program CTCSS frequency buffer into CTCSS encoder (step 2)
}
// TX and RX code // TX and RX code
/* /*
Set code mode: Set code mode:
@@ -1283,6 +1413,29 @@ bool HamShield::waitForChannel(long timeout = 0, long breakwindow = 0, int setRS
return false; return false;
} }
// Get current morse code tone frequency (in Hz)
unsigned int HamShield::getMorseFreq() {
return morse_freq;
}
// Set current morse code tone frequency (in Hz)
void HamShield::setMorseFreq(unsigned int morse_freq_hz) {
morse_freq = morse_freq_hz;
}
// Get current duration of a morse dot (shorter is more WPM)
unsigned int HamShield::getMorseDotMillis() {
return morse_dot_millis;
}
// Set current duration of a morse dot (shorter is more WPM)
void HamShield::setMorseDotMillis(unsigned int morse_dot_dur_millis) {
morse_dot_millis = morse_dot_dur_millis;
}
/* Morse code out, blocking */ /* Morse code out, blocking */
@@ -1295,11 +1448,11 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
// We delay by 4 here, if we previously sent a symbol. Otherwise 7. // We delay by 4 here, if we previously sent a symbol. Otherwise 7.
// This could probably just be always 7 and go relatively unnoticed. // This could probably just be always 7 and go relatively unnoticed.
if(prev == 0 || prev == ' '){ if(prev == 0 || prev == ' '){
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 7); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis * 7);
delay(HAMSHIELD_MORSE_DOT*7); delay(morse_dot_millis*7);
} else { } else {
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 4); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis * 4);
delay(HAMSHIELD_MORSE_DOT*4); delay(morse_dot_millis*4);
} }
continue; continue;
} }
@@ -1308,20 +1461,20 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
if(bits) { // If it is a valid character... if(bits) { // If it is a valid character...
do { do {
if(bits & 1) { if(bits & 1) {
tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT * 3); tone(HAMSHIELD_PWM_PIN, morse_freq, morse_dot_millis * 3);
delay(HAMSHIELD_MORSE_DOT*3); delay(morse_dot_millis*3);
} else { } else {
tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT); tone(HAMSHIELD_PWM_PIN, morse_freq, morse_dot_millis);
delay(HAMSHIELD_MORSE_DOT); delay(morse_dot_millis);
} }
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis);
delay(HAMSHIELD_MORSE_DOT); delay(morse_dot_millis);
bits >>= 1; // Shift into the next symbol bits >>= 1; // Shift into the next symbol
} while(bits != 1); // Wait for 1 termination to be all we have left } while(bits != 1); // Wait for 1 termination to be all we have left
} }
// End of character // End of character
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 3); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis * 3);
delay(HAMSHIELD_MORSE_DOT * 3); delay(morse_dot_millis * 3);
} }
return; return;
} }

View File

@@ -2,7 +2,7 @@
// Based on Programming Manual rev. 2.0, 5/19/2011 (RM-MPU-6000A-00) // Based on Programming Manual rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
// 11/22/2013 by Morgan Redfield <redfieldm@gmail.com> // 11/22/2013 by Morgan Redfield <redfieldm@gmail.com>
// 04/26/2015 various changes Casey Halverson <spaceneedle@gmail.com> // 04/26/2015 various changes Casey Halverson <spaceneedle@gmail.com>
// 05/08/2017 CTCSS code added
#ifndef _HAMSHIELD_H_ #ifndef _HAMSHIELD_H_
@@ -16,7 +16,6 @@
// HamShield constants // HamShield constants
#define HAMSHIELD_MORSE_DOT 100 // Morse code dot length (smaller is faster WPM)
#define HAMSHIELD_MORSE_BUFFER_SIZE 80 // Char buffer size for morse code text #define HAMSHIELD_MORSE_BUFFER_SIZE 80 // Char buffer size for morse code text
#define HAMSHIELD_AUX_BUTTON 2 // Pin assignment for AUX button #define HAMSHIELD_AUX_BUTTON 2 // Pin assignment for AUX button
#define HAMSHIELD_PWM_PIN 3 // Pin assignment for PWM output #define HAMSHIELD_PWM_PIN 3 // Pin assignment for PWM output
@@ -48,6 +47,7 @@
#define A1846S_CTCSS_FREQ_REG 0x4A // ctcss_freq<15:0> #define A1846S_CTCSS_FREQ_REG 0x4A // ctcss_freq<15:0>
#define A1846S_CDCSS_CODE_HI_REG 0x4B // cdcss_code<23:16> #define A1846S_CDCSS_CODE_HI_REG 0x4B // cdcss_code<23:16>
#define A1846S_CDCSS_CODE_LO_REG 0x4C // cdccs_code<15:0> #define A1846S_CDCSS_CODE_LO_REG 0x4C // cdccs_code<15:0>
#define A1846S_CTCSS_FREQ_PRG 0x4e // copies CTCSS value from A1846S_CTCSS_FREQ_REG into CTCSS encoder
#define A1846S_SQ_OUT_SEL_REG 0x54 // see sq #define A1846S_SQ_OUT_SEL_REG 0x54 // see sq
#define A1846S_EMPH_FILTER_REG 0x58 #define A1846S_EMPH_FILTER_REG 0x58
#define A1846S_FLAG_REG 0x5C // holds flags for different statuses #define A1846S_FLAG_REG 0x5C // holds flags for different statuses
@@ -256,7 +256,10 @@ class HamShield {
HamShield(); HamShield();
HamShield(uint8_t cs_pin); HamShield(uint8_t cs_pin);
void initialize(); void initialize(); // defaults to 12.5kHz
void initialize(bool narrowBand); // select 12.5kHz if true or 25kHz if false
void setupWideBand();
void setupNarrowBand();
bool testConnection(); bool testConnection();
// read control reg // read control reg
@@ -309,6 +312,15 @@ class HamShield {
// Subaudio settings // Subaudio settings
// Recommended user function for setting and receiving CTCSS does
// TODO: set others to private and/or deprecate
void setCtcssEncoder(float freq); // generate sub audio tone on channel when transmitting
void setCtcssDecoder(float freq); // unmute audio on tone present when receiving channel
// Ctcss/cdcss mode sel // Ctcss/cdcss mode sel
// x00=disable, // x00=disable,
// 001=inner ctcss en, // 001=inner ctcss en,
@@ -481,6 +493,10 @@ 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();
unsigned int getMorseFreq();
void setMorseFreq(unsigned int morse_freq_hz);
unsigned int getMorseDotMillis();
void setMorseDotMillis(unsigned int morse_dot_dur_millis);
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);