#ifndef V_ROTOR_22220_H
#define V_ROTOR_22220_H

#define SIZE_BUF_W    100 //2000

/////// 22220.5
#define SENSORS_NUMBER  10
#define SENSORS_NUMBER_ONLY_IN  6
//#define IMPULSES_PER_TURN (1LL << 13) //Old sensor
#define IMPULSES_PER_TURN 4096  //Lira sensor
//#define ANGLE_RESOLUTION (1LL << 18)    //2^18

typedef struct
{
    int  direct_rotor;
    int  direct_rotor_in1;
    int  direct_rotor_in2;
    int  direct_rotor_angle;
    union {
        unsigned int sens_err1:1;
        unsigned int sens_err2:1;
        unsigned int reserved:14;
    } error;

    _iq iqFsensors[SENSORS_NUMBER];


    _iq iqFdirty;
    _iq iqF;
    _iq iqFout;
    _iq iqFlong;

    _iq iqFrotFromOptica;

    unsigned int error_update_count;
}   ROTOR_VALUE_22220;

#define ROTOR_VALUE_22220_DEFAULTS {0,0,0,0,0, {0,0,0,0,0,0,0,0},0,0,0,0,0,0}


_iq counter_To_iqF2(long count, unsigned int freq_mode);
void sort_F_array(_iq *array, unsigned int size);
_iq impulses_To_iqF(unsigned int time, unsigned int impulses); //time mks. impulses count
void Rotor_measure_22220(void);
void rotorInit_22220(void);
void select_values_wrotor_22220(void);

extern ROTOR_VALUE_22220 rotor_22220;

extern _iq koef_Wout_filter, koef_Wout_filter_long;


#endif

