use the single include file

pull/21/head
A. Maitland Bottoms 2024-01-06 22:59:45 -05:00
rodzic 6d2e3038d5
commit c4287118a9
34 zmienionych plików z 21 dodań i 398 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include "symbols.h"
#include <m17/m17.h>
// syncword patterns (RX)
// TODO: Compute those at runtime from the consts below

Wyświetl plik

@ -1,25 +0,0 @@
//-------------------------------
// M17 C library - decode/symbols.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 28 December 2023
//-------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
// 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

Wyświetl plik

@ -10,8 +10,7 @@
#include <stdio.h>
#include <string.h>
#include <math/math.h>
#include "viterbi.h"
#include <m17/m17.h>
static uint32_t prevMetrics[NUM_STATES];
static uint32_t currMetrics[NUM_STATES];

Wyświetl plik

@ -1,25 +0,0 @@
//--------------------------------------------------------------------
// M17 C library - decode/viterbi.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define K 5 //constraint length
#define NUM_STATES (1 << (K - 1)) //number of states
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);
uint32_t viterbi_chainback(uint8_t* out, size_t pos, const uint16_t len);
void viterbi_reset(void);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -8,7 +8,7 @@
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include <string.h>
#include "convol.h"
#include <m17/m17.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,

Wyświetl plik

@ -1,25 +0,0 @@
//--------------------------------------------------------------------
// M17 C library - encode/convol.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <payload/lsf.h>
extern const uint8_t puncture_pattern_1[61];
extern const uint8_t puncture_pattern_2[12];
extern const uint8_t puncture_pattern_3[8];
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);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -4,7 +4,7 @@
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 5 January 2024
//--------------------------------------------------------------------
#include "symbols.h"
#include <m17/m17.h>
//dibits-symbols map (TX)
const int8_t symbol_map[4]={+1, +3, -1, -3};

Wyświetl plik

