123

Dependencies:   mbed

Fork of LG by igor Apu

Device.h

Committer:
Diletant
Date:
2016-05-03
Revision:
149:abbf7663d27d
Parent:
137:14a0c452cf32
Child:
156:e68ee0bcdcda

File content as of revision 149:abbf7663d27d:

#ifndef __DEVICE_H__
#define __DEVICE_H__

//#define DEV_BOARD
#ifdef DEV_BOARD
#warning "Program config: development board!!!"
#endif

#include "LPC17xx.h"
#include "system_LPC17xx.h"
#include "DeviceFlash.h"
#include "DeviceSettings.h"
#include "DeviceProtocol.h"
#include "DeviceTimers.h"
#include "DeviceServicePort.h"
#include "DeviceHostPort.h"
#include "DeviceSSP.h"
#include "DeviceLightUp.h"
#include "DeviceDither.h"
#include "DevicePLCS.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 _DeviceHFOState {
  uint8_t loop; //Output signal amplitude loop switch: 1 - on/0 - off
} DeviceHFOState;

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

typedef struct _Service {
  DeviceUARTState port;
} Service;

typedef struct _Device {
  //Flash memory
  DeviceFlash flash;
  //Settings
  DeviceSettings settings;
  //Peripherals
  Host host;       //Host communication asynchronous serial port
  Service service; //Service communication asynchronous serial port
  DeviceSSP SSP;   //Synchronous serial port controller (in SPI mode)
  //Counting
  DeviceLatchState latch;
  DeviceCountersState counters;
  //Units
  DevicePhotoDetectorState detector;
  DeviceLightUp lightUp;
  DeviceDither dither;
  DevicePathLengthControlSystem plcs;
  //Regulators
  DeviceHFOState hfo;
} Device;

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

#define HASH_PARAM_COUNT 29

typedef struct _HashFunc {
  uint32_t hash;
  void * ref;
  uint32_t resultSize;
  uint32_t paramCount;
} HashFunc;

#define HASH_FUNC_COUNT 3

void InitDevice(void);
void StartDevice(void);

void InitAllWithDefaults(void);

#endif  /* __DEVICE_H__ */