/*
 * batch_synch_ext.h
 *
 */

#ifndef BATCH_SYNCH_EXT_H_
#define BATCH_SYNCH_EXT_H_

#include <stdint.h>

struct batch_synch_ext_pkt_t
{
    uint32_t marker;
    uint32_t source;
    uint32_t intr_id;
    uint32_t counter;

    uint64_t time_us;
    uint32_t time_64us;

    uint32_t spare[2];

    uint32_t time_history[4];

    uint32_t spare1[8];

    uint32_t counter_check;
    uint32_t end_marker;
};


struct batch_synch_ext_recorded_t
{
	unsigned int batch_intr;
	unsigned int batch_raw_time;
	//To use only 32bits, all time data shall have LSB=64us
	unsigned int batch_tag;
	unsigned int synch_count;
	unsigned int synch_tag;
    unsigned int align_count;
    unsigned int align_tag;
    int align_delay;
    int align_shift;

	unsigned int spare[1];

	unsigned int avbdata[18];
};

extern volatile batch_synch_ext_recorded_t batch_synch_ext_recorded;

#define BATCH_SYNCH_UDP_MASTER_PORT 51110
#define BATCH_SYNCH_UDP_SLAVE_PORT (BATCH_SYNCH_UDP_MASTER_PORT+1)
#define BATCH_SYNCH_UPD_SLAVE_IP    (0x6602A8C0) //WARNING: hard-coded, equal to 192.168.2.102, that is the EIF. Set to zero to broadcast to other DSP also

extern void EifBatchTimetagSynchRecorder();

#endif /* BATCH_SYNCH_EXT_H_ */
