git-svn-id: http://moon:8086/svn/software/trunk/libsrc/radio@1 b431acfa-c32f-4a4a-93f1-934dc6c82436
62 lines
2.1 KiB
C
Executable File
62 lines
2.1 KiB
C
Executable File
// --------------------------------------------------------------
|
|
#ifndef FRAME_H
|
|
#define FRAME_H
|
|
|
|
#include "radio_types.h"
|
|
#include "cpx.h"
|
|
|
|
// --------------------------------------------------------------
|
|
// Constants
|
|
// --------------------------------------------------------------
|
|
#define FRAME_CRC16_IV 0x0000
|
|
#define FRAME_CRC16_POLY 0x1021
|
|
#define FRAME_PREAMBLE_IV 0x55
|
|
#define FRAME_SCRAMBLER_SEED 0x12345678
|
|
#define FRAME_SCRAMBLER_POLY 0x80C18601
|
|
#define FRAME_NUM_BYTES_PER_FRAME 32
|
|
#define FRAME_TYPE_IDLE 0x01
|
|
#define FRAME_TYPE_DATA 0x02
|
|
|
|
// --------------------------------------------------------------
|
|
// Types
|
|
// --------------------------------------------------------------
|
|
typedef struct _frame_hdr_t
|
|
{
|
|
uint8_t preamble[2];
|
|
uint32_t prn_state;
|
|
uint16_t crc16;
|
|
uint16_t type;
|
|
uint16_t length;
|
|
|
|
} frame_hdr_t;
|
|
|
|
typedef struct _frame_t
|
|
{
|
|
frame_hdr_t hdr;
|
|
uint8_t data[FRAME_NUM_BYTES_PER_FRAME];
|
|
|
|
} frame_t;
|
|
|
|
// --------------------------------------------------------------
|
|
// Functions
|
|
// --------------------------------------------------------------
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
uint32_t Scramble(uint8_t *pSrcDst, uint32_t state, uint32_t poly, uint32_t len);
|
|
uint32_t FrameCalcNumStreamBytes(uint32_t len_raw);
|
|
uint32_t FrameFormat(uint8_t *pRaw, uint8_t *pFormatted, uint32_t len_raw, uint32_t *pPrn_state, uint16_t frame_type);
|
|
uint32_t FrameDeformat(uint8_t *pFormatted, uint8_t *pRaw, uint32_t len_formatted, uint16_t frame_type);
|
|
uint32_t FrameSerialize(uint8_t *pSrc, uint8_t *pDst, uint32_t nBitsPerSym, uint32_t srclen);
|
|
uint32_t FrameDeSerialize(uint8_t *pSrc, uint8_t *pDst, uint32_t nBitsPerSym, uint32_t srclen, uint16_t frame_type);
|
|
uint32_t FrameSymbolsMap(uint8_t *pBits, cpx_t *pSym, uint32_t nBitsPerSym, uint32_t num_syms, uint32_t type);
|
|
uint32_t FrameSymbolsDemap(cpx_t *pSym, uint8_t *pBits, uint32_t nBitsPerSym, uint32_t num_syms, uint32_t type);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif // __cplusplus
|
|
|
|
// --------------------------------------------------------------
|
|
#endif // FRAME_H
|