123
Fork of LG by
DeviceDither.h
- Committer:
- Diletant
- Date:
- 2016-05-15
- Revision:
- 161:efd949e8d536
- Parent:
- 156:e68ee0bcdcda
- Child:
- 167:bedc0a9d559a
File content as of revision 161:efd949e8d536:
#ifndef __DEVICE_DITHER_H__ #define __DEVICE_DITHER_H__ //Dither drive pulse typedefs typedef struct _DeviceDitherPulseSettings { uint32_t rise; //rising edge position in 10 mks resolution ticks uint32_t fall; //falling edge position in 10 mks resolution ticks } DeviceDitherPulseSettings; typedef struct _DeviceDitherPulseState { uint32_t rise; //rising edge position in 10 mks resolution ticks uint32_t fall; //falling edge position in 10 mks resolution ticks uint32_t counter; //10 mks resolution counter, zeroed at each dither half period } DeviceDitherPulseState; typedef struct _DeviceDitherPulse { DeviceDitherPulseSettings settings; DeviceDitherPulseState state; } DeviceDitherPulse; //Dither noise typedefs typedef struct _DeviceDitherNoiseSettings { uint8_t enabled; uint32_t period; //noise period in mks uint32_t range; //noise range (format?) uint32_t phase; //adjusted noise constant (format?) } DeviceDitherNoiseSettings; typedef struct _DeviceDitherNoiseState { uint8_t enabled; } DeviceDitherNoiseState; typedef struct _DeviceDitherNoise { DeviceDitherNoiseSettings settings; DeviceDitherNoiseState state; } DeviceDitherNoise; //Dither oscillation frequency regulator typedefs typedef struct _DeviceDitherOscillationFrequencyRegulatorSettings { uint8_t enabled; uint32_t reference; //signed 16.16 format reference oscillation frequency uint32_t scale; //signed 16.16 format regulator scale factor } DeviceDitherOscillationFrequencyRegulatorSettings; typedef struct _DeviceDitherOscillationFrequencyRegulatorState { uint8_t enabled; uint32_t reference; //signed 16.16 format reference oscillation frequency uint32_t scale; //signed 16.16 format regulator scale factor uint32_t error; //signed 16.16 format regulator error } DeviceDitherOscillationFrequencyRegulatorState; typedef struct _DeviceDitherOscillationFrequencyRegulator { DeviceDitherOscillationFrequencyRegulatorSettings settings; DeviceDitherOscillationFrequencyRegulatorState state; } DeviceDitherOscillationFrequencyRegulator; //Dither information signal carrier frequency regulator typedefs typedef struct _DeviceDitherCarrierFrequencyRegulatorSettings { uint8_t enabled; uint32_t reference; //signed 16.16 format reference information signal carrier frequency uint32_t scale; //signed 16.16 format regulator scale factor } DeviceDitherCarrierFrequencyRegulatorSettings; typedef struct _DeviceDitherCarrierFrequencyRegulatorState { uint8_t enabled; uint32_t reference; //signed 16.16 format reference information signal carrier frequency uint32_t scale; //signed 16.16 format regulator scale factor uint32_t error; //signed 16.16 format regulator error } DeviceDitherCarrierFrequencyRegulatorState; typedef struct _DeviceDitherCarrierFrequencyRegulator { DeviceDitherOscillationFrequencyRegulatorSettings settings; DeviceDitherOscillationFrequencyRegulatorState state; } DeviceDitherCarrierFrequencyRegulator; //Dither cycle typedefs typedef struct _DeviceDitherCycleSettings { uint8_t enabled; } DeviceDitherCycleSettings; typedef struct _DeviceDitherCycleState { uint8_t enabled; //dither on/off uint8_t pin1; //pin 1 state uint8_t pin2; //pin 2 state } DeviceDitherCycleState; typedef struct _DeviceDitherCycle { DeviceDitherCycleSettings settings; DeviceDitherCycleState state; } DeviceDitherCycle; //Dither phase detector typedefs //error = sum(weight[i + offset] * device.counters.state.delta[i]) typedef struct _DeviceDitherPhaseDetectorSettings { uint8_t weight[32]; //0...255 weight factors uint8_t offset; //0...31 start position } DeviceDitherPhaseDetectorSettings; typedef struct _DeviceDitherPhaseDetectorState { int32_t error; } DeviceDitherPhaseDetectorState; typedef struct _DeviceDitherPhaseDetector { DeviceDitherPhaseDetectorSettings settings; DeviceDitherPhaseDetectorState state; } DeviceDitherPhaseDetector; //Dither drive typedefs typedef struct _DeviceDither { DeviceDitherPulse pulse; DeviceDitherNoise noise; DeviceDitherCycle cycle; DeviceDitherPhaseDetector detector; DeviceDitherOscillationFrequencyRegulator oscillation; DeviceDitherCarrierFrequencyRegulator carrier; } DeviceDither; void InitDitherWithDefaults(void); void InitDither(void); void DeviceStartDither(void); void DeviceDitherDoCycle(void); void DeviceDitherDetectPhase(void); #endif /* __DEVICE_DITHER_H__ */