123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Sun Jun 05 11:03:33 2016 +0000
Revision:
167:bedc0a9d559a
Parent:
161:efd949e8d536
Child:
173:7f938afb0447
Device & ... update. Not final!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Diletant 149:abbf7663d27d 1 #ifndef __DEVICE_DITHER_H__
Diletant 149:abbf7663d27d 2 #define __DEVICE_DITHER_H__
Diletant 149:abbf7663d27d 3
Diletant 161:efd949e8d536 4 //Dither drive pulse typedefs
Diletant 161:efd949e8d536 5 typedef struct _DeviceDitherPulseSettings {
Diletant 161:efd949e8d536 6 uint32_t rise; //rising edge position in 10 mks resolution ticks
Diletant 161:efd949e8d536 7 uint32_t fall; //falling edge position in 10 mks resolution ticks
Diletant 161:efd949e8d536 8 } DeviceDitherPulseSettings;
Diletant 149:abbf7663d27d 9
Diletant 161:efd949e8d536 10 typedef struct _DeviceDitherPulseState {
Diletant 156:e68ee0bcdcda 11 uint32_t rise; //rising edge position in 10 mks resolution ticks
Diletant 156:e68ee0bcdcda 12 uint32_t fall; //falling edge position in 10 mks resolution ticks
Diletant 161:efd949e8d536 13 uint32_t counter; //10 mks resolution counter, zeroed at each dither half period
Diletant 161:efd949e8d536 14 } DeviceDitherPulseState;
Diletant 161:efd949e8d536 15
Diletant 161:efd949e8d536 16 typedef struct _DeviceDitherPulse {
Diletant 161:efd949e8d536 17 DeviceDitherPulseSettings settings;
Diletant 161:efd949e8d536 18 DeviceDitherPulseState state;
Diletant 161:efd949e8d536 19 } DeviceDitherPulse;
Diletant 161:efd949e8d536 20
Diletant 161:efd949e8d536 21 //Dither noise typedefs
Diletant 161:efd949e8d536 22 typedef struct _DeviceDitherNoiseSettings {
Diletant 161:efd949e8d536 23 uint8_t enabled;
Diletant 161:efd949e8d536 24 uint32_t period; //noise period in mks
Diletant 161:efd949e8d536 25 uint32_t range; //noise range (format?)
Diletant 161:efd949e8d536 26 uint32_t phase; //adjusted noise constant (format?)
Diletant 161:efd949e8d536 27 } DeviceDitherNoiseSettings;
Diletant 161:efd949e8d536 28
Diletant 161:efd949e8d536 29 typedef struct _DeviceDitherNoiseState {
Diletant 161:efd949e8d536 30 uint8_t enabled;
Diletant 161:efd949e8d536 31 } DeviceDitherNoiseState;
Diletant 161:efd949e8d536 32
Diletant 161:efd949e8d536 33 typedef struct _DeviceDitherNoise {
Diletant 161:efd949e8d536 34 DeviceDitherNoiseSettings settings;
Diletant 161:efd949e8d536 35 DeviceDitherNoiseState state;
Diletant 161:efd949e8d536 36 } DeviceDitherNoise;
Diletant 161:efd949e8d536 37
Diletant 161:efd949e8d536 38 //Dither oscillation frequency regulator typedefs
Diletant 161:efd949e8d536 39 typedef struct _DeviceDitherOscillationFrequencyRegulatorSettings {
Diletant 161:efd949e8d536 40 uint8_t enabled;
Diletant 161:efd949e8d536 41 uint32_t reference; //signed 16.16 format reference oscillation frequency
Diletant 161:efd949e8d536 42 uint32_t scale; //signed 16.16 format regulator scale factor
Diletant 161:efd949e8d536 43 } DeviceDitherOscillationFrequencyRegulatorSettings;
Diletant 161:efd949e8d536 44
Diletant 161:efd949e8d536 45 typedef struct _DeviceDitherOscillationFrequencyRegulatorState {
Diletant 161:efd949e8d536 46 uint8_t enabled;
Diletant 161:efd949e8d536 47 uint32_t reference; //signed 16.16 format reference oscillation frequency
Diletant 161:efd949e8d536 48 uint32_t scale; //signed 16.16 format regulator scale factor
Diletant 161:efd949e8d536 49 uint32_t error; //signed 16.16 format regulator error
Diletant 161:efd949e8d536 50 } DeviceDitherOscillationFrequencyRegulatorState;
Diletant 161:efd949e8d536 51
Diletant 161:efd949e8d536 52 typedef struct _DeviceDitherOscillationFrequencyRegulator {
Diletant 161:efd949e8d536 53 DeviceDitherOscillationFrequencyRegulatorSettings settings;
Diletant 161:efd949e8d536 54 DeviceDitherOscillationFrequencyRegulatorState state;
Diletant 161:efd949e8d536 55 } DeviceDitherOscillationFrequencyRegulator;
Diletant 161:efd949e8d536 56
Diletant 161:efd949e8d536 57 //Dither information signal carrier frequency regulator typedefs
Diletant 161:efd949e8d536 58 typedef struct _DeviceDitherCarrierFrequencyRegulatorSettings {
Diletant 161:efd949e8d536 59 uint8_t enabled;
Diletant 161:efd949e8d536 60 uint32_t reference; //signed 16.16 format reference information signal carrier frequency
Diletant 161:efd949e8d536 61 uint32_t scale; //signed 16.16 format regulator scale factor
Diletant 161:efd949e8d536 62 } DeviceDitherCarrierFrequencyRegulatorSettings;
Diletant 161:efd949e8d536 63
Diletant 161:efd949e8d536 64 typedef struct _DeviceDitherCarrierFrequencyRegulatorState {
Diletant 161:efd949e8d536 65 uint8_t enabled;
Diletant 161:efd949e8d536 66 uint32_t reference; //signed 16.16 format reference information signal carrier frequency
Diletant 161:efd949e8d536 67 uint32_t scale; //signed 16.16 format regulator scale factor
Diletant 161:efd949e8d536 68 uint32_t error; //signed 16.16 format regulator error
Diletant 161:efd949e8d536 69 } DeviceDitherCarrierFrequencyRegulatorState;
Diletant 161:efd949e8d536 70
Diletant 161:efd949e8d536 71 typedef struct _DeviceDitherCarrierFrequencyRegulator {
Diletant 161:efd949e8d536 72 DeviceDitherOscillationFrequencyRegulatorSettings settings;
Diletant 161:efd949e8d536 73 DeviceDitherOscillationFrequencyRegulatorState state;
Diletant 161:efd949e8d536 74 } DeviceDitherCarrierFrequencyRegulator;
Diletant 161:efd949e8d536 75
Diletant 161:efd949e8d536 76 //Dither cycle typedefs
Diletant 161:efd949e8d536 77 typedef struct _DeviceDitherCycleSettings {
Diletant 161:efd949e8d536 78 uint8_t enabled;
Diletant 161:efd949e8d536 79 } DeviceDitherCycleSettings;
Diletant 161:efd949e8d536 80
Diletant 161:efd949e8d536 81 typedef struct _DeviceDitherCycleState {
Diletant 156:e68ee0bcdcda 82 uint8_t enabled; //dither on/off
Diletant 156:e68ee0bcdcda 83 uint8_t pin1; //pin 1 state
Diletant 156:e68ee0bcdcda 84 uint8_t pin2; //pin 2 state
Diletant 161:efd949e8d536 85 } DeviceDitherCycleState;
Diletant 161:efd949e8d536 86
Diletant 161:efd949e8d536 87 typedef struct _DeviceDitherCycle {
Diletant 161:efd949e8d536 88 DeviceDitherCycleSettings settings;
Diletant 161:efd949e8d536 89 DeviceDitherCycleState state;
Diletant 161:efd949e8d536 90 } DeviceDitherCycle;
Diletant 149:abbf7663d27d 91
Diletant 161:efd949e8d536 92 //Dither phase detector typedefs
Diletant 161:efd949e8d536 93 //error = sum(weight[i + offset] * device.counters.state.delta[i])
Diletant 161:efd949e8d536 94 typedef struct _DeviceDitherPhaseDetectorSettings {
Diletant 167:bedc0a9d559a 95 int16_t weight[32]; //0...255 weight factors
Diletant 161:efd949e8d536 96 uint8_t offset; //0...31 start position
Diletant 161:efd949e8d536 97 } DeviceDitherPhaseDetectorSettings;
Diletant 161:efd949e8d536 98
Diletant 161:efd949e8d536 99 typedef struct _DeviceDitherPhaseDetectorState {
Diletant 161:efd949e8d536 100 int32_t error;
Diletant 161:efd949e8d536 101 } DeviceDitherPhaseDetectorState;
Diletant 161:efd949e8d536 102
Diletant 161:efd949e8d536 103 typedef struct _DeviceDitherPhaseDetector {
Diletant 161:efd949e8d536 104 DeviceDitherPhaseDetectorSettings settings;
Diletant 161:efd949e8d536 105 DeviceDitherPhaseDetectorState state;
Diletant 161:efd949e8d536 106 } DeviceDitherPhaseDetector;
Diletant 161:efd949e8d536 107
Diletant 161:efd949e8d536 108 //Dither drive typedefs
Diletant 149:abbf7663d27d 109 typedef struct _DeviceDither {
Diletant 161:efd949e8d536 110 DeviceDitherPulse pulse;
Diletant 161:efd949e8d536 111 DeviceDitherNoise noise;
Diletant 161:efd949e8d536 112 DeviceDitherCycle cycle;
Diletant 161:efd949e8d536 113 DeviceDitherPhaseDetector detector;
Diletant 161:efd949e8d536 114 DeviceDitherOscillationFrequencyRegulator oscillation;
Diletant 161:efd949e8d536 115 DeviceDitherCarrierFrequencyRegulator carrier;
Diletant 149:abbf7663d27d 116 } DeviceDither;
Diletant 149:abbf7663d27d 117
Diletant 167:bedc0a9d559a 118 void InitDitherDefaultSettings(void);
Diletant 167:bedc0a9d559a 119 void InitDitherState(void);
Diletant 167:bedc0a9d559a 120 void DeviceStartDither(void);
Diletant 167:bedc0a9d559a 121
Diletant 156:e68ee0bcdcda 122 void DeviceStartDither(void);
Diletant 161:efd949e8d536 123 void DeviceDitherDoCycle(void);
Diletant 161:efd949e8d536 124
Diletant 161:efd949e8d536 125 void DeviceDitherDetectPhase(void);
Diletant 149:abbf7663d27d 126
Diletant 149:abbf7663d27d 127 #endif /* __DEVICE_DITHER_H__ */