Added extern C around function prototypes for C++ compatibility

pull/34/head
Karlis Goba 2022-04-23 17:40:30 +03:00
rodzic cd0dc2eca3
commit 7d534db0db
9 zmienionych plików z 240 dodań i 159 usunięć

Wyświetl plik

@ -1,10 +1,19 @@
#ifndef _INCLUDE_WAVE_H_
#define _INCLUDE_WAVE_H_
#ifdef __cplusplus
extern "C"
{
#endif
// Save signal in floating point format (-1 .. +1) as a WAVE file using 16-bit signed integers.
void save_wav(const float* signal, int num_samples, int sample_rate, const char* path);
// Load signal in floating point format (-1 .. +1) as a WAVE file using 16-bit signed integers.
int load_wav(float* signal, int* num_samples, int* sample_rate, const char* path);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_WAVE_H_

Wyświetl plik

@ -3,11 +3,10 @@
#include <stdint.h>
typedef enum
#ifdef __cplusplus
extern "C"
{
PROTO_FT4,
PROTO_FT8
} ftx_protocol_t;
#endif
#define FT8_SYMBOL_PERIOD (0.160f) ///< FT8 symbol duration, defines tone deviation in Hz and symbol rate
#define FT8_SLOT_TIME (15.0f) ///< FT8 slot period
@ -50,6 +49,12 @@ typedef enum
#define FT8_CRC_POLYNOMIAL ((uint16_t)0x2757u) ///< CRC-14 polynomial without the leading (MSB) 1
#define FT8_CRC_WIDTH (14)
typedef enum
{
PROTO_FT4,
PROTO_FT8
} ftx_protocol_t;
/// Costas 7x7 tone pattern for synchronization
extern const uint8_t kFT8_Costas_pattern[7];
extern const uint8_t kFT4_Costas_pattern[4][4];
@ -78,4 +83,8 @@ extern const uint8_t kFTX_LDPC_Mn[FTX_LDPC_N][3];
/// Number of rows (columns in C/C++) in the array Nm.
extern const uint8_t kFTX_LDPC_Num_rows[FTX_LDPC_M];
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_CONSTANTS_H_

Wyświetl plik

@ -4,6 +4,11 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
// Compute 14-bit CRC for a sequence of given number of bits using FT8/FT4 CRC polynomial
// [IN] message - byte sequence (MSB first)
// [IN] num_bits - number of bits in the sequence
@ -19,4 +24,8 @@ uint16_t ftx_extract_crc(const uint8_t a91[]);
/// @param[out] a91 91 bits of payload data + CRC
void ftx_add_crc(const uint8_t payload[], uint8_t a91[]);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_CRC_H_

Wyświetl plik

@ -6,6 +6,11 @@
#include "constants.h"
#ifdef __cplusplus
extern "C"
{
#endif
/// Input structure to ft8_find_sync() function. This structure describes stored waterfall data over the whole message slot.
/// Fields time_osr and freq_osr specify additional oversampling rate for time and frequency resolution.
/// If time_osr=1, FFT magnitude data is collected once for every symbol transmitted, i.e. every 1/6.25 = 0.16 seconds.
@ -71,4 +76,8 @@ int ft8_find_sync(const waterfall_t* power, int num_candidates, candidate_t heap
/// @return True if the decoding was successful, false otherwise (check status for details)
bool ft8_decode(const waterfall_t* power, const candidate_t* cand, message_t* message, int max_iterations, decode_status_t* status);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_DECODE_H_

Wyświetl plik

@ -3,6 +3,11 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
// typedef struct
// {
// uint8_t tones[FT8_NN];
@ -29,4 +34,8 @@ void ft8_encode(const uint8_t* payload, uint8_t* tones);
/// @param[out] tones - array of FT4_NN (105) bytes to store the generated tones (encoded as 0..3)
void ft4_encode(const uint8_t* payload, uint8_t* tones);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_ENCODE_H_

Wyświetl plik

@ -3,6 +3,11 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
// codeword is 174 log-likelihoods.
// plain is a return value, 174 ints, to be 0 or 1.
// iters is how hard to try.
@ -11,4 +16,8 @@ void ldpc_decode(float codeword[], int max_iters, uint8_t plain[], int* ok);
void bp_decode(float codeword[], int max_iters, uint8_t plain[], int* ok);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_LDPC_H_

Wyświetl plik

@ -3,9 +3,18 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
// Pack FT8 text message into 72 bits
// [IN] msg - FT8 message (e.g. "CQ TE5T KN01")
// [OUT] c77 - 10 byte array to store the 77 bit payload (MSB first)
int pack77(const char* msg, uint8_t* c77);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_PACK_H_

Wyświetl plik

@ -4,6 +4,11 @@
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
// Utility functions for characters and strings
const char* trim_front(const char* str);
@ -34,4 +39,8 @@ void int_to_dd(char* str, int value, int width, bool full_sign);
char charn(int c, int table_idx);
int nchar(char c, int table_idx);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_TEXT_H_

Wyświetl plik

@ -3,6 +3,11 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
// field1 - at least 14 bytes
// field2 - at least 14 bytes
// field3 - at least 7 bytes
@ -11,4 +16,8 @@ int unpack77_fields(const uint8_t* a77, char* field1, char* field2, char* field3
// message should have at least 35 bytes allocated (34 characters + zero terminator)
int unpack77(const uint8_t* a77, char* message);
#ifdef __cplusplus
}
#endif
#endif // _INCLUDE_UNPACK_H_