matlab_23550/Inu/Src/N12_Xilinx/x_serial_bus.h

88 lines
2.4 KiB
C
Raw Normal View History

#ifndef _X_SERIAL_BUS_H
#define _X_SERIAL_BUS_H
// <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 1000 //10000 // max 65535
#define CMD_SERIAL_BUS_READ 0x0000
#define CMD_SERIAL_BUS_WRITE 0x8000
#define SB_ERROR_REPEATS 7
typedef union {
unsigned int all;
struct {
unsigned int data_ready:1;
unsigned int trans_compl:1;
unsigned int error:1;
unsigned int write_error:1;
unsigned int read_error:2;
unsigned int error_timeout:1;
unsigned int count_hold_bus:3;
unsigned int rezerv:6;
} bit;
} X_SERIAL_BUS_flags;
typedef struct { X_SERIAL_BUS_flags flags; // <20><><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> <20><><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD>
unsigned int write_data; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int read_data; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int count_timer; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int error_count_read; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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>
unsigned int ok_count_read; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int ok_count_write; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int (*read)(); // Pointer to read function
int (*write)(); // Pointer to write function
void (*check)(); // Pointer to check function
void (*init)(); // Pointer to init function
void (*clear_stat)(); // Pointer to init function
}X_SERIAL_BUS;
typedef X_SERIAL_BUS *X_SERIAL_BUS_handle;
#define X_SERIAL_BUS_DEFAULTS { 0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
(int (*)(Uint32))x_serial_bus_read,\
(int (*)(Uint32))x_serial_bus_write,\
(void (*)(Uint32))x_serial_bus_check,\
(void (*)(Uint32))x_serial_bus_init,\
(void (*)(Uint32))x_serial_bus_clear_stat_error\
}
int x_serial_bus_read(X_SERIAL_BUS_handle);
int x_serial_bus_write(X_SERIAL_BUS_handle);
void x_serial_bus_check(X_SERIAL_BUS_handle);
void x_serial_bus_init(X_SERIAL_BUS_handle);
void x_serial_bus_clear_stat_error(X_SERIAL_BUS_handle);
void xPeriphReadyCheck(void);
extern X_SERIAL_BUS x_serial_bus_project;
#endif // end _X_SERIAL_BUS_H