/*
 * sys_utils.h
 *
 *  Created on: 11/feb/2014
 *      Author: lpedroni
 */

#ifndef SYS_UTILS_H_
#define SYS_UTILS_H_

// LED ETHERCAT (gestiti da FPGA):

#define		reset_act1_led()	fpga_gpio_led_reset(SERVICE_LED_GREEN_H4)
#define		set_act1_led()		fpga_gpio_led_set(SERVICE_LED_GREEN_H4)
#define		reset_act0_led()	fpga_gpio_led_reset(SERVICE_LED_GREEN_H3)
#define		set_act0_led()		fpga_gpio_led_set(SERVICE_LED_GREEN_H3)
#define		reset_error_led()	fpga_gpio_led_reset(SERVICE_LED_RED_H2)
#define		set_error_led()		fpga_gpio_led_set(SERVICE_LED_RED_H2)
#define		reset_run_led()		fpga_gpio_led_reset(SERVICE_LED_GREEN_H1)
#define		set_run_led()		fpga_gpio_led_set(SERVICE_LED_GREEN_H1)

// led verde e rosso general purpose collegati direttamente alla CPU

#define	LED_H12_RED			1
#define	LED_H13_GREEN		0

void 	led_init				( void );
void 	led_set					( int led_id );
void 	led_reset				( int led_id );
void 	led_toggle				( int led_id );

void 	_CacheDataCleanBuff		( unsigned int startAddr, unsigned int numBytes );
void 	_CacheDataInvalidateBuff( unsigned int startAddr, unsigned int numBytes );

void	dmtimer_init			( void );

#endif /* SYS_UTILS_H_ */

/********************************************************************/
/*                                                                 	*/
/* File name     	: SoftTimer.h                                   */
/* Author        	: 												*/
/*                                                                 	*/
/* Date          	: 13-01-05     			                        */
/* Release			:                                  		        */
/*                 	                                                */
/*                  	                                            */
/*                    	                                            */
/* Description	 	: Software timer routines	                    */
/*                      	                                        */
/*                        	                                        */
/* Note				:												*/
/*                              	                                */
/********************************************************************/
#ifndef __SOFT_TIMER
#define __SOFT_TIMER

typedef enum {
	TIMER_DELETED=0,
	TIMER_RUNNING=1,
	TIMER_EXPIRED=2
} TMR_ST;

typedef struct
{	unsigned long		ref;
	unsigned long		timeout;
	unsigned int		status;
} TMR_FRM;

extern void			set_tick_period		( unsigned int tick );
extern unsigned int	evaluate_timer		( TMR_FRM * );
extern void			start_timer			( TMR_FRM * );
extern void			delete_timer		( TMR_FRM * );
extern void			load_timer			( TMR_FRM *, unsigned int timeout_ms );
extern void			tick_reset			( void );

#endif

/*typedef struct {
	int		year;
	int		month;
	int		week;
	int		day;
	int		hour;
	int		minute;
	int		second;
	int		millisecond;
} TIMESTAMP_TYPE;*/

