From c99ac62ee5cd652933bf3c89bb9b443bc5514613 Mon Sep 17 00:00:00 2001 From: Richard Meadows Date: Sun, 13 Dec 2015 12:23:51 +0000 Subject: [PATCH] Add support for faster contestia modes --- firmware/inc/contestia.h | 15 +++++++++++++++ firmware/src/contestia.c | 6 +++--- firmware/src/mfsk.c | 12 ++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/firmware/inc/contestia.h b/firmware/inc/contestia.h index bfb3ec8..b48ede9 100644 --- a/firmware/inc/contestia.h +++ b/firmware/inc/contestia.h @@ -25,6 +25,21 @@ #ifndef CONTESTIA_H #define CONTESTIA_H + +/* /\** */ +/* * Contestia 8/1000 */ +/* *\/ */ +/* #define CONTESTIA_NUMBER_OF_TONES 8 */ +/* #define CONTESTIA_CHARACTERS_PER_BLOCK 3 */ +/* #define CONTESTIA_CHANNEL_SPACING 16 // Corresponds to 124.88 Hz */ +/* #define CONTESTIA_SYMBOL_RATE 125 */ +/* /\** */ +/* * Contestia 16/1000 */ +/* *\/ */ +/* #define CONTESTIA_NUMBER_OF_TONES 16 */ +/* #define CONTESTIA_CHARACTERS_PER_BLOCK 4 */ +/* #define CONTESTIA_CHANNEL_SPACING 8 // Corresponds to 62.44 Hz */ +/* #define CONTESTIA_SYMBOL_RATE 62.5 */ /** * Contestia 32/1000 */ diff --git a/firmware/src/contestia.c b/firmware/src/contestia.c index 388749f..882926d 100644 --- a/firmware/src/contestia.c +++ b/firmware/src/contestia.c @@ -35,7 +35,7 @@ /** * Current output tones */ -int8_t contestia_tones[CONTESTIA_NUMBER_OF_TONES]; +int8_t contestia_tones[32]; /** * Where we are in the current output tones */ @@ -80,7 +80,7 @@ uint8_t contestia_tick(void) { return 1; } - if (contestia_tone_index < CONTESTIA_NUMBER_OF_TONES) { + if (contestia_tone_index < 32) { uint8_t binary_code; uint8_t grey_code; @@ -97,7 +97,7 @@ uint8_t contestia_tick(void) { contestia_tone_index++; - if (contestia_tone_index < CONTESTIA_NUMBER_OF_TONES) { + if (contestia_tone_index < 32) { return 1; } diff --git a/firmware/src/mfsk.c b/firmware/src/mfsk.c index e63e25e..c4985c0 100644 --- a/firmware/src/mfsk.c +++ b/firmware/src/mfsk.c @@ -27,10 +27,12 @@ #include "samd20.h" #include "mfsk.h" #include "math/fwht.h" +#include "contestia.h" static const uint64_t scrambler_olivia = 0xE257E6D0291574ECLL; static const uint64_t scrambler_contestia = 0xEDB88320LL; - +static const uint16_t shift_olivia = 13; +static const uint16_t shift_contestia = 5; /** * USEFUL RESOURES ============================================================= * @@ -110,7 +112,8 @@ void olivia_mfsk_encode_block(char* block, int8_t* tones) { size_t bits_per_symbol = 5; /* That is, there are 2^5=32 tones */ - mfsk_encode_block(block, tones, 64, bits_per_symbol, scrambler_olivia, 13); + mfsk_encode_block(block, tones, 64, bits_per_symbol, + scrambler_olivia, shift_olivia); } /** * This function encodes a single block of Contestia MFSK @@ -120,7 +123,7 @@ void olivia_mfsk_encode_block(char* block, int8_t* tones) */ void contestia_mfsk_encode_block(char* block, int8_t* tones) { - size_t bits_per_symbol = 5; /* That is, there are 2^5=32 tones */ + size_t bits_per_symbol = CONTESTIA_CHARACTERS_PER_BLOCK; /* That is, there are 2^x tones */ for (uint8_t c_index = 0; c_index < bits_per_symbol; c_index++) { char character = block[c_index]; @@ -151,5 +154,6 @@ void contestia_mfsk_encode_block(char* block, int8_t* tones) } - mfsk_encode_block(block, tones, 32, bits_per_symbol, scrambler_contestia, 5); + mfsk_encode_block(block, tones, 32, bits_per_symbol, + scrambler_contestia, shift_contestia); }