123

Dependencies:   mbed

Fork of LG by igor Apu

Device.h

Committer:
Diletant
Date:
2016-07-10
Revision:
182:2bd8ec44998f
Parent:
177:672ef279c8e0
Child:
183:c7a9c309086c

File content as of revision 182:2bd8ec44998f:

#ifndef __DEVICE_H__
#define __DEVICE_H__

#include "LPC17xx.h"
//#include "system_LPC17xx.h"
#include "DeviceController.h"
//#include "DeviceDAC.h"
#include "DeviceUser.h"
#include "DeviceCounters.h"
#include "DeviceDither.h"
#include "DeviceLightUp.h"
#include "DeviceISACS.h"
#include "DeviceSequencer.h"
#include "DevicePLCS.h"
#include "DeviceTSS.h"
#include "DeviceCCS.h"
#include "DeviceErrorModel.h"
//#include "DeviceDebug.h"

//Device service communication interface typedefs
typedef struct _DeviceService {
  char buffer[512];
  uint16_t position; //Transmission position
  DeviceServicePort port;
} DeviceService;

//Device measurement cycle typedefs
typedef struct _DeviceMeasurementCycle {
  uint32_t length;  //Measurement cycle length
  uint32_t counter; //Measurement cycle counter
} DeviceMeasurementCycle;

//Device regular cycle typedefs
typedef struct _DeviceRegularCycle {
  volatile uint32_t event1Hz;
  volatile uint32_t event500Hz;
  volatile uint32_t event1K;
  volatile uint32_t event10K;
  volatile uint32_t event100K;

  volatile uint32_t time100K;
  volatile uint32_t time10K;
  volatile uint32_t time1K;
  volatile uint32_t time500Hz;
  volatile uint32_t time1Hz;
} DeviceRegularCycle;

//Device sensor typedefs
typedef struct _DeviceSensorSettings {
  //Device ID
  uint16_t id;
  //Block ID
  uint16_t block;
} DeviceSensorSettings;

typedef struct _DeviceSensorState {
} DeviceSensorState;

typedef struct _DeviceSensor {
  DeviceSensorSettings settings;
  DeviceSensorState state;
} DeviceSensor;

//Device typedefs
typedef struct _Device {
  //Measurement cycle
  DeviceMeasurementCycle measurement;
  //Control cycle
  DeviceRegularCycle regular;
  //Counters
  DeviceCounters counters;
  //Controller
  DeviceController controller;
  //Interfaces
  DeviceService service;      //Service communication interface - asynchronous serial port 0
  DeviceUser user;            //User communication interface - asynchronous serial port 1
  //Units
  DeviceSensor sensor;        //Sensor info
  DeviceLightUp lightUp;      //Light-up system
  DeviceDither dither;        //Dither system
  DeviceISACS isacs;          //Information signal amplitude stabilizer
  DeviceSequencer sequencer;  //Sequencer
  DevicePathLengthControlSystem plcs; //Path length control system
  DeviceTSS tss;              //Temperature sense system
  DeviceCCS ccs;              //Current control system
  DeviceEM em;                //Error model
  #ifdef __DEVICE_DEBUG_H__
  DeviceDebug debug;
  #endif
} Device;

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

#define HASH_PARAM_COUNT 886

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

#define HASH_FUNC_COUNT 3

void DeviceInitDefaultSettings(void);
void DeviceInitState(void);

void DeviceInit(void);
void DeviceStart(void);

void InitHashParamTable(void);
void InitHashFuncTable(void);

void DeviceRegularEvent1Hz(void);
void DeviceRegularEvent500Hz(void);
void DeviceRegularEvent1KHz(void);
void DeviceRegularEvent10KHz(void);
void DeviceRegularEvent100KHz(void);
void DeviceMeasurementInterruptHandler(void);
void DeviceRegularInterruptHandler(void);

#endif  /* __DEVICE_H__ */