Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LG by
DeviceProtocol.h@54:d94145ba23f4, 2016-02-14 (annotated)
- Committer:
- Diletant
- Date:
- Sun Feb 14 06:28:46 2016 +0000
- Revision:
- 54:d94145ba23f4
- Child:
- 58:26cb8f5f9504
- Child:
- 59:daf3a8ed255e
Device protocol. Not final!!!
Who changed what in which revision?
| User | Revision | Line number | New 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 | 54:d94145ba23f4 | 7 | typedef struct { | 
| Diletant | 54:d94145ba23f4 | 8 | uint8_t Offset; | 
| Diletant | 54:d94145ba23f4 | 9 | uint8_t Mask; | 
| Diletant | 54:d94145ba23f4 | 10 | uint8_t Value; | 
| Diletant | 54:d94145ba23f4 | 11 | } DeviceMessageCheckPoint; | 
| Diletant | 54:d94145ba23f4 | 12 | |
| Diletant | 54:d94145ba23f4 | 13 | typedef enum{ | 
| Diletant | 54:d94145ba23f4 | 14 | DMID_DeviceMode | 
| Diletant | 54:d94145ba23f4 | 15 | } DeviceMessageID; | 
| Diletant | 54:d94145ba23f4 | 16 | |
| Diletant | 54:d94145ba23f4 | 17 | typedef struct { | 
| Diletant | 54:d94145ba23f4 | 18 | DeviceMessageID ID; | 
| Diletant | 54:d94145ba23f4 | 19 | uint8_t Size; | 
| Diletant | 54:d94145ba23f4 | 20 | uint8_t CheckPointCount; | 
| Diletant | 54:d94145ba23f4 | 21 | DeviceMessageCheckPoint *CheckPointList; | 
| Diletant | 54:d94145ba23f4 | 22 | } DeviceMessageCheck; | 
| Diletant | 54:d94145ba23f4 | 23 | |
| Diletant | 54:d94145ba23f4 | 24 | |
| Diletant | 54:d94145ba23f4 | 25 | |
| Diletant | 54:d94145ba23f4 | 26 | typedef enum { | 
| Diletant | 54:d94145ba23f4 | 27 | CMD_B_DELTA_PS = 0xa000, //e. the code of the B_DeltaPS command //r. код команды B_DeltaPS | 
| Diletant | 54:d94145ba23f4 | 28 | CMD_B_DELTA_BINS = 0xb000, //e. the code of the B_DeltaBINS command //r. код команды B_DeltaBINS | 
| Diletant | 54:d94145ba23f4 | 29 | CMD_B_DELTA_SF = 0xb200, //e. the code of the B_DeltaSF command //r. код команды B_DeltaSF | 
| Diletant | 54:d94145ba23f4 | 30 | CMD_DEV_MODE = 0xA500, //e. the code of the Device_Mode command //r. код команды Device_Mode | 
| Diletant | 54:d94145ba23f4 | 31 | CMD_BIT_MODE = 0xA700, //e. the code of the B.I.T. command //r. код команды B.I.T.(встроенного тестирования) | 
| Diletant | 54:d94145ba23f4 | 32 | CMD_RATE = 0x0000, //e. the code of the Rate command //r. код команды Rate | 
| Diletant | 54:d94145ba23f4 | 33 | CMD_DELTA = 0x0f00, //e. the code of the Delta command //r. код команды Delta | 
| Diletant | 54:d94145ba23f4 | 34 | CMD_D_PERIOD_W = 0xf000, //e. the code of the D_Period_W command //r. код команды D_Period_W | 
| Diletant | 54:d94145ba23f4 | 35 | CMD_MAINT = 0x9999, //e. the code of the Maintenance mode command //r. код команды Maintenance mode | 
| Diletant | 54:d94145ba23f4 | 36 | } DeviceCommands; | 
| Diletant | 54:d94145ba23f4 | 37 | typedef enum { | 
| Diletant | 54:d94145ba23f4 | 38 | SUBCMD_M_STIMUL = 0x0a00, //e. the code of the Stimul command //r. код команды Stimul | 
| Diletant | 54:d94145ba23f4 | 39 | SUBCMD_M_RESET = 0x8000, //e. software device reset(restart) //r. программный сброс (рестарт) прибора | 
| Diletant | 54:d94145ba23f4 | 40 | SUBCMD_M_CLEAR = 0xda00, //e. reset of the register of errors of line 485 //r. очистка регистра ошибок линии 485 | 
| Diletant | 54:d94145ba23f4 | 41 | SUBCMD_M_MIRR = 0xda01, //e. return previous contents of the receiver buffer //r. возврат предыдущего содержимого буфера приемника | 
| Diletant | 54:d94145ba23f4 | 42 | SUBCMD_M_LDPAR_F = 0xda02, //e. load GLD parameters from Flash-memory //r. загрузить параметры ГЛД из флэш-памяти | 
| Diletant | 54:d94145ba23f4 | 43 | SUBCMD_M_LDPAR_D = 0xda03, //e. set GLD parameters by procedure of initialization //r. установить параметры ГЛД процедурой инициализации | 
| Diletant | 54:d94145ba23f4 | 44 | SUBCMD_M_START = 0xda04, //e. switch on the GLD //r. включить ГЛД | 
| Diletant | 54:d94145ba23f4 | 45 | SUBCMD_M_STOP = 0xda40, //e. switch off the GLD //r. выключить ГЛД | 
| Diletant | 54:d94145ba23f4 | 46 | SUBCMD_M_PULSE = 0xda0a, //e. generation of the light-up pulse //r. генерация импульса поджига | 
| Diletant | 54:d94145ba23f4 | 47 | |
| Diletant | 54:d94145ba23f4 | 48 | SUBCMD_M_CTL_R = 0xd900, //e. reading the control register of the device //r. чтение регистра управления устройства | 
| Diletant | 54:d94145ba23f4 | 49 | SUBCMD_M_CTL_M = 0xd800, //e. modification of bit of the control register //r. модификация бита регистра управления | 
| Diletant | 54:d94145ba23f4 | 50 | SUBCMD_M_RATE = 0xdd00, //e. delivery of a stack of parameters M_Rate (Rate2, Rate3) //r. выдача набора параметров M_Rate (Rate2, Rate3) | 
| Diletant | 54:d94145ba23f4 | 51 | |
| Diletant | 54:d94145ba23f4 | 52 | SUBCMD_M_TMP_W = 0xe000, //e. writing to the AD7714 circuit (temperature sensors) //r. запись в схемы AD7714 (измерители температуры) | 
| Diletant | 54:d94145ba23f4 | 53 | SUBCMD_M_TMP_R = 0xe100, //e. reading from the AD7714 circuit (temperature sensors) //r. чтение из схем AD7714 (измерители температуры) | 
| Diletant | 54:d94145ba23f4 | 54 | SUBCMD_M_E5R_W = 0xe200, //e. writing to the register of a mode of the Elio5 card //r. запись в регистр режима платы Elio5 | 
| Diletant | 54:d94145ba23f4 | 55 | SUBCMD_M_ADC_R = 0xe300, //e. reading data from the ADC of the Elio5 card //r. чтение данных из АЦП платы Elio5 | 
| Diletant | 54:d94145ba23f4 | 56 | SUBCMD_M_VIB_W = 0xe400, //e. loading of the oscillation period of the dither drive //r. загрузка периода колебаний вибропривода | 
| Diletant | 54:d94145ba23f4 | 57 | SUBCMD_M_CNT_R = 0xe500, //e. reading data from the counters of the Elio5 card //r. чтение данных из счетчиков платы Elio5 | 
| Diletant | 54:d94145ba23f4 | 58 | SUBCMD_M_GPH_W = 0xe600, //e. loading gain factors of photodetector channels //r. загрузка коэффициентов усиления каналов фотоприемника | 
| Diletant | 54:d94145ba23f4 | 59 | SUBCMD_M_FLG_R = 0xe700, //e. reading data from the register of input flags //r. чтение данных из регистра входных флагов | 
| Diletant | 54:d94145ba23f4 | 60 | SUBCMD_M_PARAM_W = 0xe800, //e. writing working parameter to the data memory //r. запись рабочего параметра в память данных | 
| Diletant | 54:d94145ba23f4 | 61 | SUBCMD_M_PARAM_R = 0xe900, //e. reading working parameter of the GLD from the data memory //r. чтение рабочего параметра GLD из памяти данных | 
| Diletant | 54:d94145ba23f4 | 62 | SUBCMD_M_E5RA_W = 0xea00, //e. writing in 1st additional (A) register of a mode of the Elio5 card //r. запись в 1-ый дополнительный (А) регистр режима платы Elio5 | 
| Diletant | 54:d94145ba23f4 | 63 | } DeviceSubCommands; | 
| Diletant | 54:d94145ba23f4 | 64 | |
| Diletant | 54:d94145ba23f4 | 65 | //Command: DeviceMode | 
| Diletant | 54:d94145ba23f4 | 66 | DeviceMessageCheckPoint DeviceModeRequestCheck[] = {{0x00,0xff,0xcc},{0x02,0xff,0xcc},{0x03,0xf0,0x00}}; | 
| Diletant | 54:d94145ba23f4 | 67 | DeviceMessageCheckPoint DeviceModeResponseCheck[] = {{0x00,0xff,0xcc},{0x02,0xff,0x00}}; | 
| Diletant | 54:d94145ba23f4 | 68 | typedef enum | 
| Diletant | 54:d94145ba23f4 | 69 | { | 
| Diletant | 54:d94145ba23f4 | 70 | Reserved, | 
| Diletant | 54:d94145ba23f4 | 71 | DevModeLatch10kHz, //internal latch with frequency 10 kHz (power on default mode) | 
| Diletant | 54:d94145ba23f4 | 72 | DevModeLatchMeander, //internal latch by signed meander pulses | 
| Diletant | 54:d94145ba23f4 | 73 | DevModeLatchRS422PS, //external latch by RS422 B_Delta_PS request with B_Delta_PS format response | 
| Diletant | 54:d94145ba23f4 | 74 | DevModeLatchRequestPS, //external latch by pulse request with B_Delta_PS format response | 
| Diletant | 54:d94145ba23f4 | 75 | DevModeLatchRS422BINS, //external latch by RS422 B_Delta_BINS request with B_Delta_BINS format response | 
| Diletant | 54:d94145ba23f4 | 76 | DevModeLatchRequestBINS //external latch mode with B_Delta_BINS format data and latch pulse request | 
| Diletant | 54:d94145ba23f4 | 77 | } DeviceModes; | 
| Diletant | 54:d94145ba23f4 | 78 | typedef __packed struct { | 
| Diletant | 54:d94145ba23f4 | 79 | uint8_t SOC; //Start Of Command: 0xCC | 
| Diletant | 54:d94145ba23f4 | 80 | uint8_t Address; //Device address: 0x00, 0x01, 0x02, 0x1f | 
| Diletant | 54:d94145ba23f4 | 81 | uint8_t Cmd; //Command code: 0xA5 | 
| Diletant | 54:d94145ba23f4 | 82 | uint8_t Reserved : 4; //Reserved | 
| Diletant | 54:d94145ba23f4 | 83 | DeviceModes Mode : 4; //Device mode | 
| Diletant | 54:d94145ba23f4 | 84 | uint8_t ChecksumHi; //Checksum Hi byte | 
| Diletant | 54:d94145ba23f4 | 85 | uint8_t ChecksumLo; //Checksum Lo byte | 
| Diletant | 54:d94145ba23f4 | 86 | } DeviceModeRequest; | 
| 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 Zero; //Reserved: 0x00 | 
| Diletant | 54:d94145ba23f4 | 91 | uint8_t Mode; //Device mode | 
| Diletant | 54:d94145ba23f4 | 92 | uint8_t RgRHi; //Register RgR Hi byte | 
| Diletant | 54:d94145ba23f4 | 93 | uint8_t RgRLo; //Register RgR Lo byte | 
| Diletant | 54:d94145ba23f4 | 94 | uint8_t ChecksumHi; //Checksum Hi byte | 
| Diletant | 54:d94145ba23f4 | 95 | uint8_t ChecksumLo; //Checksum Lo byte | 
| Diletant | 54:d94145ba23f4 | 96 | } DeviceModeResponse; | 
| Diletant | 54:d94145ba23f4 | 97 | |
| Diletant | 54:d94145ba23f4 | 98 | DeviceMessageCheck DeviceRequestChecks[] = { | 
| Diletant | 54:d94145ba23f4 | 99 | {DMID_DeviceMode, 6, 3, DeviceModeRequestCheck} | 
| Diletant | 54:d94145ba23f4 | 100 | }; | 
| Diletant | 54:d94145ba23f4 | 101 | |
| Diletant | 54:d94145ba23f4 | 102 | DeviceMessageCheck DeviceResponseChecks[] = { | 
| Diletant | 54:d94145ba23f4 | 103 | {DMID_DeviceMode, 8, 2, DeviceModeResponseCheck} | 
| Diletant | 54:d94145ba23f4 | 104 | }; | 
| Diletant | 54:d94145ba23f4 | 105 | |
| Diletant | 54:d94145ba23f4 | 106 | int CheckRequest(char *s, int start, int end); | 
| Diletant | 54:d94145ba23f4 | 107 | |
| Diletant | 54:d94145ba23f4 | 108 | #endif /* __DEVICEPROTOCOL_H__ */ | 
