123

Dependencies:   mbed

Fork of LG by igor Apu

Device.h

Committer:
Diletant
Date:
2016-04-23
Revision:
137:14a0c452cf32
Parent:
82:82d7073d36ef
Child:
149:abbf7663d27d

File content as of revision 137:14a0c452cf32:

#ifndef __DEVICE_H__
#define __DEVICE_H__

#include "DeviceSettings.h"
#include "DeviceProtocol.h"
#include "DeviceTimers.h"
#include "DeviceUART.h"

typedef enum _DeviceLatchMode {
  DeviceLatch10kHz,   //internal latch  by pulses 10 kHz (power on default mode)
  DeviceLatchMeander, //internal latch by signed meander pulses (not used?)
  DeviceLatchRS422,   //external latch by RS422 request
  DeviceLatchPin      //external latch by hardware pin request
} DeviceLatchMode;

typedef enum _DeviceLatchFormat {
  DeviceLatchFormatDeltaPS,   //latch data in DELTA_PS response format
  DeviceLatchFormatDeltaBINS, //latch data in DELTA_BINS response format
  DeviceLatchFormatDeltaSF    //latch data in DELTA_SF response format
} DeviceLatchFormat;

typedef struct _DeviceLatchState {
  uint8_t ready;
  DeviceLatchMode mode;       //latch source
  DeviceLatchFormat format;   //data to latch
  uint8_t reset;              //set to reset counters on each latch (default), clear to keep (DELTA_SF)
} DeviceLatchState;

typedef enum _DeviceCountingSource {
  DeviceCountingSourceReference, //Accumulate pulses using reference +/- counters as source
  DeviceCountingSourceDither,     //Accumulate pulses using dither counters as source
} DeviceCountingSource;

typedef struct _DeviceCountersState {
  DeviceCountingSource source; //Pulses source: reference/dither
  uint8_t filter;              //Moving average filter switch: 0 - off/1 - on
} DeviceCountersState;

typedef struct _DevicePhotoDetectorState {
    
} DevicePhotoDetectorState;

typedef struct _DeviceLightUpState {
    
} DeviceLightUpState;

typedef struct _DeviceHFOState {
  uint8_t loop; //Output signal amplitude loop switch: 1 - on/0 - off
} DeviceHFOState;

typedef struct _DevicePLCSState {
  uint8_t loop;      //Path length control system loop switch: 1 - on/0 - off
  uint8_t modulator; //Path length control system modulator switch: 1 - on/0 - off
} DevicePLCSState;

typedef struct _DeviceDitherState {
  uint8_t outputFrequencyLoop; //Output signal amplitude loop switch: 1 - on/0 - off
  uint8_t oscillationFrequencyLoop; //Output signal amplitude loop switch: 1 - on/0 - off
} DeviceDitherState;

typedef struct _Host {
  DeviceUARTState port;
  DeviceProtocolDecoder decoder;
  DeviceProtocolEncoder encoder;
  DeviceRequest request;
  DeviceResponse response;
} Host;

typedef struct _Service {
  DeviceUARTState port;
} Service;

typedef struct _Device {
  //Settings
  DeviceSettings settings;
  //Communication
  Host host; //Host - data consumer
  Service service;
  //Counting
  DeviceLatchState latch;
  DeviceCountersState counters;
  //Units
  DevicePhotoDetectorState detector;
  DeviceLightUpState lightUp;
  //Regulators
  DeviceHFOState hfo;
  DevicePLCSState plcs;
  DeviceDitherState dither;
} Device;

void InitDevice(void);

typedef struct _HashParam {
  uint32_t hash;
  void * ref;
  uint32_t size;
} HashParam;

#define HASH_PARAM_COUNT 2

#endif  /* __DEVICE_H__ */