SimpleSerial configurable preamble and tail.
This commit is contained in:
parent
86f7f0fc00
commit
9ebbe4f1c6
22
Modem/afsk.c
22
Modem/afsk.c
|
@ -13,10 +13,8 @@
|
|||
#include <struct/fifobuf.h> // FIFO buffer implementation from BertOS
|
||||
#include <string.h> // String operations, primarily used for memset function
|
||||
|
||||
#if SERIAL_PROTOCOL == PROTOCOL_KISS
|
||||
extern unsigned long kiss_preamble;
|
||||
extern unsigned long kiss_tail;
|
||||
#endif
|
||||
extern unsigned long custom_preamble;
|
||||
extern unsigned long custom_tail;
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Definitions and some useful macros //
|
||||
|
@ -453,22 +451,18 @@ static void afsk_txStart(Afsk *afsk) {
|
|||
LED_TX_ON();
|
||||
// We also need to calculate how many HDLC_FLAG
|
||||
// bytes we need to send in preamble
|
||||
#if SERIAL_PROTOCOL == PROTOCOL_KISS
|
||||
afsk->preambleLength = DIV_ROUND(kiss_preamble * BITRATE, 8000);
|
||||
#else
|
||||
afsk->preambleLength = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000);
|
||||
#endif
|
||||
afsk->preambleLength = DIV_ROUND(custom_preamble * BITRATE, 8000);
|
||||
//afsk->preambleLength = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000);
|
||||
|
||||
AFSK_DAC_IRQ_START();
|
||||
}
|
||||
// We make the same calculation for the tail length,
|
||||
// but this needs to be atomic, since the txStart
|
||||
// function could potentially be called while we
|
||||
// are already transmitting.
|
||||
#if SERIAL_PROTOCOL == PROTOCOL_KISS
|
||||
ATOMIC(afsk->tailLength = DIV_ROUND(kiss_tail * BITRATE, 8000));
|
||||
#else
|
||||
ATOMIC(afsk->tailLength = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000));
|
||||
#endif
|
||||
|
||||
ATOMIC(afsk->tailLength = DIV_ROUND(custom_tail * BITRATE, 8000));
|
||||
//ATOMIC(afsk->tailLength = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000));
|
||||
}
|
||||
|
||||
// This is the DAC ISR, called at sampling rate whenever the DAC IRQ is on.
|
||||
|
|
|
@ -13,8 +13,8 @@ size_t frame_len;
|
|||
bool IN_FRAME;
|
||||
bool ESCAPE;
|
||||
uint8_t command = CMD_UNKNOWN;
|
||||
unsigned long kiss_preamble = CONFIG_AFSK_PREAMBLE_LEN;
|
||||
unsigned long kiss_tail = CONFIG_AFSK_TRAILER_LEN;
|
||||
unsigned long custom_preamble = CONFIG_AFSK_PREAMBLE_LEN;
|
||||
unsigned long custom_tail = CONFIG_AFSK_TRAILER_LEN;
|
||||
|
||||
void kiss_init(AX25Ctx *ax25, Serial *ser) {
|
||||
ax25ctx = ax25;
|
||||
|
@ -72,9 +72,9 @@ void kiss_serialCallback(uint8_t sbyte) {
|
|||
serialBuffer[frame_len++] = sbyte;
|
||||
}
|
||||
} else if (command == CMD_TXDELAY) {
|
||||
kiss_preamble = sbyte * 10UL;
|
||||
custom_preamble = sbyte * 10UL;
|
||||
} else if (command == CMD_TXTAIL) {
|
||||
kiss_tail = sbyte * 10;
|
||||
custom_tail = sbyte * 10;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ uint8_t EEMEM nvDIRECTIVITY;
|
|||
uint8_t EEMEM nvSYMBOL_TABLE;
|
||||
uint8_t EEMEM nvSYMBOL;
|
||||
uint8_t EEMEM nvAUTOACK;
|
||||
int EEMEM nvPREAMBLE;
|
||||
int EEMEM nvTAIL;
|
||||
|
||||
// Location packet assembly fields
|
||||
char latitude[8];
|
||||
|
@ -81,6 +83,9 @@ size_t lastMessageLen;
|
|||
bool message_autoAck = false;
|
||||
/////////////////////////
|
||||
|
||||
extern unsigned long custom_preamble;
|
||||
extern unsigned long custom_tail;
|
||||
|
||||
void ss_init(AX25Ctx *ax25) {
|
||||
ax25ctx = ax25;
|
||||
ss_loadSettings();
|
||||
|
@ -131,6 +136,9 @@ void ss_loadSettings(void) {
|
|||
symbol = eeprom_read_byte((void*)&nvSYMBOL);
|
||||
message_autoAck = eeprom_read_byte((void*)&nvAUTOACK);
|
||||
|
||||
custom_preamble = eeprom_read_word((void*)&nvPREAMBLE);
|
||||
custom_tail = eeprom_read_word((void*)&nvTAIL);
|
||||
|
||||
if (VERBOSE && SS_INIT) kprintf("Configuration loaded\n");
|
||||
} else {
|
||||
if (SS_INIT && !SILENT && VERBOSE) kprintf("Error: No stored configuration to load!\n");
|
||||
|
@ -166,6 +174,9 @@ void ss_saveSettings(void) {
|
|||
eeprom_update_byte((void*)&nvSYMBOL, symbol);
|
||||
eeprom_update_byte((void*)&nvAUTOACK, message_autoAck);
|
||||
|
||||
eeprom_update_word((void*)&nvPREAMBLE, custom_preamble);
|
||||
eeprom_update_word((void*)&nvTAIL, custom_tail);
|
||||
|
||||
eeprom_update_byte((void*)&nvMagicByte, NV_MAGIC_BYTE);
|
||||
|
||||
if (VERBOSE) kprintf("Configuration saved\n");
|
||||
|
@ -554,7 +565,6 @@ void ss_serialCallback(void *_buffer, size_t length, Serial *ser, AX25Ctx *ctx)
|
|||
if (!VERBOSE && !SILENT) kprintf("1\n");
|
||||
}
|
||||
|
||||
|
||||
} else if (buffer[0] == 'm' && length > 1) {
|
||||
buffer++; length--;
|
||||
if (buffer[0] == 'c' && length > 1) {
|
||||
|
@ -614,7 +624,27 @@ void ss_serialCallback(void *_buffer, size_t length, Serial *ser, AX25Ctx *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if (buffer[0] == 'w' && length >= 2) {
|
||||
char str[4]; buffer++;
|
||||
memcpy(str, buffer, length-1);
|
||||
int preamble = atoi(str);
|
||||
if (preamble >= 0 && preamble <= 9999) {
|
||||
custom_preamble = preamble;
|
||||
kprintf("Preamble set to %dms\n", custom_preamble);
|
||||
} else {
|
||||
kprintf("Error: Invalid value for preamble\n");
|
||||
}
|
||||
} else if (buffer[0] == 'W' && length >= 2) {
|
||||
char str[4]; buffer++;
|
||||
memcpy(str, buffer, length-1);
|
||||
int tail = atoi(str);
|
||||
if (tail >= 0 && tail <= 9999) {
|
||||
custom_tail = tail;
|
||||
kprintf("TX Tail set to %dms\n", custom_tail);
|
||||
} else {
|
||||
kprintf("Error: Invalid value for TX tail\n");
|
||||
}
|
||||
} else {
|
||||
if (VERBOSE) kprintf("Error: Invalid command\n");
|
||||
if (!VERBOSE && !SILENT) kprintf("0\n");
|
||||
}
|
||||
|
@ -761,6 +791,8 @@ void ss_printSettings(void) {
|
|||
if (symbolTable == '\\') kprintf("Symbol table: alternate\n");
|
||||
if (symbolTable == '/') kprintf("Symbol table: standard\n");
|
||||
kprintf("Symbol: %c\n", symbol);
|
||||
kprintf("TX Preamble: %d\n", custom_preamble);
|
||||
kprintf("TX Tail: %d\n", custom_tail);
|
||||
}
|
||||
|
||||
#if ENABLE_HELP
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define VERS_BUILD 2341
|
||||
#define VERS_BUILD 2364
|
||||
#define VERS_HOST "shard"
|
||||
|
|
BIN
images/Modem.elf
BIN
images/Modem.elf
Binary file not shown.
3441
images/Modem.hex
3441
images/Modem.hex
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue