123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Sun Jul 03 13:40:48 2016 +0000
Revision:
177:672ef279c8e0
Parent:
174:0f86eedd511c
Child:
182:2bd8ec44998f
Device&... update. Some Ask_Gld functionality. 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 149:abbf7663d27d 4 #include "LPC17xx.h"
Diletant 173:7f938afb0447 5 //#include "system_LPC17xx.h"
Diletant 156:e68ee0bcdcda 6 #include "DeviceController.h"
Diletant 166:c3c0b8a90d81 7 //#include "DeviceDAC.h"
Diletant 161:efd949e8d536 8 #include "DeviceUserProtocol.h"
Diletant 156:e68ee0bcdcda 9 #include "DeviceCounters.h"
Diletant 161:efd949e8d536 10 #include "DeviceDither.h"
Diletant 149:abbf7663d27d 11 #include "DeviceLightUp.h"
Diletant 161:efd949e8d536 12 #include "DeviceISACS.h"
Diletant 173:7f938afb0447 13 #include "DeviceSequencer.h"
Diletant 149:abbf7663d27d 14 #include "DevicePLCS.h"
Diletant 174:0f86eedd511c 15 #include "DeviceTSS.h"
Diletant 174:0f86eedd511c 16 #include "DeviceCCS.h"
Diletant 174:0f86eedd511c 17 #include "DeviceErrorModel.h"
Diletant 177:672ef279c8e0 18 //#include "DeviceDebug.h"
Diletant 74:f4d9c3403578 19
Diletant 74:f4d9c3403578 20 typedef enum _DeviceLatchMode {
Diletant 82:82d7073d36ef 21 DeviceLatch10kHz, //internal latch by pulses 10 kHz (power on default mode)
Diletant 82:82d7073d36ef 22 DeviceLatchMeander, //internal latch by signed meander pulses (not used?)
Diletant 82:82d7073d36ef 23 DeviceLatchRS422, //external latch by RS422 request
Diletant 82:82d7073d36ef 24 DeviceLatchPin //external latch by hardware pin request
Diletant 74:f4d9c3403578 25 } DeviceLatchMode;
Diletant 74:f4d9c3403578 26
Diletant 77:8d582faecf6b 27 typedef enum _DeviceLatchFormat {
Diletant 82:82d7073d36ef 28 DeviceLatchFormatDeltaPS, //latch data in DELTA_PS response format
Diletant 82:82d7073d36ef 29 DeviceLatchFormatDeltaBINS, //latch data in DELTA_BINS response format
Diletant 82:82d7073d36ef 30 DeviceLatchFormatDeltaSF //latch data in DELTA_SF response format
Diletant 77:8d582faecf6b 31 } DeviceLatchFormat;
Diletant 74:f4d9c3403578 32
Diletant 74:f4d9c3403578 33 typedef struct _DeviceLatchState {
Diletant 82:82d7073d36ef 34 uint8_t ready;
Diletant 82:82d7073d36ef 35 DeviceLatchMode mode; //latch source
Diletant 82:82d7073d36ef 36 DeviceLatchFormat format; //data to latch
Diletant 82:82d7073d36ef 37 uint8_t reset; //set to reset counters on each latch (default), clear to keep (DELTA_SF)
Diletant 74:f4d9c3403578 38 } DeviceLatchState;
Diletant 74:f4d9c3403578 39
Diletant 82:82d7073d36ef 40 typedef enum _DeviceCountingSource {
Diletant 82:82d7073d36ef 41 DeviceCountingSourceReference, //Accumulate pulses using reference +/- counters as source
Diletant 161:efd949e8d536 42 DeviceCountingSourceDither, //Accumulate pulses using dither counters as source
Diletant 82:82d7073d36ef 43 } DeviceCountingSource;
Diletant 82:82d7073d36ef 44
Diletant 161:efd949e8d536 45 //Device service communication typedefs
Diletant 137:14a0c452cf32 46 typedef struct _Service {
Diletant 156:e68ee0bcdcda 47 char buffer[512];
Diletant 161:efd949e8d536 48 uint16_t position; //Transmission position
Diletant 137:14a0c452cf32 49 } Service;
Diletant 137:14a0c452cf32 50
Diletant 161:efd949e8d536 51 //Device measurement cycle typedefs
Diletant 156:e68ee0bcdcda 52 typedef struct _DeviceMeasurementCycle {
Diletant 156:e68ee0bcdcda 53 uint32_t length; //Measurement cycle length
Diletant 156:e68ee0bcdcda 54 uint32_t counter; //Measurement cycle counter
Diletant 156:e68ee0bcdcda 55 } DeviceMeasurementCycle;
Diletant 156:e68ee0bcdcda 56
Diletant 161:efd949e8d536 57 //Device regular cycle typedefs
Diletant 156:e68ee0bcdcda 58 typedef struct _DeviceRegularCycle {
Diletant 161:efd949e8d536 59 volatile uint32_t event1Hz;
Diletant 161:efd949e8d536 60 volatile uint32_t event500Hz;
Diletant 161:efd949e8d536 61 volatile uint32_t event1K;
Diletant 161:efd949e8d536 62 volatile uint32_t event10K;
Diletant 161:efd949e8d536 63 volatile uint32_t event100K;
Diletant 156:e68ee0bcdcda 64
Diletant 161:efd949e8d536 65 volatile uint32_t time100K;
Diletant 161:efd949e8d536 66 volatile uint32_t time10K;
Diletant 161:efd949e8d536 67 volatile uint32_t time1K;
Diletant 161:efd949e8d536 68 volatile uint32_t time500Hz;
Diletant 161:efd949e8d536 69 volatile uint32_t time1Hz;
Diletant 156:e68ee0bcdcda 70 } DeviceRegularCycle;
Diletant 156:e68ee0bcdcda 71
Diletant 161:efd949e8d536 72 //Device sensor typedefs
Diletant 161:efd949e8d536 73 typedef struct _DeviceSensorSettings {
Diletant 161:efd949e8d536 74 //Device ID
Diletant 161:efd949e8d536 75 uint16_t id;
Diletant 161:efd949e8d536 76 //Block ID
Diletant 161:efd949e8d536 77 uint16_t block;
Diletant 161:efd949e8d536 78 } DeviceSensorSettings;
Diletant 156:e68ee0bcdcda 79
Diletant 161:efd949e8d536 80 typedef struct _DeviceSensorState {
Diletant 161:efd949e8d536 81 } DeviceSensorState;
Diletant 161:efd949e8d536 82
Diletant 161:efd949e8d536 83 typedef struct _DeviceSensor {
Diletant 161:efd949e8d536 84 DeviceSensorSettings settings;
Diletant 161:efd949e8d536 85 DeviceSensorState state;
Diletant 161:efd949e8d536 86 } DeviceSensor;
Diletant 161:efd949e8d536 87
Diletant 161:efd949e8d536 88 //Device typedefs
Diletant 74:f4d9c3403578 89 typedef struct _Device {
Diletant 156:e68ee0bcdcda 90 //Measurement cycle
Diletant 156:e68ee0bcdcda 91 DeviceMeasurementCycle measurement;
Diletant 156:e68ee0bcdcda 92 //Control cycle
Diletant 156:e68ee0bcdcda 93 DeviceRegularCycle regular;
Diletant 77:8d582faecf6b 94 //Counting
Diletant 177:672ef279c8e0 95 //DeviceLatchState latch;
Diletant 156:e68ee0bcdcda 96 DeviceCounters counters;
Diletant 161:efd949e8d536 97 //Controller
Diletant 161:efd949e8d536 98 DeviceController controller;
Diletant 161:efd949e8d536 99 //Protocols
Diletant 174:0f86eedd511c 100 Service service; //Service communication protocol - asynchronous serial port 0
Diletant 174:0f86eedd511c 101 DeviceUserProtocol user; //User communication protocol - asynchronous serial port 1
Diletant 137:14a0c452cf32 102 //Units
Diletant 174:0f86eedd511c 103 DeviceSensor sensor; //Sensor info
Diletant 174:0f86eedd511c 104 DeviceLightUp lightUp; //Light-up system
Diletant 174:0f86eedd511c 105 DeviceDither dither; //Dither system
Diletant 174:0f86eedd511c 106 DeviceISACS isacs; //Information signal amplitude stabilizer
Diletant 174:0f86eedd511c 107 DeviceSequencer sequencer; //Sequencer
Diletant 161:efd949e8d536 108 DevicePathLengthControlSystem plcs; //Path length control system
Diletant 174:0f86eedd511c 109 DeviceTSS tss; //Temperature sense system
Diletant 174:0f86eedd511c 110 DeviceCCS ccs; //Current control system
Diletant 174:0f86eedd511c 111 DeviceEM em; //Error model
Diletant 177:672ef279c8e0 112 #ifdef __DEVICE_DEBUG_H__
Diletant 177:672ef279c8e0 113 DeviceDebug debug;
Diletant 177:672ef279c8e0 114 #endif
Diletant 74:f4d9c3403578 115 } Device;
Diletant 74:f4d9c3403578 116
Diletant 137:14a0c452cf32 117 typedef struct _HashParam {
Diletant 137:14a0c452cf32 118 uint32_t hash;
Diletant 137:14a0c452cf32 119 void * ref;
Diletant 137:14a0c452cf32 120 uint32_t size;
Diletant 137:14a0c452cf32 121 } HashParam;
Diletant 137:14a0c452cf32 122
Diletant 177:672ef279c8e0 123 #define HASH_PARAM_COUNT 884
Diletant 149:abbf7663d27d 124
Diletant 149:abbf7663d27d 125 typedef struct _HashFunc {
Diletant 149:abbf7663d27d 126 uint32_t hash;
Diletant 149:abbf7663d27d 127 void * ref;
Diletant 149:abbf7663d27d 128 uint32_t resultSize;
Diletant 149:abbf7663d27d 129 uint32_t paramCount;
Diletant 149:abbf7663d27d 130 } HashFunc;
Diletant 149:abbf7663d27d 131
Diletant 149:abbf7663d27d 132 #define HASH_FUNC_COUNT 3
Diletant 149:abbf7663d27d 133
Diletant 167:bedc0a9d559a 134 void DeviceInitDefaultSettings(void);
Diletant 167:bedc0a9d559a 135 void DeviceInitState(void);
Diletant 167:bedc0a9d559a 136
Diletant 173:7f938afb0447 137 void DeviceInit(void);
Diletant 173:7f938afb0447 138 void DeviceStart(void);
Diletant 173:7f938afb0447 139
Diletant 161:efd949e8d536 140 void InitHashParamTable(void);
Diletant 166:c3c0b8a90d81 141 void InitHashFuncTable(void);
Diletant 149:abbf7663d27d 142
Diletant 156:e68ee0bcdcda 143 void DeviceRegularEvent1Hz(void);
Diletant 156:e68ee0bcdcda 144 void DeviceRegularEvent500Hz(void);
Diletant 156:e68ee0bcdcda 145 void DeviceRegularEvent1KHz(void);
Diletant 156:e68ee0bcdcda 146 void DeviceRegularEvent10KHz(void);
Diletant 156:e68ee0bcdcda 147 void DeviceRegularEvent100KHz(void);
Diletant 156:e68ee0bcdcda 148 void DeviceMeasurementInterruptHandler(void);
Diletant 156:e68ee0bcdcda 149 void DeviceRegularInterruptHandler(void);
Diletant 173:7f938afb0447 150
Diletant 74:f4d9c3403578 151 #endif /* __DEVICE_H__ */