/*
 * eth_demux.h
 *
 *  Created on: 21-05-2024
 *      Author: Krzysztof Jakubczyk
 */

#ifndef ETH_DEMUX_H_
#define ETH_DEMUX_H_

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

extern u16 eth_comm_bits_act[8];
extern u16 eth_comm_bits_restored[8];

struct eth_demux_logic
{
	struct stream_frame *stream_in[8];
	struct binary_io stream_in_act[8];
	struct stream_frame stream_out[8];

	struct binary_io streams_ok;

	struct stream_frame *ostream_ptr[8];
	struct binary_io przeglad[8];
	float *endpoints;

	u32 snum_cur[8];
	u32 snum_prev[8];
	u32 sfault_delay_cnt[8];
	u32 jednostki;
};

struct eth_demux_io
{
	u32 stream1_ptr_in;
	u32 stream1_act_in;

	u32 stream2_ptr_in;
	u32 stream2_act_in;

	u32 stream3_ptr_in;
	u32 stream3_act_in;

	u32 stream4_ptr_in;
	u32 stream4_act_in;

	u32 stream5_ptr_in;
	u32 stream5_act_in;

	u32 stream6_ptr_in;
	u32 stream6_act_in;

	u32 stream7_ptr_in;
	u32 stream7_act_in;

	u32 stream8_ptr_in;
	u32 stream8_act_in;

	u32 stream1_ptr_out;
	u32 stream2_ptr_out;
	u32 stream3_ptr_out;
	u32 stream4_ptr_out;
	u32 stream5_ptr_out;
	u32 stream6_ptr_out;
	u32 stream7_ptr_out;
	u32 stream8_ptr_out;
	u32 streams_ok_out;

	u32 przeglad1_out;
	u32 przeglad2_out;
	u32 przeglad3_out;
	u32 przeglad4_out;
	u32 przeglad5_out;
	u32 przeglad6_out;
	u32 przeglad7_out;
	u32 przeglad8_out;

	u32 endpoints_float_out;
}__attribute__((__packed__));


struct eth_demux_params
{
	u32 liczba_jednostek;
}__attribute__((__packed__));

struct eth_demux_args
{
	struct eth_demux_io io;
	struct eth_demux_params params;
//	u16 crc;
}__attribute__((__packed__));

extern void eth_demux(void *args, void *logic);
extern int eth_demux_initlog(void *arguments, void *logic);

#endif
