145 lines
3.6 KiB
C
145 lines
3.6 KiB
C
|
/*
|
|||
|
* synhro_tools.c
|
|||
|
*
|
|||
|
* Created on: 13 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>. 2024 <EFBFBD>.
|
|||
|
* Author: Evgeniy_Sokolov
|
|||
|
*/
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#include <edrk_main.h>
|
|||
|
|
|||
|
#include <params.h>
|
|||
|
#include <params_alg.h>
|
|||
|
#include <params_norma.h>
|
|||
|
#include <params_pwm24.h>
|
|||
|
#include <params_temper_p.h>
|
|||
|
#include <project.h>
|
|||
|
#include "IQmathLib.h"
|
|||
|
#include "mathlib.h"
|
|||
|
#include "optical_bus.h"
|
|||
|
#include "sync_tools.h"
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////
|
|||
|
unsigned int wait_synhro_optical_bus(void)
|
|||
|
{
|
|||
|
static unsigned int cmd = 0;
|
|||
|
static unsigned int count_wait_synhro = 0;
|
|||
|
|
|||
|
|
|||
|
//
|
|||
|
// switch(cmd)
|
|||
|
// {
|
|||
|
// 0 : if (optical_read_data.data.cmd.bit.wdog_tick == 0)
|
|||
|
// cmd = 1;
|
|||
|
//
|
|||
|
// break;
|
|||
|
//
|
|||
|
// 1 : optical_write_data.data.cmd.bit.wdog_tick = 1;
|
|||
|
// break;
|
|||
|
//
|
|||
|
//
|
|||
|
// default: break
|
|||
|
// }
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////
|
|||
|
void clear_wait_synhro_optical_bus(void)
|
|||
|
{
|
|||
|
|
|||
|
// optical_read_data.data.cmd.bit.wdog_tick = 0;
|
|||
|
// optical_write_data.data.cmd.bit.wdog_tick = 0;
|
|||
|
|
|||
|
}
|
|||
|
//////////////////////////////////////////////////////////
|
|||
|
//////////////////////////////////////////////////////////
|
|||
|
void who_select_sync_signal(void)
|
|||
|
{
|
|||
|
|
|||
|
if (sync_data.what_main_pch)
|
|||
|
{
|
|||
|
if (sync_data.what_main_pch==2)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!!
|
|||
|
if (edrk.flag_second_PCH)
|
|||
|
sync_data.enable_do_sync = 1;
|
|||
|
else
|
|||
|
sync_data.enable_do_sync = 0;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (sync_data.what_main_pch==1)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!!
|
|||
|
if (edrk.flag_second_PCH)
|
|||
|
sync_data.enable_do_sync = 0;
|
|||
|
else
|
|||
|
sync_data.enable_do_sync = 1;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// if (optical_read_data.status == 1)
|
|||
|
sync_data.global_flag_sync_1_2 = (sync_data.local_flag_sync_1_2 || optical_read_data.data.cmd.bit.sync_1_2);
|
|||
|
// else
|
|||
|
// sync_data.global_flag_sync_1_2 = (sync_data.local_flag_sync_1_2);
|
|||
|
|
|||
|
|
|||
|
if (sync_data.timeout_sync_signal && optical_read_data.data.cmd.bit.sync_line_detect)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>.
|
|||
|
|
|||
|
sync_data.enable_do_sync = 0;
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (sync_data.timeout_sync_signal==0 && optical_read_data.data.cmd.bit.sync_line_detect==0)
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>.
|
|||
|
|
|||
|
sync_data.enable_do_sync = 1;
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (sync_data.sync_ready && sync_data.timeout_sync_signal==0 && optical_read_data.data.cmd.bit.sync_line_detect)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
if (optical_read_data.data.cmd.bit.sync_1_2 && sync_data.enable_do_sync==0)
|
|||
|
{
|
|||
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
if (optical_read_data.data.cmd.bit.sync_1_2 && sync_data.enable_do_sync==1)
|
|||
|
{
|
|||
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><> <20><><EFBFBD>
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>.
|
|||
|
if (edrk.flag_second_PCH==0)
|
|||
|
sync_data.enable_do_sync = 1;
|
|||
|
else
|
|||
|
sync_data.enable_do_sync = 0;
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////
|
|||
|
|