123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Mon May 09 20:03:26 2016 +0000
Revision:
156:e68ee0bcdcda
Parent:
149:abbf7663d27d
Child:
161:efd949e8d536
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 149:abbf7663d27d 10 #include "system_LPC17xx.h"
Diletant 156:e68ee0bcdcda 11 #include "DeviceController.h"
Diletant 74:f4d9c3403578 12 #include "DeviceSettings.h"
Diletant 156:e68ee0bcdcda 13 #include "DeviceDAC.h"
Diletant 74:f4d9c3403578 14 #include "DeviceProtocol.h"
Diletant 156:e68ee0bcdcda 15 //#include "DeviceTimers.h"
Diletant 156:e68ee0bcdcda 16 //#include "DeviceServicePort.h"
Diletant 156:e68ee0bcdcda 17 //#include "DeviceHostPort.h"
Diletant 156:e68ee0bcdcda 18 #include "DeviceCounters.h"
Diletant 149:abbf7663d27d 19 #include "DeviceLightUp.h"
Diletant 156:e68ee0bcdcda 20 #include "DevicePhotoDetector.h"
Diletant 149:abbf7663d27d 21 #include "DeviceDither.h"
Diletant 149:abbf7663d27d 22 #include "DevicePLCS.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 82:82d7073d36ef 46 DeviceCountingSourceDither, //Accumulate pulses using dither counters as source
Diletant 82:82d7073d36ef 47 } DeviceCountingSource;
Diletant 82:82d7073d36ef 48
Diletant 77:8d582faecf6b 49 typedef struct _DeviceHFOState {
Diletant 82:82d7073d36ef 50 uint8_t loop; //Output signal amplitude loop switch: 1 - on/0 - off
Diletant 77:8d582faecf6b 51 } DeviceHFOState;
Diletant 77:8d582faecf6b 52
Diletant 156:e68ee0bcdcda 53 typedef struct _DeviceReceiverState {
Diletant 156:e68ee0bcdcda 54 } DeviceReceiverState;
Diletant 156:e68ee0bcdcda 55
Diletant 156:e68ee0bcdcda 56 typedef struct _DeviceTransmitterState {
Diletant 156:e68ee0bcdcda 57 uint8_t position; //Output buffer transmission position
Diletant 156:e68ee0bcdcda 58 } DeviceTransmitterState;
Diletant 156:e68ee0bcdcda 59
Diletant 137:14a0c452cf32 60 typedef struct _Host {
Diletant 156:e68ee0bcdcda 61 DeviceReceiverState receiver;
Diletant 156:e68ee0bcdcda 62 DeviceTransmitterState transmitter;
Diletant 137:14a0c452cf32 63 DeviceProtocolDecoder decoder;
Diletant 137:14a0c452cf32 64 DeviceProtocolEncoder encoder;
Diletant 137:14a0c452cf32 65 DeviceRequest request;
Diletant 137:14a0c452cf32 66 DeviceResponse response;
Diletant 137:14a0c452cf32 67 } Host;
Diletant 137:14a0c452cf32 68
Diletant 137:14a0c452cf32 69 typedef struct _Service {
Diletant 156:e68ee0bcdcda 70 char buffer[512];
Diletant 156:e68ee0bcdcda 71 DeviceReceiverState receiver;
Diletant 156:e68ee0bcdcda 72 DeviceTransmitterState transmitter;
Diletant 137:14a0c452cf32 73 } Service;
Diletant 137:14a0c452cf32 74
Diletant 156:e68ee0bcdcda 75 typedef struct _DeviceMeasurementCycle {
Diletant 156:e68ee0bcdcda 76 uint32_t length; //Measurement cycle length
Diletant 156:e68ee0bcdcda 77 uint32_t counter; //Measurement cycle counter
Diletant 156:e68ee0bcdcda 78 } DeviceMeasurementCycle;
Diletant 156:e68ee0bcdcda 79
Diletant 156:e68ee0bcdcda 80 typedef struct _DeviceRegularCycle {
Diletant 156:e68ee0bcdcda 81 uint32_t event1Hz;
Diletant 156:e68ee0bcdcda 82 uint32_t event500Hz;
Diletant 156:e68ee0bcdcda 83 uint32_t event1K;
Diletant 156:e68ee0bcdcda 84 uint32_t event10K;
Diletant 156:e68ee0bcdcda 85 uint32_t event100K;
Diletant 156:e68ee0bcdcda 86
Diletant 156:e68ee0bcdcda 87 uint32_t time100K;
Diletant 156:e68ee0bcdcda 88 uint32_t time10K;
Diletant 156:e68ee0bcdcda 89 uint32_t time1K;
Diletant 156:e68ee0bcdcda 90 uint32_t time500Hz;
Diletant 156:e68ee0bcdcda 91 uint32_t time1Hz;
Diletant 156:e68ee0bcdcda 92 } DeviceRegularCycle;
Diletant 156:e68ee0bcdcda 93
Diletant 156:e68ee0bcdcda 94 typedef struct _DeviceDitherRegulator {
Diletant 156:e68ee0bcdcda 95 uint8_t oscillationFrequencyLoop;
Diletant 156:e68ee0bcdcda 96 uint8_t outputFrequencyLoop;
Diletant 156:e68ee0bcdcda 97 } DeviceDitherRegulator;
Diletant 156:e68ee0bcdcda 98
Diletant 74:f4d9c3403578 99 typedef struct _Device {
Diletant 77:8d582faecf6b 100 //Settings
Diletant 74:f4d9c3403578 101 DeviceSettings settings;
Diletant 156:e68ee0bcdcda 102 //Measurement cycle
Diletant 156:e68ee0bcdcda 103 DeviceMeasurementCycle measurement;
Diletant 156:e68ee0bcdcda 104 //Control cycle
Diletant 156:e68ee0bcdcda 105 DeviceRegularCycle regular;
Diletant 156:e68ee0bcdcda 106 //Controller
Diletant 156:e68ee0bcdcda 107 DeviceController controller;
Diletant 149:abbf7663d27d 108 //Peripherals
Diletant 149:abbf7663d27d 109 Host host; //Host communication asynchronous serial port
Diletant 149:abbf7663d27d 110 Service service; //Service communication asynchronous serial port
Diletant 156:e68ee0bcdcda 111 DeviceDAC dac; //DAC of hfo & plcs
Diletant 77:8d582faecf6b 112 //Counting
Diletant 77:8d582faecf6b 113 DeviceLatchState latch;
Diletant 156:e68ee0bcdcda 114 DeviceCounters counters;
Diletant 137:14a0c452cf32 115 //Units
Diletant 156:e68ee0bcdcda 116 DevicePhotoDetector detector;
Diletant 149:abbf7663d27d 117 DeviceLightUp lightUp;
Diletant 149:abbf7663d27d 118 DeviceDither dither;
Diletant 149:abbf7663d27d 119 DevicePathLengthControlSystem plcs;
Diletant 137:14a0c452cf32 120 //Regulators
Diletant 77:8d582faecf6b 121 DeviceHFOState hfo;
Diletant 156:e68ee0bcdcda 122 DeviceDitherRegulator ditherRegulator;
Diletant 74:f4d9c3403578 123 } Device;
Diletant 74:f4d9c3403578 124
Diletant 137:14a0c452cf32 125 typedef struct _HashParam {
Diletant 137:14a0c452cf32 126 uint32_t hash;
Diletant 137:14a0c452cf32 127 void * ref;
Diletant 137:14a0c452cf32 128 uint32_t size;
Diletant 137:14a0c452cf32 129 } HashParam;
Diletant 137:14a0c452cf32 130
Diletant 149:abbf7663d27d 131 #define HASH_PARAM_COUNT 29
Diletant 149:abbf7663d27d 132
Diletant 149:abbf7663d27d 133 typedef struct _HashFunc {
Diletant 149:abbf7663d27d 134 uint32_t hash;
Diletant 149:abbf7663d27d 135 void * ref;
Diletant 149:abbf7663d27d 136 uint32_t resultSize;
Diletant 149:abbf7663d27d 137 uint32_t paramCount;
Diletant 149:abbf7663d27d 138 } HashFunc;
Diletant 149:abbf7663d27d 139
Diletant 149:abbf7663d27d 140 #define HASH_FUNC_COUNT 3
Diletant 149:abbf7663d27d 141
Diletant 149:abbf7663d27d 142 void InitDevice(void);
Diletant 156:e68ee0bcdcda 143 void DeviceStart(void);
Diletant 156:e68ee0bcdcda 144
Diletant 156:e68ee0bcdcda 145 void DeviceInitAllWithDefaults(void);
Diletant 156:e68ee0bcdcda 146 void DeviceInitAll(void);
Diletant 149:abbf7663d27d 147
Diletant 156:e68ee0bcdcda 148 void DeviceRegularEvent1Hz(void);
Diletant 156:e68ee0bcdcda 149 void DeviceRegularEvent500Hz(void);
Diletant 156:e68ee0bcdcda 150 void DeviceRegularEvent1KHz(void);
Diletant 156:e68ee0bcdcda 151 void DeviceRegularEvent10KHz(void);
Diletant 156:e68ee0bcdcda 152 void DeviceRegularEvent100KHz(void);
Diletant 137:14a0c452cf32 153
Diletant 156:e68ee0bcdcda 154 void DeviceMeasurementInterruptHandler(void);
Diletant 156:e68ee0bcdcda 155 void DeviceRegularInterruptHandler(void);
Diletant 74:f4d9c3403578 156 #endif /* __DEVICE_H__ */