thing
This commit is contained in:
@@ -5,25 +5,36 @@
|
||||
#ifndef AUDIOCODER_DECODER_H
|
||||
#define AUDIOCODER_DECODER_H
|
||||
|
||||
#define MAX_BITS 16
|
||||
#define PREAMBLE_SYMBOLS 128
|
||||
#define DECODER_SAMPLE_HISTORY 262144
|
||||
#define MAX_FSK_TONES 32
|
||||
#include <SDL_audio.h>
|
||||
#include <SDL_render.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "goertzel.h"
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
RX_SEARCH,
|
||||
RX_ALIGN,
|
||||
RX_SYNC,
|
||||
RX_LOCKED
|
||||
RX_MAGIC,
|
||||
RX_DATA
|
||||
} RxState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PKT_WAIT_PREAMBLE,
|
||||
PKT_WAIT_MAGIC,
|
||||
PKT_WAIT_LENGTH,
|
||||
PKT_WAIT_DATA,
|
||||
PKT_WAIT_CRC1,
|
||||
PKT_WAIT_CRC2
|
||||
} PacketState;
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t bitCount;
|
||||
uint8_t bitsPerSymbol;
|
||||
uint8_t toneCount;
|
||||
|
||||
uint16_t startFreq;
|
||||
uint16_t endFreq;
|
||||
@@ -32,9 +43,16 @@ typedef struct {
|
||||
uint16_t clock0;
|
||||
uint16_t clock1;
|
||||
|
||||
uint8_t magicBuffer[16];
|
||||
uint32_t magicIndex;
|
||||
uint32_t preambleCount;
|
||||
|
||||
uint8_t lostClockCount;
|
||||
uint8_t goodClockCount;
|
||||
|
||||
|
||||
uint32_t symbolSamples;
|
||||
|
||||
uint32_t sampleRate;
|
||||
|
||||
uint32_t sampleCount;
|
||||
|
||||
@@ -43,7 +61,9 @@ typedef struct {
|
||||
uint32_t sampleHistoryCount;
|
||||
uint64_t totalSamples;
|
||||
|
||||
Goertzel tones[MAX_BITS * 2 + 2];
|
||||
Goertzel tones[MAX_FSK_TONES + 2];
|
||||
|
||||
float energies[MAX_FSK_TONES + 2];
|
||||
|
||||
uint8_t currentByte;
|
||||
uint8_t bitIndex;
|
||||
@@ -55,7 +75,6 @@ typedef struct {
|
||||
bool lastClock;
|
||||
|
||||
|
||||
float energies[MAX_BITS * 2 + 2];
|
||||
float maxEnergy;
|
||||
float clockEnergy0;
|
||||
float clockEnergy1;
|
||||
@@ -65,6 +84,8 @@ typedef struct {
|
||||
int bestSyncPhase;
|
||||
|
||||
RxState rxState;
|
||||
PacketState packetState;
|
||||
|
||||
|
||||
bool expectedClock;
|
||||
float lastClockEnergy;
|
||||
@@ -116,5 +137,6 @@ extern volatile uint32_t internalBusWrite;
|
||||
extern volatile uint32_t internalBusRead;
|
||||
|
||||
void initAudioDecoder(SDL_Renderer *renderer);
|
||||
void decoder_reset_rx(Decoder *dec);
|
||||
|
||||
#endif //AUDIOCODER_DECODER_H
|
||||
|
||||
Reference in New Issue
Block a user