pull/10/merge
va7ta 2018-02-08 06:44:32 +00:00 committed by GitHub
commit 4b3752c499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 30 deletions

View File

@ -9,6 +9,7 @@ extern bool LibAPRS_open_squelch;
bool hw_afsk_dac_isr = false;
bool hw_5v_ref = false;
bool fullBfrErr=false;
Afsk *AFSK_modem;
@ -25,36 +26,39 @@ void AFSK_hw_refDetect(void) {
}
}
void AFSK_hw_init(void) {
// Set up ADC
namespace AFSKADCINIT{
AFSK_hw_refDetect();
void AFSK_hw_init(void) {
// Set up ADC
TCCR1A = 0;
TCCR1B = _BV(CS10) | _BV(WGM13) | _BV(WGM12);
ICR1 = (((CPU_FREQ+FREQUENCY_CORRECTION)) / 9600) - 1;
AFSK_hw_refDetect();
if (hw_5v_ref) {
ADMUX = _BV(REFS0) | 0;
} else {
ADMUX = 0;
}
TCCR1A = 0;
TCCR1B = _BV(CS10) | _BV(WGM13) | _BV(WGM12);
ICR1 = (((CPU_FREQ+FREQUENCY_CORRECTION)) / 9600) - 1;
ADC_DDR &= ~_BV(0);
ADC_PORT &= ~_BV(0);
DIDR0 |= _BV(0);
ADCSRB = _BV(ADTS2) |
_BV(ADTS1) |
_BV(ADTS0);
ADCSRA = _BV(ADEN) |
_BV(ADSC) |
_BV(ADATE)|
_BV(ADIE) |
_BV(ADPS2);
if (hw_5v_ref) {
ADMUX = _BV(REFS0) | 0;
} else {
ADMUX = 0;
}
AFSK_DAC_INIT();
LED_TX_INIT();
LED_RX_INIT();
ADC_DDR &= ~_BV(0);
ADC_PORT &= ~_BV(0);
DIDR0 |= _BV(0);
ADCSRB = _BV(ADTS2) |
_BV(ADTS1) |
_BV(ADTS0);
ADCSRA = _BV(ADEN) |
_BV(ADSC) |
_BV(ADATE)|
_BV(ADIE) |
_BV(ADPS2);
AFSK_DAC_INIT();
LED_TX_INIT();
LED_RX_INIT();
}
}
void AFSK_init(Afsk *afsk) {
@ -73,7 +77,7 @@ void AFSK_init(Afsk *afsk) {
fifo_push(&afsk->delayFifo, 0);
}
AFSK_hw_init();
AFSKADCINIT::AFSK_hw_init();
}
@ -211,6 +215,8 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) {
ret = false;
hdlc->receiving = false;
LED_RX_OFF();
fullBfrErr=true;
}
// Everytime we receive a HDLC_FLAG, we reset the

View File

@ -10,6 +10,9 @@
#include "HDLC.h"
#define SIN_LEN 512
namespace AFSKADCINIT {
void AFSK_hw_init(void);
};
static const uint8_t sin_table[] PROGMEM =
{
128, 129, 131, 132, 134, 135, 137, 138, 140, 142, 143, 145, 146, 148, 149, 151,

View File

@ -15,6 +15,7 @@
extern int LibAPRS_vref;
extern bool LibAPRS_open_squelch;
bool CRC_Err=false;
void ax25_init(AX25Ctx *ctx, ax25_callback_t hook) {
memset(ctx, 0, sizeof(*ctx));
@ -70,6 +71,8 @@ void ax25_poll(AX25Ctx *ctx) {
LED_RX_ON();
}
ax25_decode(ctx);
}else{
CRC_Err=true;
}
}
ctx->sync = true;

View File

@ -4,7 +4,7 @@
Afsk modem;
AX25Ctx AX25;
extern void aprs_msg_callback(struct AX25Msg *msg);
extern void aprs_msg_callback(struct AX25Msg *msg);
#define countof(a) sizeof(a)/sizeof(a[0])
int LibAPRS_vref = REF_3V3;
@ -12,6 +12,7 @@ bool LibAPRS_open_squelch = false;
unsigned long custom_preamble = 350UL;
unsigned long custom_tail = 50UL;
char dataID_Flag; // '!' no messaging; '=' messaging va7ta update
AX25Call src;
AX25Call dst;
@ -121,6 +122,10 @@ void APRS_setTail(unsigned long tail) {
custom_tail = tail;
}
void APRS_setDataTypeID(uint8_t flag) {//va7ta update
dataID_Flag = flag;//va7ta update
}//va7ta update
void APRS_useAlternateSymbolTable(bool use) {
if (use) {
symbolTable = '\\';
@ -228,7 +233,7 @@ void APRS_sendLoc(void *_buffer, size_t length) {
}
uint8_t *packet = (uint8_t*)malloc(payloadLength);
uint8_t *ptr = packet;
packet[0] = '=';
packet[0] = dataID_Flag; //'!'or'='//va7ta update
packet[9] = symbolTable;
packet[19] = symbol;
ptr++;

View File

@ -19,7 +19,9 @@ void APRS_setPath2(char *call, int ssid);
void APRS_setPreamble(unsigned long pre);
void APRS_setTail(unsigned long tail);
void APRS_useAlternateSymbolTable(bool use);
void APRS_useAlternateSymbolTable(bool use);
void APRS_setDataTypeID(uint8_t flag);
void APRS_setSymbol(char sym);
void APRS_setLat(char *lat);

View File

@ -11,6 +11,10 @@
// OR
//#define ADC_REFERENCE REF_5V
// '!'(33) for no messaging; '='(61)if APRS messaging available
#define APRS_DATA_TYPE_FLAG '='
// Note some squelch delays are too short for catching APRS packets.
// You can also define whether your modem will be
// running with an open squelch radio:
#define OPEN_SQUELCH false
@ -29,8 +33,13 @@
// from your main loop, like this:
boolean gotPacket = false;
extern boolean fullBfrErr;//used for flagging data errors
extern boolean CRC_Err;//used for flagging data errors
AX25Msg incomingPacket;
uint8_t *packetData;
using namespace AFSKADCINIT;//provides access for re-initializing ADC for AFSK decoding
void aprs_msg_callback(struct AX25Msg *msg) {
// If we already have a packet waiting to be
// processed, we must drop the new one.
@ -109,6 +118,8 @@ void locationUpdateExample() {
APRS_setHeight(4);
APRS_setGain(7);
APRS_setDirectivity(0);
APRS_setDataTypeID(APRS_DATA_TYPE_FLAG);//flags if APRS messaging is available
// We'll define a comment string
char *comment = "LibAPRS location update";
@ -164,6 +175,14 @@ void processPacket() {
boolean whichExample = false;
void loop() {
/*
* insert this statement immediately after using the ADC for
* other possible functions such as measuring a voltage from
* a sensor. This is needed to re-configure the ADC for AFSK
* decoding.
*/
// AFSKADCINIT::AFSK_hw_init();// re-initialize AFSK operation
delay(1000);
if (whichExample) {
locationUpdateExample();
@ -174,4 +193,14 @@ void loop() {
delay(500);
processPacket();
}
// monitor packet data errors - Note: cannot be used with open squelch
if(CRC_Err==true){
Serial.println(F("CRC_Error"));
CRC_Err=false;
}
// Flag any buffer overrun errors
if(fullBfrErr==true){
Serial.println(F("FullBufferError"));
fullBfrErr=false;
}
}