matlab_23550/Inu/Src/N12_Xilinx/x_parallel_bus.h

127 lines
4.8 KiB
C
Raw Normal View History

#ifndef _X_PARALLEL_BUS_H
#define _X_PARALLEL_BUS_H
#define MAX_WAIT_ERROR_PARALLEL_BUS 3 // <20><><EFBFBD><EFBFBD>. <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>
typedef union {
unsigned int all;
struct {
unsigned int started:1;
unsigned int error:1;
unsigned int cmd_start:1;
unsigned int count_error:4;
unsigned int slave_addr_error:4;
unsigned int init:1;
unsigned int was_started:1;
unsigned int rezerv:3;
} bit;
} X_PARALLEL_BUS_flags;
typedef struct {
unsigned int setup_error_count_read; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int size_table; // <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add_table
unsigned int tms_adr_data_finish; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TMS <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> , <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int tms_adr_data_start; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TMS <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int free_table; // <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
} X_PARALLEL_BUS_Setup;
#define X_PARALLEL_BUS_Setup_DEFAULTS {MAX_WAIT_ERROR_PARALLEL_BUS, -1, 0, 0, -1}
typedef struct { X_PARALLEL_BUS_flags flags; // <20><><EFBFBD><EFBFBD><EFBFBD>
X_PARALLEL_BUS_Setup setup; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int slave_addr; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD>
unsigned int reg_addr; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD>
unsigned int error_count_start; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
unsigned int count_read; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
unsigned int adr_table_read; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 0 _ (size_table-1) ,
// adr_table_read + tms_adr_data_start
unsigned int data_table_read; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> parallel bus,
// unsigned int error_count_write; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// unsigned int error_count_hold; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
void (*clear_table)(); // Pointer to read function
void (*add_table)(); // Pointer to read function
void (*start)(); // Pointer to read function
void (*stop)(); // Pointer to read function
void (*restart)(); // Pointer to read function
void (*init)(); // Pointer to init function
void (*read_status)(); // Pointer to init function
void (*read_one_data)(); // Pointer to init function
int (*check_free_table)(); // Pointer to init function
}X_PARALLEL_BUS;
/*
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TIME_OUT_SERIAL_BUS 10000 // max 65535
#define CMD_SERIAL_BUS_READ 0x0000
#define CMD_SERIAL_BUS_WRITE 0x8000
*/
typedef X_PARALLEL_BUS *X_PARALLEL_BUS_handle;
#define X_PARALLEL_BUS_DEFAULTS { 0, \
X_PARALLEL_BUS_Setup_DEFAULTS, \
0, \
0, \
0, \
0, \
0, \
0, \
(void (*)(Uint32))x_parallel_bus_clear_table,\
(void (*)(Uint32))x_parallel_bus_add_table,\
(void (*)(Uint32))x_parallel_bus_start,\
(void (*)(Uint32))x_parallel_bus_stop,\
(void (*)(Uint32))x_parallel_bus_restart,\
(void (*)(Uint32))x_parallel_bus_init,\
(void (*)(Uint32))x_parallel_bus_read_status,\
(void (*)(Uint32))x_parallel_bus_read_one_data,\
(int (*)(Uint32))x_parallel_bus_check_free_table\
}
void x_parallel_bus_clear_table(X_PARALLEL_BUS_handle);
void x_parallel_bus_add_table(X_PARALLEL_BUS_handle);
void x_parallel_bus_start(X_PARALLEL_BUS_handle);
void x_parallel_bus_stop(X_PARALLEL_BUS_handle);
void x_parallel_bus_restart(X_PARALLEL_BUS_handle);
void x_parallel_bus_init(X_PARALLEL_BUS_handle);
void x_parallel_bus_read_status(X_PARALLEL_BUS_handle);
void x_parallel_bus_read_one_data(X_PARALLEL_BUS_handle);
int x_parallel_bus_check_free_table(X_PARALLEL_BUS_handle);
extern X_PARALLEL_BUS x_parallel_bus_project;
#define read_pbus_value(bit,adr,res) {if (bit) res = i_ReadMemory(adr++); else res = 0; }
#define read_pbus_value_full(bit,adr,res) {res = i_ReadMemory(adr++); }
#define read_pbus_adc_value(bit,adr,res) {if (bit) res = i_ReadMemory(adr++) & 0xfff; else res = 0; }
#define read_pbus_adc_value_full(bit,adr,res) {res = i_ReadMemory(adr++) & 0xfff; }
// ver 2
#define read_pbus_value_v2(bit,adr,res) {if (bit) { res = i_ReadMemory(adr); i_WriteMemory(adr++,0x0); } else res = 0; }
#define read_pbus_value_full_v2(bit,adr,res) {res = i_ReadMemory(adr); i_WriteMemory(adr++,0x0); }
#define read_pbus_adc_value_v2(bit,adr,res) {if (bit) { res = i_ReadMemory(adr) & 0xfff; i_WriteMemory(adr++,0x0);} else res = 0; }
#define read_pbus_adc_value_full_v2(bit,adr,res) {res = i_ReadMemory(adr) & 0xfff; i_WriteMemory(adr++,0x0); }
#endif // end _X_PARALLEL_BUS_H