123
Fork of LG by
Diff: DeviceUser.h
- Revision:
- 198:78dd6d14d108
- Parent:
- 197:7a05523bf588
--- a/DeviceUser.h Wed Oct 19 10:55:05 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ -#ifndef __DEVICE_USER_H__ -#define __DEVICE_USER_H__ - -#include "stdint.h" -#include "DeviceUserRequest.h" -#include "DeviceUserResponse.h" -#include "DeviceUserDecoder.h" -#include "DeviceUserEncoder.h" - -#define BROADCAST_ADDRESS 0x1f -#define BROADCAST_FRAME 100 //100 mks - -//All commands -#define DELTA_PS 0xa000 //B_DeltaPS command code: output of accumulated pulses and ACS parameters as 22 indexed packets sequence -#define DELTA_BINS 0xb000 //B_DeltaBINS command code: output of accumulated pulses and data validity attribute in one packet -#define DELTA_SF 0xb200 //B_DeltaSF command code: scale factor measurement data output in one packet -#define DEV_MODE 0xa500 //Device_Mode command code -#define BIT_MODE 0xa700 //B.I.T. (built-in test) command code - -#define MAINTENANCE 0x9900 //Maintenance mode command code -//Maintenance command set versions -#define M0_MAINTENANCE 0x99 //: initial version -//Maintenance basic commands group -#define M0_BASIC 0xda00 //Basic maintenance commands group code -#define M0_CLEAR 0xda00 //group command select: reset line 485 error register -#define M0_MIRROR 0xda01 //group command select: return previous contents of the receiver buffer -#define M0_LDPAR_F 0xda02 //group command select: load device parameters from Flash-memory -#define M0_LDPAR_D 0xda03 //group command select: set device parameters by procedure of initialization -#define M0_START 0xda04 //group command select: switch on the device -#define M0_STOP 0xda40 //group command select: switch off the device -#define M0_PULSE 0xda0a //group command select: generation of the light-up pulse -//Maintenance rate commands group -#define M0_RATE 0xdd00 //M_Rate commands group code -#define M0_RATE_1 0xdd01 //group command select: output parameters set 1 (MRate) -#define M0_RATE_2 0xdd02 //group command select: output parameters set 2 (MRate2) -#define M0_RATE_3 0xdd03 //group command select: output parameters set 3 (MRate3) -#define M0_RATE_4 0xdd04 //group command select: output parameters set 4 (MRate4) -#define M0_RATE_7 0xdd07 //group command select: output parameters set 7 (MRate7) - -//Other maintenance commands -#define M0_STIMUL 0x0a00 //MStimul command code -#define M0_RESET 0x8000 //software device reset(restart) - -#define M0_CTL_R 0xd900 //reading the control register RgConA/B of the device -#define M0_CTL_A_R 0xd900 //MCtlR command code mask: reading the control register RgConA of the device -#define M0_CTL_B_R 0xd910 //MCtlR command code mask: reading the control register RgConB of the device -#define M0_CTL_M 0xd800 //modification of bit of the control register -#define M0_CTL_A_M 0xd800 //MCtlM command code mask: modification control register RgConA of the device -#define M0_CTL_B_M 0xd810 //MCtlM command code mask: modification the control register RgConB of the device - -#define M0_TMP_W 0xe000 //writing to the AD7714 circuit (temperature sensors) -#define M0_TMP_R 0xe100 //reading from the AD7714 circuit (temperature sensors) -#define M0_E5R_W 0xe200 //writing to the register of a mode of the Elio5 card -#define M0_ADC_R 0xe300 //reading data from the ADC of the Elio5 card -#define M0_VIB_W 0xe400 //loading of the oscillation period of the dither drive -#define M0_CNT_R 0xe500 //reading data from the counters of the Elio5 card -#define M0_GPH_W 0xe600 //loading gain factors of photodetector channels -#define M0_FLG_R 0xe700 //reading data from the register of input flags -#define M0_PARAM_W 0xe800 //writing working parameter to the data memory -#define M0_PARAM_R 0xe900 //reading working parameter of the GLD from the data memory -#define M0_E5RA_W 0xea00 //writing in 1st additional (A) register of a mode of the Elio5 card - -//Factory maintenance commands -#define FACTORY_ACCESS 0xff00 //Factory access: command mask - -#define H_PARAM8_R 0xff00 //Hash access: 0000b read 1-byte param -#define H_PARAM16_R 0xff01 //Hash access: 0001b read 2-byte param -#define H_PARAM32_R 0xff03 //Hash access: 0010b read 4-byte param -#define H_BYTES_R 0xff0f //Hash access: 1111b read bytes param - -#define H_PARAM8_W 0xff10 //Hash access: 0000b write 1-byte param -#define H_PARAM16_W 0xff11 //Hash access: 0001b write 2-byte param -#define H_PARAM32_W 0xff13 //Hash access: 0010b write 4-byte param -#define H_BYTES_W 0xff1f //Hash access: 1111b write bytes param - -#define H_FUNC_PARAM0_BY_IMM8 0xff20 //Hash access: 0000b set function parameter 0 by 8 bit immediate value -#define H_FUNC_PARAM1_BY_IMM8 0xff24 //Hash access: 0100b set function parameter 1 by 8 bit immediate value -#define H_FUNC_PARAM2_BY_IMM8 0xff28 //Hash access: 1000b set function parameter 2 by 8 bit immediate value -#define H_FUNC_PARAM3_BY_IMM8 0xff2c //Hash access: 1100b set function parameter 3 by 8 bit immediate value - -#define H_FUNC_PARAM0_BY_IMM16 0xff21 //Hash access: 0001b set function parameter 0 by 16 bit immediate value -#define H_FUNC_PARAM1_BY_IMM16 0xff25 //Hash access: 0101b set function parameter 1 by 16 bit immediate value -#define H_FUNC_PARAM2_BY_IMM16 0xff29 //Hash access: 1001b set function parameter 2 by 16 bit immediate value -#define H_FUNC_PARAM3_BY_IMM16 0xff2d //Hash access: 1101b set function parameter 3 by 16 bit immediate value - -#define H_FUNC_PARAM0_BY_IMM32 0xff23 //Hash access: 0011b set function parameter 0 by 32 bit immediate value -#define H_FUNC_PARAM1_BY_IMM32 0xff27 //Hash access: 0111b set function parameter 1 by 32 bit immediate value -#define H_FUNC_PARAM2_BY_IMM32 0xff2b //Hash access: 1011b set function parameter 2 by 32 bit immediate value -#define H_FUNC_PARAM3_BY_IMM32 0xff2f //Hash access: 1111b set function parameter 3 by 32 bit immediate value - -#define H_FUNC_PARAM0_BY_VAL8 0xff30 //Hash access: 0000b set function parameter 0 by 8 bit variable value -#define H_FUNC_PARAM1_BY_VAL8 0xff34 //Hash access: 0100b set function parameter 1 by 8 bit variable value -#define H_FUNC_PARAM2_BY_VAL8 0xff38 //Hash access: 1000b set function parameter 2 by 8 bit variable value -#define H_FUNC_PARAM3_BY_VAL8 0xff3c //Hash access: 1100b set function parameter 3 by 8 bit variable value - -#define H_FUNC_PARAM0_BY_VAL16 0xff31 //Hash access: 0001b set function parameter 0 by 16 bit variable value -#define H_FUNC_PARAM1_BY_VAL16 0xff35 //Hash access: 0101b set function parameter 1 by 16 bit variable value -#define H_FUNC_PARAM2_BY_VAL16 0xff39 //Hash access: 1001b set function parameter 2 by 16 bit variable value -#define H_FUNC_PARAM3_BY_VAL16 0xff3d //Hash access: 1101b set function parameter 3 by 16 bit variable value - -#define H_FUNC_PARAM0_BY_VAL32 0xff33 //Hash access: 0011b set function parameter 0 by 32 bit variable value -#define H_FUNC_PARAM1_BY_VAL32 0xff37 //Hash access: 0111b set function parameter 1 by 32 bit variable value -#define H_FUNC_PARAM2_BY_VAL32 0xff3b //Hash access: 1011b set function parameter 2 by 32 bit variable value -#define H_FUNC_PARAM3_BY_VAL32 0xff3f //Hash access: 1111b set function parameter 3 by 32 bit variable value - -#define H_FUNC_PARAM0_BY_REF8 0xff40 //Hash access: 0000b set function parameter 0 by 8 bit variable reference -#define H_FUNC_PARAM1_BY_REF8 0xff44 //Hash access: 0100b set function parameter 1 by 8 bit variable reference -#define H_FUNC_PARAM2_BY_REF8 0xff48 //Hash access: 1000b set function parameter 2 by 8 bit variable reference -#define H_FUNC_PARAM3_BY_REF8 0xff4c //Hash access: 1100b set function parameter 3 by 8 bit variable reference - -#define H_FUNC_PARAM0_BY_REF16 0xff41 //Hash access: 0001b set function parameter 0 by 16 bit variable reference -#define H_FUNC_PARAM1_BY_REF16 0xff45 //Hash access: 0101b set function parameter 1 by 16 bit variable reference -#define H_FUNC_PARAM2_BY_REF16 0xff49 //Hash access: 1001b set function parameter 2 by 16 bit variable reference -#define H_FUNC_PARAM3_BY_REF16 0xff4d //Hash access: 1101b set function parameter 3 by 16 bit variable reference - -#define H_FUNC_PARAM0_BY_REF32 0xff43 //Hash access: 0011b set function parameter 0 by 32 bit variable reference -#define H_FUNC_PARAM1_BY_REF32 0xff47 //Hash access: 0111b set function parameter 1 by 32 bit variable reference -#define H_FUNC_PARAM2_BY_REF32 0xff4b //Hash access: 1011b set function parameter 2 by 32 bit variable reference -#define H_FUNC_PARAM3_BY_REF32 0xff4f //Hash access: 1111b set function parameter 3 by 32 bit variable reference - -#define FUNCTION_CALL 0xff50 //Hash access: function call - no parameters -#define FUNCTION_CALL_1 0xff51 //Hash access: function call - 1 parameter -#define FUNCTION_CALL_2 0xff52 //Hash access: function call - 2 parameters -#define FUNCTION_CALL_3 0xff53 //Hash access: function call - 3 parameters -#define FUNCTION_CALL_4 0xff54 //Hash access: function call - 4 parameters - -#define FLASH_READ_ALL 0xff60 //Flash access: read all from flash -#define FLASH_WRITE_ALL 0xff70 //Flash access: write all to flash - -//Common response messages -#define MESSAGE_OK 0x0000 -#define MESSAGE_UNKNOWN_REQUEST_CODE 0x8000 -#define MESSAGE_UNKNOWN_REQUEST_PARAMETER 0x8001 -#define MESSAGE_UNKNOWN_REQUEST_HASH 0x8002 -#define MESSAGE_WRONG_REQUEST_VALUE_SIZE 0x8003 -#define MESSAGE_WRONG_REQUEST_VALUE_RANGE 0x8004 - -//Actual commands: -//BINS -// GLD initialization sequence: -// a5 04 - external latch with DeltaPS format -// a0 70 - DeltaPS 921600/921600 by request only -// Other: -// 80 00 - reset -//BINS/AskGLD/Techno -// 99 99 - maintenance -//Techno -// d8 90 - set bit 0 of RgConB -// d8 10 - reset bit 0 of RgConB -// dd 81 - periodic 38400 MRate -// a0 b0 - periodic 115200/115200 DeltaPS - -//Registers: -// RgConA - flags of regulator loops -// RgConB - counting mode: 00 - reference counters, 01 - dither counters and moving average filter - -//User protocol typedefs -typedef struct _DeviceUser { - //Device address - uint16_t address; - //Units - DeviceUserPort port; - DeviceUserDecoder decoder; - DeviceUserEncoder encoder; - DeviceUserRequest request; - DeviceUserResponse response; -} DeviceUser; - -//User communication initialization functions -void InitUserDefaultSettings(void); -void InitUserState(void); -void DeviceStartUser(void); - -#endif /* __DEVICE_USER_H__ */ \ No newline at end of file