123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Sat Apr 23 15:00:20 2016 +0000
Revision:
137:14a0c452cf32
Parent:
82:82d7073d36ef
Child:
149:abbf7663d27d
Device&Settings&Protocol&UART&Timers update. Not final!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Diletant 74:f4d9c3403578 1 #ifndef __DEVICE_H__
Diletant 74:f4d9c3403578 2 #define __DEVICE_H__
Diletant 74:f4d9c3403578 3
Diletant 74:f4d9c3403578 4 #include "DeviceSettings.h"
Diletant 74:f4d9c3403578 5 #include "DeviceProtocol.h"
Diletant 137:14a0c452cf32 6 #include "DeviceTimers.h"
Diletant 78:0ea9d02b7b46 7 #include "DeviceUART.h"
Diletant 74:f4d9c3403578 8
Diletant 74:f4d9c3403578 9 typedef enum _DeviceLatchMode {
Diletant 82:82d7073d36ef 10 DeviceLatch10kHz, //internal latch by pulses 10 kHz (power on default mode)
Diletant 82:82d7073d36ef 11 DeviceLatchMeander, //internal latch by signed meander pulses (not used?)
Diletant 82:82d7073d36ef 12 DeviceLatchRS422, //external latch by RS422 request
Diletant 82:82d7073d36ef 13 DeviceLatchPin //external latch by hardware pin request
Diletant 74:f4d9c3403578 14 } DeviceLatchMode;
Diletant 74:f4d9c3403578 15
Diletant 77:8d582faecf6b 16 typedef enum _DeviceLatchFormat {
Diletant 82:82d7073d36ef 17 DeviceLatchFormatDeltaPS, //latch data in DELTA_PS response format
Diletant 82:82d7073d36ef 18 DeviceLatchFormatDeltaBINS, //latch data in DELTA_BINS response format
Diletant 82:82d7073d36ef 19 DeviceLatchFormatDeltaSF //latch data in DELTA_SF response format
Diletant 77:8d582faecf6b 20 } DeviceLatchFormat;
Diletant 74:f4d9c3403578 21
Diletant 74:f4d9c3403578 22 typedef struct _DeviceLatchState {
Diletant 82:82d7073d36ef 23 uint8_t ready;
Diletant 82:82d7073d36ef 24 DeviceLatchMode mode; //latch source
Diletant 82:82d7073d36ef 25 DeviceLatchFormat format; //data to latch
Diletant 82:82d7073d36ef 26 uint8_t reset; //set to reset counters on each latch (default), clear to keep (DELTA_SF)
Diletant 74:f4d9c3403578 27 } DeviceLatchState;
Diletant 74:f4d9c3403578 28
Diletant 82:82d7073d36ef 29 typedef enum _DeviceCountingSource {
Diletant 82:82d7073d36ef 30 DeviceCountingSourceReference, //Accumulate pulses using reference +/- counters as source
Diletant 82:82d7073d36ef 31 DeviceCountingSourceDither, //Accumulate pulses using dither counters as source
Diletant 82:82d7073d36ef 32 } DeviceCountingSource;
Diletant 82:82d7073d36ef 33
Diletant 74:f4d9c3403578 34 typedef struct _DeviceCountersState {
Diletant 82:82d7073d36ef 35 DeviceCountingSource source; //Pulses source: reference/dither
Diletant 82:82d7073d36ef 36 uint8_t filter; //Moving average filter switch: 0 - off/1 - on
Diletant 74:f4d9c3403578 37 } DeviceCountersState;
Diletant 74:f4d9c3403578 38
Diletant 77:8d582faecf6b 39 typedef struct _DevicePhotoDetectorState {
Diletant 77:8d582faecf6b 40
Diletant 77:8d582faecf6b 41 } DevicePhotoDetectorState;
Diletant 77:8d582faecf6b 42
Diletant 77:8d582faecf6b 43 typedef struct _DeviceLightUpState {
Diletant 77:8d582faecf6b 44
Diletant 77:8d582faecf6b 45 } DeviceLightUpState;
Diletant 77:8d582faecf6b 46
Diletant 77:8d582faecf6b 47 typedef struct _DeviceHFOState {
Diletant 82:82d7073d36ef 48 uint8_t loop; //Output signal amplitude loop switch: 1 - on/0 - off
Diletant 77:8d582faecf6b 49 } DeviceHFOState;
Diletant 77:8d582faecf6b 50
Diletant 77:8d582faecf6b 51 typedef struct _DevicePLCSState {
Diletant 82:82d7073d36ef 52 uint8_t loop; //Path length control system loop switch: 1 - on/0 - off
Diletant 82:82d7073d36ef 53 uint8_t modulator; //Path length control system modulator switch: 1 - on/0 - off
Diletant 77:8d582faecf6b 54 } DevicePLCSState;
Diletant 77:8d582faecf6b 55
Diletant 77:8d582faecf6b 56 typedef struct _DeviceDitherState {
Diletant 82:82d7073d36ef 57 uint8_t outputFrequencyLoop; //Output signal amplitude loop switch: 1 - on/0 - off
Diletant 82:82d7073d36ef 58 uint8_t oscillationFrequencyLoop; //Output signal amplitude loop switch: 1 - on/0 - off
Diletant 77:8d582faecf6b 59 } DeviceDitherState;
Diletant 77:8d582faecf6b 60
Diletant 137:14a0c452cf32 61 typedef struct _Host {
Diletant 137:14a0c452cf32 62 DeviceUARTState port;
Diletant 137:14a0c452cf32 63 DeviceProtocolDecoder decoder;
Diletant 137:14a0c452cf32 64 DeviceProtocolEncoder encoder;
Diletant 137:14a0c452cf32 65 DeviceRequest request;
Diletant 137:14a0c452cf32 66 DeviceResponse response;
Diletant 137:14a0c452cf32 67 } Host;
Diletant 137:14a0c452cf32 68
Diletant 137:14a0c452cf32 69 typedef struct _Service {
Diletant 137:14a0c452cf32 70 DeviceUARTState port;
Diletant 137:14a0c452cf32 71 } Service;
Diletant 137:14a0c452cf32 72
Diletant 74:f4d9c3403578 73 typedef struct _Device {
Diletant 77:8d582faecf6b 74 //Settings
Diletant 74:f4d9c3403578 75 DeviceSettings settings;
Diletant 77:8d582faecf6b 76 //Communication
Diletant 137:14a0c452cf32 77 Host host; //Host - data consumer
Diletant 137:14a0c452cf32 78 Service service;
Diletant 77:8d582faecf6b 79 //Counting
Diletant 77:8d582faecf6b 80 DeviceLatchState latch;
Diletant 74:f4d9c3403578 81 DeviceCountersState counters;
Diletant 137:14a0c452cf32 82 //Units
Diletant 77:8d582faecf6b 83 DevicePhotoDetectorState detector;
Diletant 77:8d582faecf6b 84 DeviceLightUpState lightUp;
Diletant 137:14a0c452cf32 85 //Regulators
Diletant 77:8d582faecf6b 86 DeviceHFOState hfo;
Diletant 77:8d582faecf6b 87 DevicePLCSState plcs;
Diletant 77:8d582faecf6b 88 DeviceDitherState dither;
Diletant 74:f4d9c3403578 89 } Device;
Diletant 74:f4d9c3403578 90
Diletant 137:14a0c452cf32 91 void InitDevice(void);
Diletant 137:14a0c452cf32 92
Diletant 137:14a0c452cf32 93 typedef struct _HashParam {
Diletant 137:14a0c452cf32 94 uint32_t hash;
Diletant 137:14a0c452cf32 95 void * ref;
Diletant 137:14a0c452cf32 96 uint32_t size;
Diletant 137:14a0c452cf32 97 } HashParam;
Diletant 137:14a0c452cf32 98
Diletant 137:14a0c452cf32 99 #define HASH_PARAM_COUNT 2
Diletant 137:14a0c452cf32 100
Diletant 74:f4d9c3403578 101 #endif /* __DEVICE_H__ */