HamShield/examples/KISS/KISS.ino

89 lines
2.1 KiB
Arduino
Raw Normal View History

/* 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
*/
#include <HamShield.h>
#include <KISS.h>
2016-12-27 20:08:28 +00:00
#include <DDS.h>
2018-06-25 00:16:39 +00:00
#include <packet.h>
2016-12-27 20:08:28 +00:00
#include <avr/wdt.h>
HamShield radio;
DDS dds;
2018-06-25 00:16:39 +00:00
AFSK afsk;
KISS kiss(&Serial, &radio, &dds, &afsk);
2015-11-23 16:54:10 +00:00
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
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);
delay(5); // wait for device to come up
Serial.begin(9600);
2015-11-23 16:54:10 +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);
//radio.bypassPreDeEmph();
dds.start();
2018-06-25 00:16:39 +00:00
afsk.start(&dds);
2016-12-27 20:08:28 +00:00
delay(100);
radio.setModeReceive();
}
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;
}
}
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) {
2018-06-25 00:16:39 +00:00
afsk.timer();
2016-12-27 20:08:28 +00:00
tcnt = 0;
}
}