/*
 * TaskExecuter.h
 *
 * Created: 22.2.2016 23:05:02
 *  Author: Chenda
 */ 


#ifndef TASKEXECUTER_H_
#define TASKEXECUTER_H_

#include "DeviceAddresses.h"

/************************************************************************/
/* Application structure                                                */
/************************************************************************/
struct stApplicationStructure {
	struct stMinimumStatusReportingStructure *SCPI_StatStr;
	
	struct stAPI_layers {
		struct stAPI_layer *UART1;
		struct stAPI_layer *USB;
		struct stAPI_layer *SPI;
	}API;
	
	struct stAvailableDevices {
		uint8_t PS_list[DEV_ADD_MAX_PS+1];
		uint8_t PS_selected;
		bool Loc_Ctrl_present;
		bool Rem_Ctrl_present;
	}AV_DEVICE;
	
	struct stCommandProccessing {
		uint8_t CMD_No;
		uint8_t CMD_phase;
		uint8_t CMD_src;
		uint8_t CMD_trg;
		uint8_t DATA_buff[255];
		uint8_t DATA_len;
		uint8_t MPC0;		// multi purpose counter 0
		uint8_t MPC1;		// multi purpose counter 1
		
		struct stAPI_layer *SrcAPI;
		struct stAPI_layer *TrgAPI;
	}CMD;
	
	struct stErrorHandling {
		uint8_t ERROR_No;
		uint8_t ERROR_src;
		uint8_t DATA_cmd;
		uint8_t DATA_buff[255];
		uint8_t DATA_len;
		bool InitiateReset;
	}ERROR;
	
	struct stTimerEvents {
		uint8_t Tick100ms;
		uint8_t OldCptSof;
		struct stPingEvent {
			uint8_t Ticks;
			uint8_t TicksToEvent;
			bool Event;	
		}PING;
	}T_EVENTS;	
};


/************************************************************************/
/* Function declaration                                                 */
/************************************************************************/
// Public Functions
void TE_INIT(void);
void TE(void);

// mapped interrupt function USB Start Of Frame - every 1ms
//void sof_action(void);
#endif /* TASKEXECUTER_H_ */