Dmitry Kovalev / Mbed 2 deprecated LG2

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Tue Feb 16 03:00:30 2016 +0000
Revision:
61:1b76fe74a0d9
Parent:
60:98eb64c0fda3
Child:
62:2d2dcf999fb5
Device protocol&settings update. Not final!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Diletant 54:d94145ba23f4 1 #ifndef __DEVICEPROTOCOL_H__
Diletant 54:d94145ba23f4 2 #define __DEVICEPROTOCOL_H__
Diletant 54:d94145ba23f4 3
Diletant 54:d94145ba23f4 4 #include "DeviceSettings.h"
Diletant 54:d94145ba23f4 5 #include "stdint.h"
Diletant 54:d94145ba23f4 6
Diletant 59:daf3a8ed255e 7 /*Move this to uart_m.h when protocol completed*/
Diletant 59:daf3a8ed255e 8 #define IOBufferSize 1024
Diletant 59:daf3a8ed255e 9 typedef struct _IOCyclicBuffer {
Diletant 59:daf3a8ed255e 10 uint8_t buffer[IOBufferSize];
Diletant 59:daf3a8ed255e 11 int start; //first byte position
Diletant 59:daf3a8ed255e 12 int end; //last byte position
Diletant 59:daf3a8ed255e 13 } IOCyclicBuffer;
Diletant 59:daf3a8ed255e 14
Diletant 59:daf3a8ed255e 15 /*
Diletant 54:d94145ba23f4 16 typedef struct {
Diletant 54:d94145ba23f4 17 uint8_t Offset;
Diletant 54:d94145ba23f4 18 uint8_t Mask;
Diletant 54:d94145ba23f4 19 uint8_t Value;
Diletant 54:d94145ba23f4 20 } DeviceMessageCheckPoint;
Diletant 54:d94145ba23f4 21
Diletant 54:d94145ba23f4 22 typedef enum{
Diletant 54:d94145ba23f4 23 DMID_DeviceMode
Diletant 54:d94145ba23f4 24 } DeviceMessageID;
Diletant 54:d94145ba23f4 25
Diletant 54:d94145ba23f4 26 typedef struct {
Diletant 54:d94145ba23f4 27 DeviceMessageID ID;
Diletant 54:d94145ba23f4 28 uint8_t Size;
Diletant 54:d94145ba23f4 29 uint8_t CheckPointCount;
Diletant 54:d94145ba23f4 30 DeviceMessageCheckPoint *CheckPointList;
Diletant 54:d94145ba23f4 31 } DeviceMessageCheck;
Diletant 59:daf3a8ed255e 32 */
Diletant 61:1b76fe74a0d9 33
Diletant 61:1b76fe74a0d9 34 #define DELTA_PS 0xa0 //e. the code of the B_DeltaPS command //r. код команды B_DeltaPS
Diletant 61:1b76fe74a0d9 35 #define DELTA_BINS 0xb0 //e. the code of the B_DeltaBINS command //r. код команды B_DeltaBINS
Diletant 61:1b76fe74a0d9 36 #define DELTA_SF 0xb2 //e. the code of the B_DeltaSF command //r. код команды B_DeltaSF
Diletant 61:1b76fe74a0d9 37 #define DEV_MODE 0xa5 //e. the code of the Device_Mode command //r. код команды Device_Mode
Diletant 61:1b76fe74a0d9 38 #define BIT_MODE 0xa7 //e. the code of the B.I.T. command //r. код команды B.I.T.(встороенного тестирования)
Diletant 61:1b76fe74a0d9 39 #define RATE 0x00 //e. the code of the Rate command //r. код команды Rate
Diletant 61:1b76fe74a0d9 40 #define DELTA 0x0f //e. the code of the Delta command //r. код команды Delta
Diletant 61:1b76fe74a0d9 41 #define D_PERIOD_W 0xf0 //e. the code of the D_Period_W command //r. код команды D_Period_W
Diletant 61:1b76fe74a0d9 42
Diletant 61:1b76fe74a0d9 43 #define MAINTENANCE 0x99 //e. the code of the Maintenance mode command //r. код команды Maintenance mode
Diletant 61:1b76fe74a0d9 44 #define M0_MAINTENANCE 0x99 //Maintenance command set version: initial version
Diletant 61:1b76fe74a0d9 45 //Basic maintenance commands group
Diletant 61:1b76fe74a0d9 46 #define M0_BASIC 0xda //Basic maintenance commands group code
Diletant 61:1b76fe74a0d9 47 #define M0_CLEAR 0x00 //group command select: e. reset of the register of errors of line 485 //r. очистка регистра ошибок линии 485
Diletant 61:1b76fe74a0d9 48 #define M0_MIRROR 0x01 //group command select: e. return previous contents of the receiver buffer //r. возврат предыдущего содержимого буфера приемника
Diletant 61:1b76fe74a0d9 49 #define M0_LDPAR_F 0x02 //group command select: e. load GLD parameters from Flash-memory //r. загрузить параметры ГЛД из флэш-памяти
Diletant 61:1b76fe74a0d9 50 #define M0_LDPAR_D 0x03 //group command select: e. set GLD parameters by procedure of initialization //r. установить параметры ГЛД процедурой инициализации
Diletant 61:1b76fe74a0d9 51 #define M0_START 0x04 //group command select: e. switch on the GLD //r. включить ГЛД
Diletant 61:1b76fe74a0d9 52 #define M0_STOP 0x40 //group command select: e. switch off the GLD //r. выключить ГЛД
Diletant 61:1b76fe74a0d9 53 #define M0_PULSE 0x0a //group command select: e. generation of the light-up pulse //r. генерация импульса поджига
Diletant 61:1b76fe74a0d9 54 //Other maintenance commands
Diletant 61:1b76fe74a0d9 55 #define M0_STIMUL 0x0a //e. the code of the Stimul command //r. код команды Stimul
Diletant 61:1b76fe74a0d9 56 #define M0_RESET 0x80 //e. software device reset(restart) //r. программный сброс (рестарт) прибора
Diletant 61:1b76fe74a0d9 57
Diletant 61:1b76fe74a0d9 58 #define M0_CTL_R 0xd9 //e. reading the control register of the device //r. чтение регистра управления устройства
Diletant 61:1b76fe74a0d9 59 #define M0_CTL_M 0xd8 //e. modification of bit of the control register //r. модификация бита регистра управления
Diletant 61:1b76fe74a0d9 60 #define M0_RATE 0xdd //e. delivery of a stack of parameters M_Rate (Rate2, Rate3) //r. выдача набора параметров M_Rate (Rate2, Rate3)
Diletant 61:1b76fe74a0d9 61
Diletant 61:1b76fe74a0d9 62 #define M0_TMP_W 0xe0 //e. writing to the AD7714 circuit (temperature sensors) //r. запись в схемы AD7714 (измерители температуры)
Diletant 61:1b76fe74a0d9 63 #define M0_TMP_R 0xe1 //e. reading from the AD7714 circuit (temperature sensors) //r. чтение из схем AD7714 (измерители температуры)
Diletant 61:1b76fe74a0d9 64 #define M0_E5R_W 0xe2 //e. writing to the register of a mode of the Elio5 card //r. запись в регистр режима платы Elio5
Diletant 61:1b76fe74a0d9 65 #define M0_ADC_R 0xe3 //e. reading data from the ADC of the Elio5 card //r. чтение данных из АЦП платы Elio5
Diletant 61:1b76fe74a0d9 66 #define M0_VIB_W 0xe4 //e. loading of the oscillation period of the dither drive //r. загрузка периода колебаний вибропривода
Diletant 61:1b76fe74a0d9 67 #define M0_CNT_R 0xe5 //e. reading data from the counters of the Elio5 card //r. чтение данных из счетчиков платы Elio5
Diletant 61:1b76fe74a0d9 68 #define M0_GPH_W 0xe6 //e. loading gain factors of photodetector channels //r. загрузка коэффициентов усиления каналов фотоприемника
Diletant 61:1b76fe74a0d9 69 #define M0_FLG_R 0xe7 //e. reading data from the register of input flags //r. чтение данных из регистра входных флагов
Diletant 61:1b76fe74a0d9 70 #define M0_PARAM_W 0xe8 //e. writing working parameter to the data memory //r. запись рабочего параметра в память данных
Diletant 61:1b76fe74a0d9 71 #define M0_PARAM_R 0xe9 //e. reading working parameter of the GLD from the data memory //r. чтение рабочего параметра GLD из памяти данных
Diletant 61:1b76fe74a0d9 72 #define M0_E5RA_W 0xea //e. writing in 1st additional (A) register of a mode of the Elio5 card //r. запись в 1-ый дополнительный (А) регистр режима платы Elio5
Diletant 54:d94145ba23f4 73
Diletant 54:d94145ba23f4 74 //Command: DeviceMode
Diletant 59:daf3a8ed255e 75 //DeviceMessageCheckPoint DeviceModeRequestCheck[] = {{0x00,0xff,0xcc},{0x02,0xff,0xcc},{0x03,0xf0,0x00}};
Diletant 59:daf3a8ed255e 76 //DeviceMessageCheckPoint DeviceModeResponseCheck[] = {{0x00,0xff,0xcc},{0x02,0xff,0x00}};
Diletant 54:d94145ba23f4 77 typedef enum
Diletant 54:d94145ba23f4 78 {
Diletant 54:d94145ba23f4 79 Reserved,
Diletant 54:d94145ba23f4 80 DevModeLatch10kHz, //internal latch with frequency 10 kHz (power on default mode)
Diletant 54:d94145ba23f4 81 DevModeLatchMeander, //internal latch by signed meander pulses
Diletant 54:d94145ba23f4 82 DevModeLatchRS422PS, //external latch by RS422 B_Delta_PS request with B_Delta_PS format response
Diletant 54:d94145ba23f4 83 DevModeLatchRequestPS, //external latch by pulse request with B_Delta_PS format response
Diletant 54:d94145ba23f4 84 DevModeLatchRS422BINS, //external latch by RS422 B_Delta_BINS request with B_Delta_BINS format response
Diletant 54:d94145ba23f4 85 DevModeLatchRequestBINS //external latch mode with B_Delta_BINS format data and latch pulse request
Diletant 54:d94145ba23f4 86 } DeviceModes;
Diletant 54:d94145ba23f4 87 typedef __packed struct {
Diletant 54:d94145ba23f4 88 uint8_t SOC; //Start Of Command: 0xCC
Diletant 54:d94145ba23f4 89 uint8_t Address; //Device address: 0x00, 0x01, 0x02, 0x1f
Diletant 54:d94145ba23f4 90 uint8_t Cmd; //Command code: 0xA5
Diletant 54:d94145ba23f4 91 uint8_t Reserved : 4; //Reserved
Diletant 54:d94145ba23f4 92 DeviceModes Mode : 4; //Device mode
Diletant 54:d94145ba23f4 93 uint8_t ChecksumHi; //Checksum Hi byte
Diletant 54:d94145ba23f4 94 uint8_t ChecksumLo; //Checksum Lo byte
Diletant 54:d94145ba23f4 95 } DeviceModeRequest;
Diletant 54:d94145ba23f4 96 typedef __packed struct {
Diletant 54:d94145ba23f4 97 uint8_t SOC; //Start Of Command: 0xCC
Diletant 54:d94145ba23f4 98 uint8_t Address; //Device address: 0x00, 0x01, 0x02, 0x1f
Diletant 54:d94145ba23f4 99 uint8_t Zero; //Reserved: 0x00
Diletant 54:d94145ba23f4 100 uint8_t Mode; //Device mode
Diletant 54:d94145ba23f4 101 uint8_t RgRHi; //Register RgR Hi byte
Diletant 54:d94145ba23f4 102 uint8_t RgRLo; //Register RgR Lo byte
Diletant 54:d94145ba23f4 103 uint8_t ChecksumHi; //Checksum Hi byte
Diletant 54:d94145ba23f4 104 uint8_t ChecksumLo; //Checksum Lo byte
Diletant 54:d94145ba23f4 105 } DeviceModeResponse;
Diletant 59:daf3a8ed255e 106 /*
Diletant 54:d94145ba23f4 107 DeviceMessageCheck DeviceRequestChecks[] = {
Diletant 54:d94145ba23f4 108 {DMID_DeviceMode, 6, 3, DeviceModeRequestCheck}
Diletant 54:d94145ba23f4 109 };
Diletant 54:d94145ba23f4 110
Diletant 54:d94145ba23f4 111 DeviceMessageCheck DeviceResponseChecks[] = {
Diletant 54:d94145ba23f4 112 {DMID_DeviceMode, 8, 2, DeviceModeResponseCheck}
Diletant 54:d94145ba23f4 113 };
Diletant 59:daf3a8ed255e 114 */
Diletant 54:d94145ba23f4 115
Diletant 59:daf3a8ed255e 116 int PullRequest(IOCyclicBuffer *b);
Diletant 54:d94145ba23f4 117
Diletant 54:d94145ba23f4 118 #endif /* __DEVICEPROTOCOL_H__ */