#ifndef __CONTROL_H_
#define __CONTROL_H_

#include "modbus_data.h"
#include "periph_general.h"
#include "math.h"

#define M_PI           	3.14159265358979323846  /* pi */

// defines for timers
#define HZ_TIMER_CTRL	400
#define HZ_TIMER_PWM	1000


// defines for PWMs
//#define INTERNAL_THREE_PHASE_PWM_ENABLE		// pwm with timer in slave mode: time shift less than 1 period of PWM
//#define SINE_THREE_PHASE_PWM_ENABLE				// pwm sine with time shift

#define SIN_TABLE_SIZE_MAX HZ_TIMER_PWM


// defines for filling arrays
#define CALC_SAMPLES_PER_PERIOD(_hztim_, _hztarget_)						(_hztim_/_hztarget_)	
//(TIM_CTRL.sTimFreq/PWM.PWM_Value)

// OR define samples
//#define SAMPLES_PER_PERIOD	10
//#define	HZ_TIMER_CTRL						(HZ_SINUS*SAMPLES_PER_PERIOD)

#define CALC_NUMB_OF_PERIODS(_arr_size_, _hztim_, _hztarget_)		(_arr_size_/CALC_SAMPLES_PER_PERIOD(_hztim_, _hztarget_))
//#define NUMB_OF_PERIODS				(5)

#define CALC_ARR_SIZE(_numb_of_periods_, _samples_per_period_)	((_numb_of_periods_)*(_samples_per_period_))




#endif // __CONTROL_H_