@ -1,22 +0,0 @@
//-------------------------------
// M17 C library - encode/symbols.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 5 January 2024
//-------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
//dibits-symbols map (TX)
extern const int8_t symbol_map[4];
//End of Transmission symbol pattern
extern const float eot_symbols[8];
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -4,8 +4,7 @@
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 5 January 2024
//--------------------------------------------------------------------
#include <encode/symbols.h>
#include "lib.h"
#include <m17/m17.h>
/**
* @brief Generate symbol stream for a preamble.

Wyświetl plik

@ -1,32 +0,0 @@
//-------------------------------
// M17 C library - lib.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 5 January 2024
//-------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#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(float out[SYM_PER_FRA], uint32_t *cnt, const uint8_t type);
void send_syncword(float out[SYM_PER_SWD], uint32_t *cnt, const uint16_t syncword);
void send_data(float out[SYM_PER_PLD], uint32_t *cnt, const uint8_t* in);
void send_eot(float out[SYM_PER_FRA], uint32_t *cnt);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -11,8 +11,7 @@
//--------------------------------------------------------------------
#include <string.h>
#include <math/math.h>
#include "golay.h"
#include <m17/m17.h>
/**
* @brief Precomputed encoding matrix for Golay(24, 12).

Wyświetl plik

@ -1,23 +0,0 @@
//--------------------------------------------------------------------
// M17 C library - math/golay.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
extern const uint16_t encode_matrix[12];
extern const uint16_t decode_matrix[12];
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);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -11,7 +11,7 @@
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include <math.h>
#include "math.h"
#include <m17/m17.h>
/**
* @brief Utility function returning the absolute value of a difference between

Wyświetl plik

@ -1,25 +0,0 @@
//--------------------------------------------------------------------
// M17 C library - math/math.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
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);
uint16_t soft_to_int(const uint16_t* in, const uint8_t len);
uint16_t div16(const uint16_t a, const uint16_t b);
uint16_t mul16(const uint16_t a, const uint16_t b);
uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b);
void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t len);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -4,7 +4,7 @@
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include "rrc.h"
#include <m17/m17.h>
//sample RRC filter for 48kHz sample rate
//alpha=0.5, span=8, sps=10, gain=sqrt(sps)

Wyświetl plik

@ -1,23 +0,0 @@
//-------------------------------
// 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

Wyświetl plik

@ -9,7 +9,7 @@
//--------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include "call.h"
#include <m17/m17.h>
/**
* @brief Decode a 6-byte long array (little-endian) into callsign string.

Wyświetl plik

@ -1,23 +0,0 @@
//--------------------------------------------------------------------
// M17 C library - payload/call.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define CHAR_MAP " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/."
void decode_callsign_bytes(uint8_t *outp, const uint8_t inp[6]);
void decode_callsign_value(uint8_t *outp, const uint64_t inp);
int8_t encode_callsign_bytes(uint8_t out[6], const uint8_t *inp);
int8_t encode_callsign_value(uint64_t *out, const uint8_t *inp);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -8,7 +8,7 @@
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include <string.h>
#include "crc.h"
#include <m17/m17.h>
//M17 CRC polynomial
const uint16_t M17_CRC_POLY = 0x5935;

Wyświetl plik

@ -1,23 +0,0 @@
//--------------------------------------------------------------------
// M17 C library - payload/crc.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "lsf.h"
//M17 CRC polynomial
extern const uint16_t M17_CRC_POLY;
uint16_t CRC_M17(const uint8_t *in, const uint16_t len);
uint16_t LSF_CRC(const struct LSF *in);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -1,28 +0,0 @@
//-------------------------------
// 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

Wyświetl plik

@ -5,7 +5,7 @@
// M17 Project, 28 December 2023
//-------------------------------
#include "interleave.h"
#include <m17/m17.h>
//interleaver pattern
const uint16_t intrl_seq[368]=

Wyświetl plik

@ -1,19 +0,0 @@
//-------------------------------
// M17 C library - phy/interleave.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 28 December 2023
//-------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
//interleaver pattern
extern const uint16_t intrl_seq[368];
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -4,7 +4,7 @@
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include "randomize.h"
#include <m17/m17.h>
//randomizing pattern
const uint8_t rand_seq[46]=

Wyświetl plik

@ -1,19 +0,0 @@
//-------------------------------
// M17 C library - phy/randomize.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 28 December 2023
//-------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
//randomizing pattern
extern const uint8_t rand_seq[46];
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -4,7 +4,7 @@
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 29 December 2023
//--------------------------------------------------------------------
#include "sync.h"
#include <m17/m17.h>
//syncwords
const uint16_t SYNC_LSF = 0x55F7;

Wyświetl plik

@ -1,23 +0,0 @@
//-------------------------------
// M17 C library - phy/sync.h
//
// Wojciech Kaczmarski, SP5WWP
// M17 Project, 28 December 2023
//-------------------------------
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
//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

Wyświetl plik

@ -1,5 +1,5 @@
m17-coder-sym: m17-coder-sym.c
gcc -I ../lib -L ../lib -O2 -Wall m17-coder-sym.c -o m17-coder-sym -lm -lm17
gcc -I ../include -L ../lib -O2 -Wall m17-coder-sym.c -o m17-coder-sym -lm -lm17
clean:
rm -f m17-coder-sym

Wyświetl plik

@ -4,14 +4,7 @@
#include <string.h>
//libm17
#include <lib.h>
#include <encode/convol.h>
#include <math/golay.h>
#include <payload/crc.h>
#include <payload/lsf.h>
#include <phy/interleave.h>
#include <phy/randomize.h>
#include <phy/sync.h>
#include <m17/m17.h>
//#define FN60_DEBUG

Wyświetl plik

@ -1,5 +1,5 @@
m17-decoder-sym: m17-decoder-sym.c
gcc -I ../lib -L ../lib -Wall -O2 m17-decoder-sym.c -o m17-decoder-sym -lm -lm17
gcc -I ../include -L ../lib -Wall -O2 m17-decoder-sym.c -o m17-decoder-sym -lm -lm17
clean:
rm -f m17-decoder-sym

Wyświetl plik

@ -4,18 +4,7 @@
#include <string.h>
//libm17
#include <lib.h>
#include <decode/symbols.h>
#include <decode/viterbi.h>
#include <encode/convol.h>
#include <encode/symbols.h>
#include <math/golay.h>
#include <math/math.h>
#include <payload/call.h>
#include <payload/crc.h>
#include <phy/interleave.h>
#include <phy/sync.h>
#include <phy/randomize.h>
#include <m17/m17.h>
#define DECODE_CALLSIGNS
#define SHOW_VITERBI_ERRS

Wyświetl plik

@ -1,10 +1,10 @@
all: m17-packet-encode m17-packet-decode
m17-packet-encode: m17-packet-encode.c
gcc -I ../lib -L ../lib -O2 -Wall m17-packet-encode.c -o m17-packet-encode -lm -lm17
gcc -I ../include -L ../lib -O2 -Wall m17-packet-encode.c -o m17-packet-encode -lm -lm17
m17-packet-decode: m17-packet-decode.c
gcc -I ../lib -L ../lib -O2 -Wall m17-packet-decode.c -o m17-packet-decode -lm -lm17
gcc -I ../include -L ../lib -O2 -Wall m17-packet-decode.c -o m17-packet-decode -lm -lm17
install: all
sudo install m17-packet-encode /usr/local/bin

Wyświetl plik

@ -4,18 +4,7 @@
#include <string.h>
//libm17
#include <lib.h>
#include <decode/symbols.h>
#include <decode/viterbi.h>
#include <encode/convol.h>
#include <encode/symbols.h>
#include <math/golay.h>
#include <math/math.h>
#include <payload/call.h>
#include <payload/crc.h>
#include <phy/interleave.h>
#include <phy/sync.h>
#include <phy/randomize.h>
#include <m17/m17.h>
float sample; //last raw sample from the stdin
float last[8]; //look-back buffer for finding syncwords

Wyświetl plik

@ -5,17 +5,7 @@
#include <math.h>
//libm17
#include <lib.h>
#include <encode/convol.h>
#include <encode/symbols.h>
#include <math/golay.h>
#include <math/rrc.h>
#include <payload/call.h>
#include <payload/crc.h>
#include <payload/lsf.h>
#include <phy/interleave.h>
#include <phy/randomize.h>
#include <phy/sync.h>
#include <m17/m17.h>
#define FLT_LEN (BSB_SPS*FLT_SPAN+1) //for 48kHz sample rate this is 81