![Nova Electronics MCX514 Скачать руководство пользователя страница 262](http://html1.mh-extra.com/html/nova-electronics/mcx514/mcx514_user-manual_1710400262.webp)
NOVA electronics Inc. MCX514 -
249
-
249
-
// Common function of
commands for writing data
// Data can be written by writing data into WR6, WR7, and then writing a command into WR0.
int SetData(unsigned short Cmd, int Axis, long Data) {
long mask_data = 0x0000ffff;
unsigned short write_data;
// Writes the lower 16-bit of data into WR6
write_data = (unsigned short )(Data & mask_data);
WriteReg6(write_data);
// Writes the upper 16-bit of data into WR7
write_data = (unsigned short )(Data >> 16);
WriteReg7(write_data);
// Writes a command (into WR0)
WriteReg0(((Axis << 8) + Cmd));
return 0;
}
// Common function of
commands for writing mode
// Data can be written by writing data into WR6, and then writing a command into WR0.
int SetModeData(unsigned short Cmd, int Axis, unsigned short Data) {
// Writes the lower 16-bit of data into WR6
WriteReg6(Data);
// Writes a command (into WR0)
WriteReg0(((Axis << 8) + Cmd));
return 0;
}
// Common function of commands for reading data
// Data can be read by writing a command into WR0, and then read RR6, RR7.
int GetData(unsigned short Cmd, int Axis, long *Data) {
unsigned short rdata1,rdata2;
long retdata = 0x00000000;
if (Data == NULL) return 0;
// Writes a command (into WR0)
WriteReg0(((Axis << 8) + Cmd));
// Reads RR7
ReadReg7(&rdata1);
// Reads RR6
ReadReg6(&rdata2);
// Create data for reading
retdata = (long )rdata1;
// Sets RR7 value to the upper 16-bit
*Data = (retdata << 16);
retdata = (long )rdata2;
// Sets RR6 value to the lower 16-bit
*Data = *Data + retdata;
return 0;
}
// Common function of command execution
int ExeCmd(unsigned short Cmd, int Axis) {
// Writes a command (into WR0)
WriteReg0(((Axis << 8) + Cmd));
return 0;
}