/*
 * mkstream.h
 *
 *  Created on: 16-04-2019
 *      Author: Krzysztof Jakubczyk
 */

#ifndef MKSTREAM_H_
#define MKSTREAM_H_

#include "tdefs.h"
#include "helper.h"

#define STATUS_FRAME_READ	0x80
#define STREAM_NO_SYNC		0x8000

struct stream_frame
{
	u8 hdr[2];
	u16 sample_stamp;
	float A[3];
	float A_prev[3];
	u16 bits;
	u8 addr;
	u8 cksum;
};//__attribute__((__packed__));

struct mkstream_logic
{
	float *A[3];
	float *A_prev[3];
	struct analog_in_params *A_params;
	struct stream_frame stream;
	struct binary_io gpbit[8];
	struct binary_io valid_sync;
	u32 *bits;
	float mul[3];
};

struct mkstream_io
{
	u32 A1L1_float_in;
	u32 A1L2_float_in;
	u32 A1L3_float_in;
	u32 A1_params_ptr_in;
	u32 bits_float_in;
	u32	gpbit_in[8];
	u32 valid_sync_in;
	u32 A1L1_prev_float_in;
	u32 A1L2_prev_float_in;
	u32 A1L3_prev_float_in;
	u32 stream_ptr_out;
}__attribute__((__packed__));


struct mkstream_params
{
	u32 addr;
}__attribute__((__packed__));

struct mkstream_args
{
	struct mkstream_io io;
	struct mkstream_params params;
//	u16 crc;
}__attribute__((__packed__));

extern void mkstream(void *args, void *logic);
extern int mkstream_initlog(void *arguments, void *logic);

#endif
