123

Dependencies:   mbed

Fork of LG by igor Apu

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