// --------------------------------------------------------------
#ifndef _RADIO_FRAMEDEFS_HPP_
#define	_RADIO_FRAMEDEFS_HPP_

#include <radio/radio_types.h>
#include <radio/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	256
//#define	FRAME_TYPE_IDLE				0x01
//#define	FRAME_TYPE_DATA				0x02

// --------------------------------------------------------------
// Types
// --------------------------------------------------------------
enum frame_type
{
	FRAME_TYPE_UNKNOWN = 0,
	FRAME_TYPE_IDLE,
	FRAME_TYPE_DATA
};

#pragma pack(push)
#pragma pack(1)
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;
#pragma pack(pop)
typedef struct _frame_statistics_t
{
	uint32_t numTotalFrame;
	uint32_t numInvalidFrame;
	uint32_t numIdleFrame;
	uint32_t numDataFrame;
	uint32_t numDataBytes;

} frame_statistics_t;

#define SIZEOF_SYMBOL_BITS			(8*sizeof(symbol_t))
#define SIZEOF_DATA_BITS			(8*sizeof(data_t))


// --------------------------------------------------------------
#endif // _RADIO_FRAMEDEFS_HPP_
