110 lines
4.0 KiB
C
110 lines
4.0 KiB
C
/*
|
|
* optical_bus.h
|
|
*
|
|
* Created on: 18 àâã. 2020 ã.
|
|
* Author: stud
|
|
*/
|
|
|
|
#ifndef SRC_MAIN_OPTICAL_BUS_H_
|
|
#define SRC_MAIN_OPTICAL_BUS_H_
|
|
|
|
#include "xp_cds_tk_23550.h"
|
|
|
|
enum
|
|
{
|
|
CODE_READY_CMD_NOT_READY=0, //// 0 - not ready
|
|
CODE_READY_CMD_READY1, //1-ready1
|
|
CODE_READY_CMD_READY1TO2, //2-ready1to2
|
|
CODE_READY_CMD_READY2 //3 -ready2
|
|
};
|
|
|
|
enum
|
|
{
|
|
CODE_RASCEPITEL_CMD_ENABLE_ON_AND_THIS_OFF=0, //0 - ìîæíî âêëþ÷àòü ðàñöåïèòåëü, ñâîé âûêëþ÷åí
|
|
CODE_RASCEPITEL_CMD_ENABLE_ON_AND_THIS_ON, // 1 - ìîæíî âêëþ÷àòü ðàñöåïèòåëü, ñâîé âêëþ÷åí
|
|
CODE_RASCEPITEL_CMD_REQUEST_AND_THIS_OFF, // 2 - çàïðîñ íà âêëþ÷åíèå, ñâîé âûêëþ÷åí
|
|
CODE_RASCEPITEL_CMD_DISABLE_THIS_ON // 3 - çàïðåò ïîäêëþ÷åíèÿ ðàñöåïèòåëÿ, ñâîé âêëþ÷åí
|
|
};
|
|
|
|
|
|
typedef 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_line_detect :1; // 1 - yes, 0 - no ñèíõðîñèãíàë ïðèíèìàåòñÿ
|
|
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 prepare_stop_PWM :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 can_on_rascepitel :1; // 1 - yes, 0 - no ìîæíî ïîäêëþ÷àòü ðàñöåïèòåëü
|
|
unsigned int maybe_master :1; // 1 - yes, 0 - no çàïðîñ íà çàõâàò ðåæèìà Master
|
|
unsigned int rascepitel_cmd :2; //
|
|
// 00 - ìîæíî âêëþ÷àòü ðàñöåïèòåëü, ñâîé âûêëþ÷åí
|
|
// 01 - ìîæíî âêëþ÷àòü ðàñöåïèòåëü, ñâîé âêëþ÷åí
|
|
// 10 - çàïðîñ íà âêëþ÷åíèå, ñâîé âûêëþ÷åí
|
|
// 11 - çàïðåò ïîäêëþ÷åíèÿ ðàñöåïèòåëÿ, ñâîé âêëþ÷åí
|
|
} bit;
|
|
unsigned int all;
|
|
} OPTICAL_BUS_DATA_LOW_CMD;
|
|
|
|
|
|
// typedef union {
|
|
// struct {
|
|
// unsigned int ready :1; // äàííûå ãîòîâû
|
|
// unsigned int overfull :1; //äàííûå ïîòåðÿíû
|
|
// unsigned int recive_error :1; //äàííûå ïðèøëè ñ îøèáêîé
|
|
// unsigned int send_error :1; //äàííûå óøëè ñ îøèáêîé
|
|
// unsigned int wait :1; //äàííûå îæèäàþòñÿ
|
|
// unsigned int timeout :1; //äàííûõ äàâíî íå áûëî
|
|
// } bit;
|
|
// unsigned int all;
|
|
// } OPTICAL_BUS_CODE_STATUS;
|
|
|
|
|
|
typedef struct {
|
|
int pzad_or_wzad; //given turns or power, depends on controlMode;
|
|
int angle_pwm; //current rotor turns
|
|
int iq_zad_i_zad; // Iq_zadan or Izad
|
|
OPTICAL_BUS_DATA_LOW_CMD cmd;
|
|
} OPTICAL_BUS_DATA_LOW;
|
|
|
|
typedef struct {
|
|
OPTICAL_BUS_DATA_LOW raw;
|
|
OPTICAL_BUS_DATA_LOW data;
|
|
unsigned int status;
|
|
unsigned int overfull_data;
|
|
unsigned int timer;
|
|
unsigned int flag_clear;
|
|
unsigned int data_was_update_between_pwm_int;
|
|
unsigned int error_wdog;
|
|
unsigned int count_error_wdog;
|
|
unsigned int count_read_optical_bus_old_data; // ñ÷åò÷èê âðåìåíè ñêîëüêî äàííûå íå îáíîâëÿëèñü
|
|
|
|
|
|
// OPTICAL_BUS_CODE_STATUS code_status;
|
|
} OPTICAL_BUS_DATA;
|
|
|
|
|
|
#define OPTICAL_BUS_DATA_DEFAULT {{0,0,0,0},{0,0,0,0},0,0,0,0,0,0,0,0}
|
|
|
|
extern OPTICAL_BUS_DATA optical_write_data;
|
|
extern OPTICAL_BUS_DATA optical_read_data;
|
|
|
|
|
|
void optical_bus_read(void);
|
|
STATUS_DATA_READ_OPT_BUS optical_bus_get_status_and_read(void);
|
|
void optical_bus_write(void);
|
|
void optical_bus_read_clear_count_error(void);
|
|
void optical_bus_update_data_write(void);
|
|
|
|
#endif /* SRC_MAIN_OPTICAL_BUS_H_ */
|