/*
 * events_reg.h
 *
 *
 *  Created on: 02-06-2014
 *      Author: KJ
 */

#ifndef EVENTS_REG_H_
#define EVENTS_REG_H_

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

#define MAX_EVENTS_COUNT	256
#define EVENT_ON			0x80
#define EVENT_OFF			0x00

extern struct events_reg_logic *ev_reg_log;

extern volatile u8 events_reg_filter_act;
extern volatile u16 events_reg_filter_period;
extern volatile u8 events_reg_filter_trans_limit;
extern volatile u8 saved_events[16];

extern void zprae_event_add(u8 fun, u8 inf);
extern void zprae_event_add_with_time(u8 fun, u8 inf,struct timeval *cur_time);

struct event_data
{
	u8 fun;
	u8 inf;
	u32 sec;
	u16 msec;
}__attribute__((__packed__));

struct events_db
{
	struct event_data ev[MAX_EVENTS_COUNT];
	u16 pos;
}__attribute__((__packed__));

extern struct events_db ev_db;

struct events_reg_logic
{
	u16 events_count;
	u16 time_cnt;
	u8 start_cnt;
	u16 element_num[];
};

struct events_reg_io
{
}__attribute__((__packed__));

struct events_reg_params
{
}__attribute__((__packed__));

struct events_reg_args
{
	struct events_reg_io io;
	struct events_reg_params params;
//	u16 crc;
}__attribute__((__packed__));

#define EVENT_FILTERED	0x80

extern int events_reg_initlog(void *args, void *logic);
extern void events_reg(void *args, void *logic);

#endif /* EVENTS_REG_H_ */
