Razvalyaev
7e0063eee0
Все основные файлы подтянуты без изменений Изменены (только папка main_matlab): - заглушки для ненужных функций (main_matlab.c) - iq библиотека (IQmathLib_matlab.c) - библиотеки DSP281x
114 lines
3.1 KiB
C
114 lines
3.1 KiB
C
|
|
|
|
#define LEVEL_FIND_SYNC_ZERO 10 //74 //24
|
|
#define MAX_COUNT_ERROR_SYNC 100
|
|
#define MAX_COUNT_TIMEOUT_SYNC 100
|
|
#define MAX_COUNT_PAUSE_READY 100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
//Sync vals
|
|
int pwm_freq_plus_minus_zero;
|
|
int disable_sync;
|
|
int sync_ready;
|
|
unsigned int level_find_sync_zero;
|
|
|
|
int delta_error_sync;
|
|
int delta_capnum;
|
|
int count_error_sync;
|
|
unsigned int capnum0;
|
|
unsigned int capnum1;
|
|
|
|
int PWMcounterVal;
|
|
int local_flag_sync_1_2;
|
|
int global_flag_sync_1_2;
|
|
int timeout_sync_signal;
|
|
|
|
unsigned int count_timeout_sync;
|
|
unsigned int count_pause_ready;
|
|
int enable_do_sync;
|
|
int latch_interrupt;
|
|
int enabled_interrupt;
|
|
unsigned int count_interrupts;
|
|
unsigned int what_main_pch;
|
|
|
|
|
|
|
|
// int pzad_or_wzad; //given turns or power, depends on controlMode;
|
|
// int angle_pwm; //current rotor turns
|
|
// int iq_zad; // Iq_zadan
|
|
// union {
|
|
// struct {
|
|
// unsigned int wdog_tick :1; //ïîñûëàåì 0_1_0 è ò.ä.
|
|
// unsigned int statusQTV :1; //1-QTV On, QTV - off
|
|
// unsigned int master :1; // 1 -Master, 0 - not Master
|
|
// unsigned int slave :1; // 1 -Slave, 0 - not Slave
|
|
//
|
|
// unsigned int sync_1_2 :1; // 1 - yes, 0 - no ñèíõðîñèãíàë ïðèíèìàåòñÿ
|
|
// unsigned int alarm :1; // 1 - yes, 0 - no àâàðèÿ
|
|
// unsigned int ready_cmd :2; // 00 - not ready,01-ready1,10-ready1to2, 11 -ready2
|
|
//
|
|
// unsigned int controlMode :1; // 0 - regul turns; 1 - power ðåæèì ðàáîòû
|
|
// unsigned int ready_to_go :1; // 1 - yes, 0 - no ñõåìà ñîáðàíà, ãîòîâû äàâàòü øèì
|
|
// unsigned int start_pwm :1; // 1 - yes, 0 - no èäåò êîìàíäà íà çàïóñê øèìà
|
|
// unsigned int stop_pwm :1; // 1 - yes, 0 - no èäåò êîìàíäà íà ñòîï øèìà
|
|
//
|
|
// unsigned int pwm_status :1; // 1 -On, 0 - Off òåêóùåå çíà÷åíèå øèìà
|
|
// unsigned int err_optbus :1; // 1 - yes, 0 - no øèíà optbus íåèñïðàâíà
|
|
// unsigned int maybe_master :1; // 1 - yes, 0 - no çàïðîñ íà çàõâàò ðåæèìà Master
|
|
// unsigned int rascepitel :1; // 1 - yes, 0 - no ñîñòîÿíèå ðàñöåïèòåëÿ
|
|
//
|
|
//// unsigned int leading_ready :1; //1 - second inverter ready to work or in work
|
|
//// unsigned int leading_Go :1;
|
|
// } bit;
|
|
// unsigned int all;
|
|
// } cmd;
|
|
} SYNC_TOOLS_DATA;
|
|
|
|
#define SYNC_TOOLS_DATA_DEFAULT {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
|
|
|
extern SYNC_TOOLS_DATA sync_data;
|
|
|
|
|
|
|
|
|
|
void setup_sync_line(void);
|
|
void sync_inc_error(void);
|
|
void setup_sync_int(void);
|
|
void start_sync_interrupt(void);
|
|
void stop_sync_interrupt(void);
|
|
void stop_sync_interrupt_local(void);
|
|
|
|
|
|
int get_status_sync_line(void);
|
|
|
|
void clear_sync_error(void);
|
|
|
|
void Sync_alg(void);
|
|
void calculate_sync_detected(void);
|
|
|
|
|
|
|
|
|
|
inline void i_sync_pin_on()
|
|
{
|
|
EALLOW;
|
|
GpioDataRegs.GPBSET.bit.GPIOB12 = 1;
|
|
EDIS;
|
|
}
|
|
|
|
|
|
inline void i_sync_pin_off()
|
|
{
|
|
EALLOW;
|
|
GpioDataRegs.GPBCLEAR.bit.GPIOB12 = 1;
|
|
EDIS;
|
|
}
|
|
|
|
|