2016-08-13 21:05:19 +00:00
|
|
|
/* Hamshield
|
|
|
|
* Example: KISS
|
|
|
|
* This is a example configures the HamShield to be used as
|
|
|
|
* a TNC/KISS device. You will need a KISS device to input
|
|
|
|
* commands to the HamShield
|
|
|
|
* Connect the HamShield to your Arduino. Screw the antenna
|
|
|
|
* into the HamShield RF jack. Connect the Arduino to wall
|
|
|
|
* power and then to your computer via USB. Issue commands
|
|
|
|
* via the KISS equipment.
|
2016-12-27 20:46:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
2016-08-13 21:05:19 +00:00
|
|
|
*/
|
|
|
|
|
2015-07-14 00:55:07 +00:00
|
|
|
#include <HamShield.h>
|
|
|
|
#include <KISS.h>
|
2016-12-27 20:08:28 +00:00
|
|
|
#include <DDS.h>
|
2016-08-20 01:52:36 +00:00
|
|
|
#include <packet.h>
|
2016-12-27 20:08:28 +00:00
|
|
|
#include <avr/wdt.h>
|
2015-07-14 00:55:07 +00:00
|
|
|
|
|
|
|
HamShield radio;
|
|
|
|
DDS dds;
|
2016-08-17 21:17:56 +00:00
|
|
|
AFSK afsk;
|
2016-12-27 20:08:28 +00:00
|
|
|
KISS kiss(&Serial, &radio, &dds, &afsk);
|
2015-07-14 00:55:07 +00:00
|
|
|
|
2015-11-23 16:54:10 +00:00
|
|
|
#define PWM_PIN 3
|
|
|
|
#define RESET_PIN A3
|
|
|
|
#define SWITCH_PIN 2
|
|
|
|
|
2015-07-14 00:55:07 +00:00
|
|
|
void setup() {
|
2015-11-23 16:54:10 +00:00
|
|
|
// NOTE: if not using PWM out, it should be held low to avoid tx noise
|
|
|
|
pinMode(PWM_PIN, OUTPUT);
|
|
|
|
digitalWrite(PWM_PIN, LOW);
|
|
|
|
|
|
|
|
// prep the switch
|
|
|
|
pinMode(SWITCH_PIN, INPUT_PULLUP);
|
|
|
|
|
|
|
|
// set up the reset control pin
|
|
|
|
pinMode(RESET_PIN, OUTPUT);
|
2016-12-27 20:08:28 +00:00
|
|
|
digitalWrite(RESET_PIN, HIGH);
|
2015-07-14 00:55:07 +00:00
|
|
|
|
|
|
|
Serial.begin(9600);
|
2015-11-23 16:54:10 +00:00
|
|
|
|
2015-07-14 00:55:07 +00:00
|
|
|
radio.initialize();
|
2016-12-27 20:08:28 +00:00
|
|
|
//radio.setSQOff();
|
|
|
|
radio.setVolume1(0xFF);
|
|
|
|
radio.setVolume2(0xFF);
|
|
|
|
radio.setSQHiThresh(-100);
|
|
|
|
radio.setSQLoThresh(-100);
|
|
|
|
radio.setSQOn();
|
2016-05-04 18:35:06 +00:00
|
|
|
radio.frequency(144390);
|
2015-07-14 00:55:07 +00:00
|
|
|
|
|
|
|
dds.start();
|
2016-08-17 21:17:56 +00:00
|
|
|
afsk.start(&dds);
|
2016-12-27 20:08:28 +00:00
|
|
|
delay(100);
|
|
|
|
radio.setModeReceive();
|
2015-07-14 00:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
kiss.loop();
|
|
|
|
}
|
|
|
|
|
2016-12-27 20:08:28 +00:00
|
|
|
ISR(TIMER2_OVF_vect) {
|
|
|
|
TIFR2 = _BV(TOV2);
|
|
|
|
static uint8_t tcnt = 0;
|
|
|
|
if(++tcnt == 8) {
|
|
|
|
dds.clockTick();
|
|
|
|
tcnt = 0;
|
|
|
|
}
|
2015-07-14 00:55:07 +00:00
|
|
|
}
|
2016-12-27 20:08:28 +00:00
|
|
|
|
|
|
|
ISR(ADC_vect) {
|
|
|
|
static uint8_t tcnt = 0;
|
|
|
|
TIFR1 = _BV(ICF1); // Clear the timer flag
|
|
|
|
dds.clockTick();
|
|
|
|
if(++tcnt == 1) {
|
|
|
|
afsk.timer();
|
|
|
|
tcnt = 0;
|
|
|
|
}
|
|
|
|
}
|