/*
 * detect_phase_break2.h
 *
 *  Created on: 10 äåê. 2020 ã.
 *      Author: star
 */

#ifndef SRC_MAIN_DETECT_PHASE_BREAK2_H_
#define SRC_MAIN_DETECT_PHASE_BREAK2_H_

#include "IQmathLib.h"


typedef struct {
    _iq iqCh[3];
    _iq sum_brocken_out[4]; // 4 ýëåìåíò - ýòî ìàêñ. èç ïåðâûõ òðåõ
    _iq freq_signal;

    int brocken_i_out;
    int return_brocken_code;
	_iq plus_a;


    struct {
        unsigned int freq_pwm;
        unsigned int norma_freq;

        _iq minimal_level;
		_iq calc_const;
		_iq iq_freq;
    } config;

    int (*calc)();
    void (*init)();
	void (*clear_error)();

} BREAK2_PHASE;

#define BREAK2_PHASE_DEFAULTS {{0,0,0},\
                               {0,0,0,0},\
                               0,0,0,0,\
                               0,0,0,0,0, \
                               calc_break2_phase, init_break2_phase, clear_break2_phase }

void check_brocken_phase(BREAK2_PHASE *v);
int calc_break2_phase(BREAK2_PHASE *v);
void init_break2_phase(BREAK2_PHASE *v);
void clear_break2_phase(BREAK2_PHASE *v);

#endif /* SRC_MAIN_DETECT_PHASE_BREAK2_H_ */