110 lines
4.0 KiB
C
110 lines
4.0 KiB
C
|
/*
|
|||
|
* optical_bus.h
|
|||
|
*
|
|||
|
* Created on: 18 <EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
|
|||
|
* 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 - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
CODE_RASCEPITEL_CMD_ENABLE_ON_AND_THIS_ON, // 1 - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
CODE_RASCEPITEL_CMD_REQUEST_AND_THIS_OFF, // 2 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
CODE_RASCEPITEL_CMD_DISABLE_THIS_ON // 3 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
typedef union {
|
|||
|
struct {
|
|||
|
unsigned int wdog_tick :1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0_1_0 <20> <20>.<2E>.
|
|||
|
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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned int sync_1_2 :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><>
|
|||
|
unsigned int alarm :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
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 <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// unsigned int ready_to_go :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
|||
|
unsigned int start_pwm :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
unsigned int stop_pwm :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
unsigned int pwm_status :1; // 1 -On, 0 - Off <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
// unsigned int can_on_rascepitel :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
unsigned int maybe_master :1; // 1 - yes, 0 - no <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Master
|
|||
|
unsigned int rascepitel_cmd :2; //
|
|||
|
// 00 - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// 01 - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// 10 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// 11 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
} bit;
|
|||
|
unsigned int all;
|
|||
|
} OPTICAL_BUS_DATA_LOW_CMD;
|
|||
|
|
|||
|
|
|||
|
// typedef union {
|
|||
|
// struct {
|
|||
|
// unsigned int ready :1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// unsigned int overfull :1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// unsigned int recive_error :1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// unsigned int send_error :1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// unsigned int wait :1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// unsigned int timeout :1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
|||
|
// } 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; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
// 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_ */
|