From b4a5a23ae92ebad03e306def9b0c1016350e3b19 Mon Sep 17 00:00:00 2001 From: redpfire Date: Fri, 29 Dec 2023 19:06:40 +0100 Subject: [PATCH] refactor(libm17): restructure the project --- SP5WWP/lib/decode/symbols.c | 16 +++ SP5WWP/lib/decode/symbols.h | 25 ++++ SP5WWP/lib/{m17viterbi.c => decode/viterbi.c} | 12 +- SP5WWP/lib/{m17viterbi.h => decode/viterbi.h} | 11 +- SP5WWP/lib/{m17convol.c => encode/convol.c} | 38 +++-- SP5WWP/lib/{m17convol.h => encode/convol.h} | 14 +- SP5WWP/lib/encode/symbols.c | 10 ++ SP5WWP/lib/{m17lib.h => encode/symbols.h} | 13 +- SP5WWP/lib/{m17lib.c => lib.c} | 6 +- SP5WWP/lib/lib.h | 32 +++++ SP5WWP/lib/m17consts.c | 135 ------------------ SP5WWP/lib/m17consts.h | 90 ------------ SP5WWP/lib/{m17golay.c => math/golay.c} | 29 ++-- SP5WWP/lib/{m17golay.h => math/golay.h} | 8 +- SP5WWP/lib/{m17math.c => math/math.c} | 14 +- SP5WWP/lib/{m17math.h => math/math.h} | 10 +- SP5WWP/lib/math/rrc.c | 67 +++++++++ SP5WWP/lib/math/rrc.h | 23 +++ SP5WWP/lib/{m17call.c => payload/call.c} | 4 +- SP5WWP/lib/{m17call.h => payload/call.h} | 10 +- SP5WWP/lib/{m17crc.c => payload/crc.c} | 11 +- SP5WWP/lib/{m17crc.h => payload/crc.h} | 14 +- SP5WWP/lib/payload/lsf.h | 28 ++++ SP5WWP/lib/phy/interleave.c | 36 +++++ SP5WWP/lib/phy/interleave.h | 19 +++ SP5WWP/lib/phy/randomize.c | 14 ++ SP5WWP/lib/phy/randomize.h | 19 +++ SP5WWP/lib/phy/sync.c | 14 ++ SP5WWP/lib/phy/sync.h | 23 +++ 29 files changed, 415 insertions(+), 330 deletions(-) create mode 100644 SP5WWP/lib/decode/symbols.c create mode 100644 SP5WWP/lib/decode/symbols.h rename SP5WWP/lib/{m17viterbi.c => decode/viterbi.c} (97%) rename SP5WWP/lib/{m17viterbi.h => decode/viterbi.h} (78%) rename SP5WWP/lib/{m17convol.c => encode/convol.c} (86%) rename SP5WWP/lib/{m17convol.h => encode/convol.h} (70%) create mode 100644 SP5WWP/lib/encode/symbols.c rename SP5WWP/lib/{m17lib.h => encode/symbols.h} (50%) rename SP5WWP/lib/{m17lib.c => lib.c} (95%) create mode 100644 SP5WWP/lib/lib.h delete mode 100644 SP5WWP/lib/m17consts.c delete mode 100644 SP5WWP/lib/m17consts.h rename SP5WWP/lib/{m17golay.c => math/golay.c} (97%) rename SP5WWP/lib/{m17golay.h => math/golay.h} (84%) rename SP5WWP/lib/{m17math.c => math/math.c} (97%) rename SP5WWP/lib/{m17math.h => math/math.h} (89%) create mode 100644 SP5WWP/lib/math/rrc.c create mode 100644 SP5WWP/lib/math/rrc.h rename SP5WWP/lib/{m17call.c => payload/call.c} (97%) rename SP5WWP/lib/{m17call.h => payload/call.h} (83%) rename SP5WWP/lib/{m17crc.c => payload/crc.c} (90%) rename SP5WWP/lib/{m17crc.h => payload/crc.h} (76%) create mode 100644 SP5WWP/lib/payload/lsf.h create mode 100644 SP5WWP/lib/phy/interleave.c create mode 100644 SP5WWP/lib/phy/interleave.h create mode 100644 SP5WWP/lib/phy/randomize.c create mode 100644 SP5WWP/lib/phy/randomize.h create mode 100644 SP5WWP/lib/phy/sync.c create mode 100644 SP5WWP/lib/phy/sync.h diff --git a/SP5WWP/lib/decode/symbols.c b/SP5WWP/lib/decode/symbols.c new file mode 100644 index 0000000..d7813bf --- /dev/null +++ b/SP5WWP/lib/decode/symbols.c @@ -0,0 +1,16 @@ +//-------------------------------------------------------------------- +// M17 C library - decode/symbols.c +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 29 December 2023 +//-------------------------------------------------------------------- +#include "symbols.h" + +// syncword patterns (RX) +// TODO: Compute those at runtime from the consts below +const int8_t lsf_sync_symbols[8]={+3, +3, +3, +3, -3, -3, +3, -3}; +const int8_t str_sync_symbols[8]={-3, -3, -3, -3, +3, +3, -3, +3}; +const int8_t pkt_sync_symbols[8]={+3, -3, +3, +3, -3, -3, -3, -3}; + +// symbol levels (RX) +const float symbol_levels[4]={-3.0, -1.0, +1.0, +3.0}; diff --git a/SP5WWP/lib/decode/symbols.h b/SP5WWP/lib/decode/symbols.h new file mode 100644 index 0000000..1dbec3d --- /dev/null +++ b/SP5WWP/lib/decode/symbols.h @@ -0,0 +1,25 @@ +//------------------------------- +// M17 C library - decode/symbols.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#include + +// syncword patterns (RX) +// TODO: Compute those at runtime from the consts below +extern const int8_t lsf_sync_symbols[8]; +extern const int8_t str_sync_symbols[8]; +extern const int8_t pkt_sync_symbols[8]; + +// symbol levels (RX) +extern const float symbol_levels[4]; + +#ifdef __cplusplus +} +#endif diff --git a/SP5WWP/lib/m17viterbi.c b/SP5WWP/lib/decode/viterbi.c similarity index 97% rename from SP5WWP/lib/m17viterbi.c rename to SP5WWP/lib/decode/viterbi.c index 676c023..fd4ef06 100644 --- a/SP5WWP/lib/m17viterbi.c +++ b/SP5WWP/lib/decode/viterbi.c @@ -1,17 +1,17 @@ //-------------------------------------------------------------------- -// M17 C library - m17viterbi.c +// M17 C library - decode/viterbi.c // // This file contains: -// - all the Viterbi decoder stuff +// - the Viterbi decoder // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- #include #include -#include "m17consts.h" -#include "m17math.h" -#include "m17viterbi.h" + +#include +#include "viterbi.h" static uint32_t prevMetrics[NUM_STATES]; static uint32_t currMetrics[NUM_STATES]; @@ -200,4 +200,4 @@ void viterbi_reset(void) memset((uint8_t*)prevMetrics, 0, 4*NUM_STATES); memset((uint8_t*)currMetricsData, 0, 4*NUM_STATES); memset((uint8_t*)prevMetricsData, 0, 4*NUM_STATES); -} \ No newline at end of file +} diff --git a/SP5WWP/lib/m17viterbi.h b/SP5WWP/lib/decode/viterbi.h similarity index 78% rename from SP5WWP/lib/m17viterbi.h rename to SP5WWP/lib/decode/viterbi.h index 4ed3d4b..103905f 100644 --- a/SP5WWP/lib/m17viterbi.h +++ b/SP5WWP/lib/decode/viterbi.h @@ -1,21 +1,19 @@ //-------------------------------------------------------------------- -// M17 C library - m17viterbi.h +// M17 C library - decode/viterbi.h // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- -#ifndef M17_VITERBI_LIB -#define M17_VITERBI_LIB +#pragma once #ifdef __cplusplus extern "C" { #endif #include -//vars -; +#define K 5 //constraint length +#define NUM_STATES (1 << (K - 1)) //number of states -//functions uint32_t viterbi_decode(uint8_t* out, const uint16_t* in, const uint16_t len); uint32_t viterbi_decode_punctured(uint8_t* out, const uint16_t* in, const uint8_t* punct, const uint16_t in_len, const uint16_t p_len); void viterbi_decode_bit(uint16_t s0, uint16_t s1, size_t pos); @@ -25,4 +23,3 @@ void viterbi_reset(void); #ifdef __cplusplus } #endif -#endif \ No newline at end of file diff --git a/SP5WWP/lib/m17convol.c b/SP5WWP/lib/encode/convol.c similarity index 86% rename from SP5WWP/lib/m17convol.c rename to SP5WWP/lib/encode/convol.c index b6ba863..27ebb0b 100644 --- a/SP5WWP/lib/m17convol.c +++ b/SP5WWP/lib/encode/convol.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------------- -// M17 C library - m17convol.c +// M17 C library - encode/convol.c // // This file contains: // - convolutional encoders for the LSF, stream, and packet frames @@ -8,18 +8,28 @@ // M17 Project, 29 December 2023 //-------------------------------------------------------------------- #include -#include "m17convol.h" +#include "convol.h" + +const uint8_t puncture_pattern_1[61] = { + 1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1, + 1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1, + 1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1, + 1,0,1,1,1,0,1,1,1,0,1,1 +}; + +const uint8_t puncture_pattern_2[12]={1,1,1,1,1,1,1,1,1,1,1,0}; +const uint8_t puncture_pattern_3[8]={1,1,1,1,1,1,1,0}; /** * @brief Encode M17 stream frame using convolutional encoder with puncturing. - * + * * @param out Output array, unpacked. * @param in Input - packed array of uint8_t, 144 type-1 bits. * @param fn Input - 16-bit frame number. */ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn) { - uint8_t pp_len = sizeof(P_2); + uint8_t pp_len = sizeof(puncture_pattern_2); uint8_t p=0; //puncturing pattern index uint16_t pb=0; //pushed punctured bits uint8_t ud[144+4+4]; //unpacked data @@ -49,7 +59,7 @@ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn //printf("%d%d", G1, G2); - if(P_2[p]) + if(puncture_pattern_2[p]) { out[pb]=G1; pb++; @@ -58,7 +68,7 @@ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn p++; p%=pp_len; - if(P_2[p]) + if(puncture_pattern_2[p]) { out[pb]=G2; pb++; @@ -73,13 +83,13 @@ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn /** * @brief Encode M17 packet frame using convolutional encoder with puncturing. - * + * * @param out Output array, unpacked. * @param in Input - packed array of uint8_t, 206 type-1 bits. */ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in) { - uint8_t pp_len = sizeof(P_3); + uint8_t pp_len = sizeof(puncture_pattern_3); uint8_t p=0; //puncturing pattern index uint16_t pb=0; //pushed punctured bits uint8_t ud[206+4+4]; //unpacked data @@ -104,7 +114,7 @@ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in) //fprintf(stderr, "%d%d", G1, G2); - if(P_3[p]) + if(puncture_pattern_3[p]) { out[pb]=G1; pb++; @@ -113,7 +123,7 @@ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in) p++; p%=pp_len; - if(P_3[p]) + if(puncture_pattern_3[p]) { out[pb]=G2; pb++; @@ -128,13 +138,13 @@ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in) /** * @brief Encode M17 stream frame using convolutional encoder with puncturing. - * + * * @param out Output array, unpacked. * @param in Input - pointer to a struct holding the Link Setup Frame. */ void conv_encode_LSF(uint8_t* out, const struct LSF *in) { - uint8_t pp_len = sizeof(P_1); + uint8_t pp_len = sizeof(puncture_pattern_1); uint8_t p=0; //puncturing pattern index uint16_t pb=0; //pushed punctured bits uint8_t ud[240+4+4]; //unpacked data @@ -204,7 +214,7 @@ void conv_encode_LSF(uint8_t* out, const struct LSF *in) //printf("%d%d", G1, G2); - if(P_1[p]) + if(puncture_pattern_1[p]) { out[pb]=G1; pb++; @@ -213,7 +223,7 @@ void conv_encode_LSF(uint8_t* out, const struct LSF *in) p++; p%=pp_len; - if(P_1[p]) + if(puncture_pattern_1[p]) { out[pb]=G2; pb++; diff --git a/SP5WWP/lib/m17convol.h b/SP5WWP/lib/encode/convol.h similarity index 70% rename from SP5WWP/lib/m17convol.h rename to SP5WWP/lib/encode/convol.h index f991db2..b0c86a9 100644 --- a/SP5WWP/lib/m17convol.h +++ b/SP5WWP/lib/encode/convol.h @@ -1,22 +1,21 @@ //-------------------------------------------------------------------- -// M17 C library - m17convol.h +// M17 C library - encode/convol.h // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- -#ifndef M17_CONVOL_LIB -#define M17_CONVOL_LIB +#pragma once #ifdef __cplusplus extern "C" { #endif #include -#include "m17consts.h" +#include -//vars -; +extern const uint8_t puncture_pattern_1[61]; +extern const uint8_t puncture_pattern_2[12]; +extern const uint8_t puncture_pattern_3[8]; -//functions void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn); void conv_encode_packet_frame(uint8_t* out, const uint8_t* in); void conv_encode_LSF(uint8_t* out, const struct LSF *in); @@ -24,4 +23,3 @@ void conv_encode_LSF(uint8_t* out, const struct LSF *in); #ifdef __cplusplus } #endif -#endif \ No newline at end of file diff --git a/SP5WWP/lib/encode/symbols.c b/SP5WWP/lib/encode/symbols.c new file mode 100644 index 0000000..f80c897 --- /dev/null +++ b/SP5WWP/lib/encode/symbols.c @@ -0,0 +1,10 @@ +//-------------------------------------------------------------------- +// M17 C library - encode/symbols.c +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 29 December 2023 +//-------------------------------------------------------------------- +#include "symbols.h" + +// dibits-symbols map (TX) +const int8_t symbol_map[4]={+1, +3, -1, -3}; diff --git a/SP5WWP/lib/m17lib.h b/SP5WWP/lib/encode/symbols.h similarity index 50% rename from SP5WWP/lib/m17lib.h rename to SP5WWP/lib/encode/symbols.h index 30bcec7..9016d69 100644 --- a/SP5WWP/lib/m17lib.h +++ b/SP5WWP/lib/encode/symbols.h @@ -1,24 +1,19 @@ //------------------------------- -// M17 C library - m17lib.h +// M17 C library - encode/symbols.h // // Wojciech Kaczmarski, SP5WWP // M17 Project, 28 December 2023 //------------------------------- -#ifndef M17_LIB -#define M17_LIB +#pragma once #ifdef __cplusplus extern "C" { #endif #include -//functions -void send_preamble(const uint8_t type); -void send_syncword(const uint16_t syncword); -void send_data(const uint8_t* in); -void send_eot(void); +// dibits-symbols map (TX) +extern const int8_t symbol_map[4]; #ifdef __cplusplus } #endif -#endif diff --git a/SP5WWP/lib/m17lib.c b/SP5WWP/lib/lib.c similarity index 95% rename from SP5WWP/lib/m17lib.c rename to SP5WWP/lib/lib.c index 08e12c6..92a5694 100644 --- a/SP5WWP/lib/m17lib.c +++ b/SP5WWP/lib/lib.c @@ -1,12 +1,12 @@ //-------------------------------------------------------------------- -// M17 C library - m17lib.c +// M17 C library - lib.c // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- #include -#include "m17consts.h" -#include "m17lib.h" +#include +#include "lib.h" //misc void send_preamble(const uint8_t type) diff --git a/SP5WWP/lib/lib.h b/SP5WWP/lib/lib.h new file mode 100644 index 0000000..0cf72d0 --- /dev/null +++ b/SP5WWP/lib/lib.h @@ -0,0 +1,32 @@ +//------------------------------- +// M17 C library - lib.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#include + +#define BSB_SPS 10 //samples per symbol +#define FLT_SPAN 8 //baseband RRC filter span in symbols +#define SYM_PER_SWD 8 //symbols per syncword +#define SW_LEN (BSB_SPS*SYM_PER_SWD) //syncword detector length +#define SYM_PER_PLD 184 //symbols per payload in a frame +#define SYM_PER_FRA 192 //symbols per whole 40 ms frame +#define RRC_DEV 7168.0f //.rrc file deviation for +1.0 symbol + +//L2 metric threshold +#define DIST_THRESH 2.0f //threshold for distance (syncword detection) + +void send_preamble(const uint8_t type); +void send_syncword(const uint16_t syncword); +void send_data(const uint8_t* in); +void send_eot(void); + +#ifdef __cplusplus +} +#endif diff --git a/SP5WWP/lib/m17consts.c b/SP5WWP/lib/m17consts.c deleted file mode 100644 index 2364ecb..0000000 --- a/SP5WWP/lib/m17consts.c +++ /dev/null @@ -1,135 +0,0 @@ -//-------------------------------------------------------------------- -// M17 C library - m17consts.c -// -// Wojciech Kaczmarski, SP5WWP -// M17 Project, 29 December 2023 -//-------------------------------------------------------------------- -#include "m17consts.h" - -//syncword patterns (RX) TODO:Compute those at runtime from the consts below -const int8_t lsf_sync[8]={+3, +3, +3, +3, -3, -3, +3, -3}; -const int8_t str_sync[8]={-3, -3, -3, -3, +3, +3, -3, +3}; -const int8_t pkt_sync[8]={+3, -3, +3, +3, -3, -3, -3, -3}; - -//symbol levels (RX) -const float symbs[4]={-3.0, -1.0, +1.0, +3.0}; - -//dibits-symbols map (TX) -const int8_t symbol_map[4]={+1, +3, -1, -3}; - -//syncwords -const uint16_t SYNC_LSF = 0x55F7; -const uint16_t SYNC_STR = 0xFF5D; -const uint16_t SYNC_PKT = 0x75FF; -const uint16_t SYNC_BER = 0xDF55; -const uint16_t EOT_MRKR = 0x555D; - -//puncturing pattern P_1 -const uint8_t P_1[61]={1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1, - 1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1, - 1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1, - 1,0,1,1,1,0,1,1,1,0,1,1}; - -//puncturing pattern P_2 -const uint8_t P_2[12]={1,1,1,1,1,1,1,1,1,1,1,0}; - -//puncturing pattern P_3 -const uint8_t P_3[8]={1,1,1,1,1,1,1,0}; - -//M17 CRC polynomial -const uint16_t M17_CRC_POLY = 0x5935; - -//sample RRC filter for 48kHz sample rate -//alpha=0.5, span=8, sps=10, gain=sqrt(sps) -const float taps_10[8*10+1]= -{ - -0.003195702904062073f, -0.002930279157647190f, -0.001940667871554463f, - -0.000356087678023658f, 0.001547011339077758f, 0.003389554791179751f, - 0.004761898604225673f, 0.005310860846138910f, 0.004824746306020221f, - 0.003297923526848786f, 0.000958710871218619f, -0.001749908029791816f, - -0.004238694106631223f, -0.005881783042101693f, -0.006150256456781309f, - -0.004745376707651645f, -0.001704189656473565f, 0.002547854551539951f, - 0.007215575568844704f, 0.011231038205363532f, 0.013421952197060707f, - 0.012730475385624438f, 0.008449554307303753f, 0.000436744366018287f, - -0.010735380379191660f, -0.023726883538258272f, -0.036498030780605324f, - -0.046500883189991064f, -0.050979050575999614f, -0.047340680079891187f, - -0.033554880492651755f, -0.008513823955725943f, 0.027696543159614194f, - 0.073664520037517042f, 0.126689053778116234f, 0.182990955139333916f, - 0.238080025892859704f, 0.287235637987091563f, 0.326040247765297220f, - 0.350895727088112619f, 0.359452932027607974f, 0.350895727088112619f, - 0.326040247765297220f, 0.287235637987091563f, 0.238080025892859704f, - 0.182990955139333916f, 0.126689053778116234f, 0.073664520037517042f, - 0.027696543159614194f, -0.008513823955725943f, -0.033554880492651755f, - -0.047340680079891187f, -0.050979050575999614f, -0.046500883189991064f, - -0.036498030780605324f, -0.023726883538258272f, -0.010735380379191660f, - 0.000436744366018287f, 0.008449554307303753f, 0.012730475385624438f, - 0.013421952197060707f, 0.011231038205363532f, 0.007215575568844704f, - 0.002547854551539951f, -0.001704189656473565f, -0.004745376707651645f, - -0.006150256456781309f, -0.005881783042101693f, -0.004238694106631223f, - -0.001749908029791816f, 0.000958710871218619f, 0.003297923526848786f, - 0.004824746306020221f, 0.005310860846138910f, 0.004761898604225673f, - 0.003389554791179751f, 0.001547011339077758f, -0.000356087678023658f, - -0.001940667871554463f, -0.002930279157647190f, -0.003195702904062073f -}; - -//sample RRC filter for 24kHz sample rate -//alpha=0.5, span=8, sps=5, gain=sqrt(sps) -const float taps_5[8*5+1]= -{ - -0.004519384154389f, -0.002744505321971f, - 0.002187793653660f, 0.006734308458208f, - 0.006823188093192f, 0.001355815246317f, - -0.005994389201970f, -0.008697733303330f, - -0.002410076268276f, 0.010204314627992f, - 0.018981413448435f, 0.011949415510291f, - -0.015182045838927f, -0.051615756197679f, - -0.072094910038768f, -0.047453533621088f, - 0.039168634270669f, 0.179164496628150f, - 0.336694345124862f, 0.461088271869920f, - 0.508340710642860f, 0.461088271869920f, - 0.336694345124862f, 0.179164496628150f, - 0.039168634270669f, -0.047453533621088f, - -0.072094910038768f, -0.051615756197679f, - -0.015182045838927f, 0.011949415510291f, - 0.018981413448435f, 0.010204314627992f, - -0.002410076268276f, -0.008697733303330f, - -0.005994389201970f, 0.001355815246317f, - 0.006823188093192f, 0.006734308458208f, - 0.002187793653660f, -0.002744505321971f, - -0.004519384154389f -}; - -//randomizing pattern -const uint8_t rand_seq[46]= -{ - 0xD6, 0xB5, 0xE2, 0x30, 0x82, 0xFF, 0x84, 0x62, 0xBA, 0x4E, 0x96, 0x90, 0xD8, 0x98, 0xDD, 0x5D, 0x0C, 0xC8, 0x52, 0x43, 0x91, 0x1D, 0xF8, - 0x6E, 0x68, 0x2F, 0x35, 0xDA, 0x14, 0xEA, 0xCD, 0x76, 0x19, 0x8D, 0xD5, 0x80, 0xD1, 0x33, 0x87, 0x13, 0x57, 0x18, 0x2D, 0x29, 0x78, 0xC3 -}; - -//interleaver pattern -const uint16_t intrl_seq[368]= -{ - 0, 137, 90, 227, 180, 317, 270, 39, 360, 129, 82, 219, 172, 309, 262, 31, - 352, 121, 74, 211, 164, 301, 254, 23, 344, 113, 66, 203, 156, 293, 246, 15, - 336, 105, 58, 195, 148, 285, 238, 7, 328, 97, 50, 187, 140, 277, 230, 367, - 320, 89, 42, 179, 132, 269, 222, 359, 312, 81, 34, 171, 124, 261, 214, 351, - 304, 73, 26, 163, 116, 253, 206, 343, 296, 65, 18, 155, 108, 245, 198, 335, - 288, 57, 10, 147, 100, 237, 190, 327, 280, 49, 2, 139, 92, 229, 182, 319, - 272, 41, 362, 131, 84, 221, 174, 311, 264, 33, 354, 123, 76, 213, 166, 303, - 256, 25, 346, 115, 68, 205, 158, 295, 248, 17, 338, 107, 60, 197, 150, 287, - 240, 9, 330, 99, 52, 189, 142, 279, 232, 1, 322, 91, 44, 181, 134, 271, - 224, 361, 314, 83, 36, 173, 126, 263, 216, 353, 306, 75, 28, 165, 118, 255, - 208, 345, 298, 67, 20, 157, 110, 247, 200, 337, 290, 59, 12, 149, 102, 239, - 192, 329, 282, 51, 4, 141, 94, 231, 184, 321, 274, 43, 364, 133, 86, 223, - 176, 313, 266, 35, 356, 125, 78, 215, 168, 305, 258, 27, 348, 117, 70, 207, - 160, 297, 250, 19, 340, 109, 62, 199, 152, 289, 242, 11, 332, 101, 54, 191, - 144, 281, 234, 3, 324, 93, 46, 183, 136, 273, 226, 363, 316, 85, 38, 175, - 128, 265, 218, 355, 308, 77, 30, 167, 120, 257, 210, 347, 300, 69, 22, 159, - 112, 249, 202, 339, 292, 61, 14, 151, 104, 241, 194, 331, 284, 53, 6, 143, - 96, 233, 186, 323, 276, 45, 366, 135, 88, 225, 178, 315, 268, 37, 358, 127, - 80, 217, 170, 307, 260, 29, 350, 119, 72, 209, 162, 299, 252, 21, 342, 111, - 64, 201, 154, 291, 244, 13, 334, 103, 56, 193, 146, 283, 236, 5, 326, 95, - 48, 185, 138, 275, 228, 365, 318, 87, 40, 177, 130, 267, 220, 357, 310, 79, - 32, 169, 122, 259, 212, 349, 302, 71, 24, 161, 114, 251, 204, 341, 294, 63, - 16, 153, 106, 243, 196, 333, 286, 55, 8, 145, 98, 235, 188, 325, 278, 47 -}; diff --git a/SP5WWP/lib/m17consts.h b/SP5WWP/lib/m17consts.h deleted file mode 100644 index 7f11440..0000000 --- a/SP5WWP/lib/m17consts.h +++ /dev/null @@ -1,90 +0,0 @@ -//-------------------------------------------------------------------- -// M17 C library - m17consts.h -// -// Wojciech Kaczmarski, SP5WWP -// M17 Project, 29 December 2023 -//-------------------------------------------------------------------- -#ifndef M17_CONSTS -#define M17_CONSTS - -#ifdef __cplusplus -extern "C" { -#endif -#include - -#define BSB_SPS 10 //samples per symbol -#define FLT_SPAN 8 //baseband RRC filter span in symbols -#define SYM_PER_SWD 8 //symbols per syncword -#define SW_LEN (BSB_SPS*SYM_PER_SWD) //syncword detector length -#define SYM_PER_PLD 184 //symbols per payload in a frame -#define SYM_PER_FRA 192 //symbols per whole 40 ms frame -#define RRC_DEV 7168.0f //.rrc file deviation for +1.0 symbol - -//L2 metric threshold -#define DIST_THRESH 2.0f //threshold for distance (syncword detection) - -//Viterbi -#define K 5 //constraint length -#define NUM_STATES (1 << (K - 1)) //number of states - -//syncword patterns (RX) TODO:Compute those at runtime from the consts below -extern const int8_t lsf_sync[8]; -extern const int8_t str_sync[8]; -extern const int8_t pkt_sync[8]; - -//symbol levels (RX) -extern const float symbs[4]; - -//dibits-symbols map (TX) -extern const int8_t symbol_map[4]; - -//syncwords -extern const uint16_t SYNC_LSF; -extern const uint16_t SYNC_STR; -extern const uint16_t SYNC_PKT; -extern const uint16_t SYNC_BER; -extern const uint16_t EOT_MRKR; - -//puncturing pattern P_1 -extern const uint8_t P_1[61]; - -//puncturing pattern P_2 -extern const uint8_t P_2[12]; - -//puncturing pattern P_3 -extern const uint8_t P_3[8]; - -//M17 CRC polynomial -extern const uint16_t M17_CRC_POLY; - -//sample RRC filter for 48kHz sample rate -//alpha=0.5, span=8, sps=10, gain=sqrt(sps) -extern const float taps_10[8*10+1]; - -//sample RRC filter for 24kHz sample rate -//alpha=0.5, span=8, sps=5, gain=sqrt(sps) -extern const float taps_5[8*5+1]; - -//randomizing pattern -extern const uint8_t rand_seq[46]; - -//interleaver pattern -extern const uint16_t intrl_seq[368]; - -/** - * @brief Structure holding Link Setup Frame data. - * - */ -struct LSF -{ - uint8_t dst[6]; - uint8_t src[6]; - uint8_t type[2]; - uint8_t meta[112/8]; - uint8_t crc[2]; -}; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/SP5WWP/lib/m17golay.c b/SP5WWP/lib/math/golay.c similarity index 97% rename from SP5WWP/lib/m17golay.c rename to SP5WWP/lib/math/golay.c index 59c81d8..b0d8938 100644 --- a/SP5WWP/lib/m17golay.c +++ b/SP5WWP/lib/math/golay.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------------- -// M17 C library - m17golay.c +// M17 C library - math/golay.c // // This file contains: // - Golay(24, 12) encoder @@ -10,12 +10,13 @@ // M17 Project, 29 December 2023 //-------------------------------------------------------------------- #include -#include "m17math.h" -#include "m17golay.h" + +#include +#include "golay.h" /** * @brief Precomputed encoding matrix for Golay(24, 12). - * + * */ const uint16_t encode_matrix[12]= { @@ -25,7 +26,7 @@ const uint16_t encode_matrix[12]= /** * @brief Precomputed decoding matrix for Golay(24, 12). - * + * */ const uint16_t decode_matrix[12]= { @@ -35,7 +36,7 @@ const uint16_t decode_matrix[12]= /** * @brief Encode a 12-bit value with Golay(24, 12). - * + * * @param data 12-bit input value (right justified). * @return uint32_t 24-bit Golay codeword. */ @@ -56,7 +57,7 @@ uint32_t golay24_encode(const uint16_t data) /** * @brief Soft-valued equivalent of `popcount()` - * + * * @param in Pointer to an array holding soft logic vector. * @param siz Vector's size. * @return uint32_t Sum of all values. @@ -72,10 +73,10 @@ uint32_t s_popcount(const uint16_t* in, uint8_t siz) } /** - * @brief - * - * @param out - * @param value + * @brief + * + * @param out + * @param value */ void s_calc_checksum(uint16_t* out, const uint16_t* value) { @@ -100,7 +101,7 @@ void s_calc_checksum(uint16_t* out, const uint16_t* value) /** * @brief Detect errors in a soft-valued Golay(24, 12) codeword. - * + * * @param codeword Input 24-bit soft codeword. * @return uint32_t Detected errors vector. */ @@ -216,7 +217,7 @@ uint32_t s_detect_errors(const uint16_t* codeword) /** * @brief Soft decode Golay(24, 12) codeword. - * + * * @param codeword Pointer to a 24-element soft-valued (fixed-point) bit codeword. * @return uint16_t Decoded data. */ @@ -237,7 +238,7 @@ uint16_t golay24_sdecode(const uint16_t codeword[24]) /** * @brief Soft decode LICH into a 6-byte array. - * + * * @param outp An array of packed, decoded bits. * @param inp Pointer to an array of 96 soft bits. */ diff --git a/SP5WWP/lib/m17golay.h b/SP5WWP/lib/math/golay.h similarity index 84% rename from SP5WWP/lib/m17golay.h rename to SP5WWP/lib/math/golay.h index b0b3892..1eec0f9 100644 --- a/SP5WWP/lib/m17golay.h +++ b/SP5WWP/lib/math/golay.h @@ -1,22 +1,19 @@ //-------------------------------------------------------------------- -// M17 C library - m17golay.h +// M17 C library - math/golay.h // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- -#ifndef M17_GOLAY_LIB -#define M17_GOLAY_LIB +#pragma once #ifdef __cplusplus extern "C" { #endif #include -//consts extern const uint16_t encode_matrix[12]; extern const uint16_t decode_matrix[12]; -//functions uint32_t golay24_encode(const uint16_t data); uint16_t golay24_sdecode(const uint16_t codeword[24]); void decode_LICH(uint8_t* outp, const uint16_t* inp); @@ -24,4 +21,3 @@ void decode_LICH(uint8_t* outp, const uint16_t* inp); #ifdef __cplusplus } #endif -#endif diff --git a/SP5WWP/lib/m17math.c b/SP5WWP/lib/math/math.c similarity index 97% rename from SP5WWP/lib/m17math.c rename to SP5WWP/lib/math/math.c index 75eb752..146d240 100644 --- a/SP5WWP/lib/m17math.c +++ b/SP5WWP/lib/math/math.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------------- -// M17 C library - m17math.c +// M17 C library - math/math.c // // This file contains: // - absolute difference value @@ -11,7 +11,7 @@ // M17 Project, 29 December 2023 //-------------------------------------------------------------------- #include -#include "m17math.h" +#include "math.h" /** * @brief Utility function returning the absolute value of a difference between @@ -29,7 +29,7 @@ uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2) /** * @brief Calculate L2 norm between two n-dimensional vectors of floats. - * + * * @param in1 Vector 1. * @param in2 Vector 2. * @param n Vectors' size. @@ -84,7 +84,7 @@ uint16_t soft_to_int(const uint16_t* in, const uint8_t len) /** * @brief 1st quadrant fixed point division with saturation. - * + * * @param a Dividend. * @param b Divisor. * @return uint16_t Quotient = a/b. @@ -99,7 +99,7 @@ uint16_t div16(const uint16_t a, const uint16_t b) /** * @brief 1st quadrant fixed point multiplication. - * + * * @param a Multiplicand. * @param b Multiplier. * @return uint16_t Product = a*b. @@ -111,7 +111,7 @@ uint16_t mul16(const uint16_t a, const uint16_t b) /** * @brief Bilinear interpolation (soft-valued expansion) for XOR. - * + * * @param a Input A. * @param b Input B. * @return uint16_t Output = A xor B. @@ -133,4 +133,4 @@ void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t { for(uint8_t i=0; i -//vars -; - -//functions uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2); float eucl_norm(const float* in1, const int8_t* in2, const uint8_t n); void int_to_soft(uint16_t* out, const uint16_t in, const uint8_t len); @@ -28,4 +23,3 @@ void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t #ifdef __cplusplus } #endif -#endif \ No newline at end of file diff --git a/SP5WWP/lib/math/rrc.c b/SP5WWP/lib/math/rrc.c new file mode 100644 index 0000000..ba84058 --- /dev/null +++ b/SP5WWP/lib/math/rrc.c @@ -0,0 +1,67 @@ +//-------------------------------------------------------------------- +// M17 C library - math/rrc.c +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 29 December 2023 +//-------------------------------------------------------------------- +#include "rrc.h" + +//sample RRC filter for 48kHz sample rate +//alpha=0.5, span=8, sps=10, gain=sqrt(sps) +const float rrc_taps_10[8*10+1]= +{ + -0.003195702904062073f, -0.002930279157647190f, -0.001940667871554463f, + -0.000356087678023658f, 0.001547011339077758f, 0.003389554791179751f, + 0.004761898604225673f, 0.005310860846138910f, 0.004824746306020221f, + 0.003297923526848786f, 0.000958710871218619f, -0.001749908029791816f, + -0.004238694106631223f, -0.005881783042101693f, -0.006150256456781309f, + -0.004745376707651645f, -0.001704189656473565f, 0.002547854551539951f, + 0.007215575568844704f, 0.011231038205363532f, 0.013421952197060707f, + 0.012730475385624438f, 0.008449554307303753f, 0.000436744366018287f, + -0.010735380379191660f, -0.023726883538258272f, -0.036498030780605324f, + -0.046500883189991064f, -0.050979050575999614f, -0.047340680079891187f, + -0.033554880492651755f, -0.008513823955725943f, 0.027696543159614194f, + 0.073664520037517042f, 0.126689053778116234f, 0.182990955139333916f, + 0.238080025892859704f, 0.287235637987091563f, 0.326040247765297220f, + 0.350895727088112619f, 0.359452932027607974f, 0.350895727088112619f, + 0.326040247765297220f, 0.287235637987091563f, 0.238080025892859704f, + 0.182990955139333916f, 0.126689053778116234f, 0.073664520037517042f, + 0.027696543159614194f, -0.008513823955725943f, -0.033554880492651755f, + -0.047340680079891187f, -0.050979050575999614f, -0.046500883189991064f, + -0.036498030780605324f, -0.023726883538258272f, -0.010735380379191660f, + 0.000436744366018287f, 0.008449554307303753f, 0.012730475385624438f, + 0.013421952197060707f, 0.011231038205363532f, 0.007215575568844704f, + 0.002547854551539951f, -0.001704189656473565f, -0.004745376707651645f, + -0.006150256456781309f, -0.005881783042101693f, -0.004238694106631223f, + -0.001749908029791816f, 0.000958710871218619f, 0.003297923526848786f, + 0.004824746306020221f, 0.005310860846138910f, 0.004761898604225673f, + 0.003389554791179751f, 0.001547011339077758f, -0.000356087678023658f, + -0.001940667871554463f, -0.002930279157647190f, -0.003195702904062073f +}; + +//sample RRC filter for 24kHz sample rate +//alpha=0.5, span=8, sps=5, gain=sqrt(sps) +const float rrc_taps_5[8*5+1]= +{ + -0.004519384154389f, -0.002744505321971f, + 0.002187793653660f, 0.006734308458208f, + 0.006823188093192f, 0.001355815246317f, + -0.005994389201970f, -0.008697733303330f, + -0.002410076268276f, 0.010204314627992f, + 0.018981413448435f, 0.011949415510291f, + -0.015182045838927f, -0.051615756197679f, + -0.072094910038768f, -0.047453533621088f, + 0.039168634270669f, 0.179164496628150f, + 0.336694345124862f, 0.461088271869920f, + 0.508340710642860f, 0.461088271869920f, + 0.336694345124862f, 0.179164496628150f, + 0.039168634270669f, -0.047453533621088f, + -0.072094910038768f, -0.051615756197679f, + -0.015182045838927f, 0.011949415510291f, + 0.018981413448435f, 0.010204314627992f, + -0.002410076268276f, -0.008697733303330f, + -0.005994389201970f, 0.001355815246317f, + 0.006823188093192f, 0.006734308458208f, + 0.002187793653660f, -0.002744505321971f, + -0.004519384154389f +}; diff --git a/SP5WWP/lib/math/rrc.h b/SP5WWP/lib/math/rrc.h new file mode 100644 index 0000000..f2a0781 --- /dev/null +++ b/SP5WWP/lib/math/rrc.h @@ -0,0 +1,23 @@ +//------------------------------- +// M17 C library - math/rrc.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +//sample RRC filter for 48kHz sample rate +//alpha=0.5, span=8, sps=10, gain=sqrt(sps) +extern const float rrc_taps_10[8*10+1]; + +//sample RRC filter for 24kHz sample rate +//alpha=0.5, span=8, sps=5, gain=sqrt(sps) +extern const float rrc_taps_5[8*5+1]; + +#ifdef __cplusplus +} +#endif diff --git a/SP5WWP/lib/m17call.c b/SP5WWP/lib/payload/call.c similarity index 97% rename from SP5WWP/lib/m17call.c rename to SP5WWP/lib/payload/call.c index 9de0352..5c5fd90 100644 --- a/SP5WWP/lib/m17call.c +++ b/SP5WWP/lib/payload/call.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------------- -// M17 C library - m17call.c +// M17 C library - payload/call.c // // This file contains: // - callsign encoder and decoders @@ -9,7 +9,7 @@ //-------------------------------------------------------------------- #include #include -#include "m17call.h" +#include "call.h" //decodes a 6-byte long array to a callsign void decode_callsign_bytes(uint8_t *outp, const uint8_t *inp) diff --git a/SP5WWP/lib/m17call.h b/SP5WWP/lib/payload/call.h similarity index 83% rename from SP5WWP/lib/m17call.h rename to SP5WWP/lib/payload/call.h index 01be883..874a4b9 100644 --- a/SP5WWP/lib/m17call.h +++ b/SP5WWP/lib/payload/call.h @@ -1,21 +1,16 @@ //-------------------------------------------------------------------- -// M17 C library - m17call.h +// M17 C library - payload/call.h // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- -#ifndef M17_CALL_LIB -#define M17_CALL_LIB +#pragma once #ifdef __cplusplus extern "C" { #endif #include -//vars -; - -//functions void decode_callsign_bytes(uint8_t *outp, const uint8_t *inp); void decode_callsign_value(uint8_t *outp, const uint64_t inp); uint8_t encode_callsign(uint64_t* out, const uint8_t* inp); @@ -23,4 +18,3 @@ uint8_t encode_callsign(uint64_t* out, const uint8_t* inp); #ifdef __cplusplus } #endif -#endif \ No newline at end of file diff --git a/SP5WWP/lib/m17crc.c b/SP5WWP/lib/payload/crc.c similarity index 90% rename from SP5WWP/lib/m17crc.c rename to SP5WWP/lib/payload/crc.c index c4fd49b..71aedd7 100644 --- a/SP5WWP/lib/m17crc.c +++ b/SP5WWP/lib/payload/crc.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------------- -// M17 C library - m17crc.c +// M17 C library - payload/crc.c // // This file contains: // - CRC calculating functions (arbitrary length) @@ -8,11 +8,14 @@ // M17 Project, 29 December 2023 //-------------------------------------------------------------------- #include -#include "m17crc.h" +#include "crc.h" + +//M17 CRC polynomial +const uint16_t M17_CRC_POLY = 0x5935; /** * @brief Calculate CRC value. - * + * * @param in Pointer to the input byte array. * @param len Input's length. * @return uint16_t CRC value. @@ -37,7 +40,7 @@ uint16_t CRC_M17(const uint8_t *in, const uint16_t len) /** * @brief Calculate CRC value for the Link Setup Frame. - * + * * @param in Pointer to an LSF struct. * @return uint16_t CRC value. */ diff --git a/SP5WWP/lib/m17crc.h b/SP5WWP/lib/payload/crc.h similarity index 76% rename from SP5WWP/lib/m17crc.h rename to SP5WWP/lib/payload/crc.h index af18ea3..2a94a91 100644 --- a/SP5WWP/lib/m17crc.h +++ b/SP5WWP/lib/payload/crc.h @@ -1,27 +1,23 @@ //-------------------------------------------------------------------- -// M17 C library - m17crc.h +// M17 C library - payload/crc.h // // Wojciech Kaczmarski, SP5WWP // M17 Project, 29 December 2023 //-------------------------------------------------------------------- -#ifndef M17_CRC_LIB -#define M17_CRC_LIB +#pragma once #ifdef __cplusplus extern "C" { #endif #include -#include "m17consts.h" +#include "lsf.h" -//vars -; +//M17 CRC polynomial +extern const uint16_t M17_CRC_POLY; -//functions uint16_t CRC_M17(const uint8_t *in, const uint16_t len); uint16_t LSF_CRC(const struct LSF *in); #ifdef __cplusplus } #endif -#endif - diff --git a/SP5WWP/lib/payload/lsf.h b/SP5WWP/lib/payload/lsf.h new file mode 100644 index 0000000..2d76918 --- /dev/null +++ b/SP5WWP/lib/payload/lsf.h @@ -0,0 +1,28 @@ +//------------------------------- +// M17 C library - payload/lsf.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Structure holding Link Setup Frame data. + * + */ +struct LSF +{ + uint8_t dst[6]; + uint8_t src[6]; + uint8_t type[2]; + uint8_t meta[112/8]; + uint8_t crc[2]; +}; + +#ifdef __cplusplus +} +#endif diff --git a/SP5WWP/lib/phy/interleave.c b/SP5WWP/lib/phy/interleave.c new file mode 100644 index 0000000..363405e --- /dev/null +++ b/SP5WWP/lib/phy/interleave.c @@ -0,0 +1,36 @@ +//------------------------------- +// M17 C library - phy/interleave.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- + +#include "interleave.h" + +//interleaver pattern +const uint16_t intrl_seq[368]= +{ + 0, 137, 90, 227, 180, 317, 270, 39, 360, 129, 82, 219, 172, 309, 262, 31, + 352, 121, 74, 211, 164, 301, 254, 23, 344, 113, 66, 203, 156, 293, 246, 15, + 336, 105, 58, 195, 148, 285, 238, 7, 328, 97, 50, 187, 140, 277, 230, 367, + 320, 89, 42, 179, 132, 269, 222, 359, 312, 81, 34, 171, 124, 261, 214, 351, + 304, 73, 26, 163, 116, 253, 206, 343, 296, 65, 18, 155, 108, 245, 198, 335, + 288, 57, 10, 147, 100, 237, 190, 327, 280, 49, 2, 139, 92, 229, 182, 319, + 272, 41, 362, 131, 84, 221, 174, 311, 264, 33, 354, 123, 76, 213, 166, 303, + 256, 25, 346, 115, 68, 205, 158, 295, 248, 17, 338, 107, 60, 197, 150, 287, + 240, 9, 330, 99, 52, 189, 142, 279, 232, 1, 322, 91, 44, 181, 134, 271, + 224, 361, 314, 83, 36, 173, 126, 263, 216, 353, 306, 75, 28, 165, 118, 255, + 208, 345, 298, 67, 20, 157, 110, 247, 200, 337, 290, 59, 12, 149, 102, 239, + 192, 329, 282, 51, 4, 141, 94, 231, 184, 321, 274, 43, 364, 133, 86, 223, + 176, 313, 266, 35, 356, 125, 78, 215, 168, 305, 258, 27, 348, 117, 70, 207, + 160, 297, 250, 19, 340, 109, 62, 199, 152, 289, 242, 11, 332, 101, 54, 191, + 144, 281, 234, 3, 324, 93, 46, 183, 136, 273, 226, 363, 316, 85, 38, 175, + 128, 265, 218, 355, 308, 77, 30, 167, 120, 257, 210, 347, 300, 69, 22, 159, + 112, 249, 202, 339, 292, 61, 14, 151, 104, 241, 194, 331, 284, 53, 6, 143, + 96, 233, 186, 323, 276, 45, 366, 135, 88, 225, 178, 315, 268, 37, 358, 127, + 80, 217, 170, 307, 260, 29, 350, 119, 72, 209, 162, 299, 252, 21, 342, 111, + 64, 201, 154, 291, 244, 13, 334, 103, 56, 193, 146, 283, 236, 5, 326, 95, + 48, 185, 138, 275, 228, 365, 318, 87, 40, 177, 130, 267, 220, 357, 310, 79, + 32, 169, 122, 259, 212, 349, 302, 71, 24, 161, 114, 251, 204, 341, 294, 63, + 16, 153, 106, 243, 196, 333, 286, 55, 8, 145, 98, 235, 188, 325, 278, 47 +}; diff --git a/SP5WWP/lib/phy/interleave.h b/SP5WWP/lib/phy/interleave.h new file mode 100644 index 0000000..ddeca4e --- /dev/null +++ b/SP5WWP/lib/phy/interleave.h @@ -0,0 +1,19 @@ +//------------------------------- +// M17 C library - phy/interleave.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#include + +//interleaver pattern +extern const uint16_t intrl_seq[368]; + +#ifdef __cplusplus +} +#endif diff --git a/SP5WWP/lib/phy/randomize.c b/SP5WWP/lib/phy/randomize.c new file mode 100644 index 0000000..d1c72bb --- /dev/null +++ b/SP5WWP/lib/phy/randomize.c @@ -0,0 +1,14 @@ +//-------------------------------------------------------------------- +// M17 C library - phy/randomize.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 29 December 2023 +//-------------------------------------------------------------------- +#include "randomize.h" + +//randomizing pattern +const uint8_t rand_seq[46]= +{ + 0xD6, 0xB5, 0xE2, 0x30, 0x82, 0xFF, 0x84, 0x62, 0xBA, 0x4E, 0x96, 0x90, 0xD8, 0x98, 0xDD, 0x5D, 0x0C, 0xC8, 0x52, 0x43, 0x91, 0x1D, 0xF8, + 0x6E, 0x68, 0x2F, 0x35, 0xDA, 0x14, 0xEA, 0xCD, 0x76, 0x19, 0x8D, 0xD5, 0x80, 0xD1, 0x33, 0x87, 0x13, 0x57, 0x18, 0x2D, 0x29, 0x78, 0xC3 +}; diff --git a/SP5WWP/lib/phy/randomize.h b/SP5WWP/lib/phy/randomize.h new file mode 100644 index 0000000..864b6ee --- /dev/null +++ b/SP5WWP/lib/phy/randomize.h @@ -0,0 +1,19 @@ +//------------------------------- +// M17 C library - phy/randomize.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#include + +//randomizing pattern +extern const uint8_t rand_seq[46]; + +#ifdef __cplusplus +} +#endif diff --git a/SP5WWP/lib/phy/sync.c b/SP5WWP/lib/phy/sync.c new file mode 100644 index 0000000..60f021f --- /dev/null +++ b/SP5WWP/lib/phy/sync.c @@ -0,0 +1,14 @@ +//-------------------------------------------------------------------- +// M17 C library - phy/sync.c +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 29 December 2023 +//-------------------------------------------------------------------- +#include "sync.h" + +//syncwords +const uint16_t SYNC_LSF = 0x55F7; +const uint16_t SYNC_STR = 0xFF5D; +const uint16_t SYNC_PKT = 0x75FF; +const uint16_t SYNC_BER = 0xDF55; +const uint16_t EOT_MRKR = 0x555D; diff --git a/SP5WWP/lib/phy/sync.h b/SP5WWP/lib/phy/sync.h new file mode 100644 index 0000000..48a800e --- /dev/null +++ b/SP5WWP/lib/phy/sync.h @@ -0,0 +1,23 @@ +//------------------------------- +// M17 C library - phy/sync.h +// +// Wojciech Kaczmarski, SP5WWP +// M17 Project, 28 December 2023 +//------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#include + +//syncwords +extern const uint16_t SYNC_LSF; +extern const uint16_t SYNC_STR; +extern const uint16_t SYNC_PKT; +extern const uint16_t SYNC_BER; +extern const uint16_t EOT_MRKR; + +#ifdef __cplusplus +} +#endif