123
Fork of LG by
DeviceCounters.h@174:0f86eedd511c, 2016-06-26 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
Diletant | 156:e68ee0bcdcda | 1 | #ifndef __DEVICE_COUNTERS_H__ |
Diletant | 156:e68ee0bcdcda | 2 | #define __DEVICE_COUNTERS_H__ |
Diletant | 156:e68ee0bcdcda | 3 | |
Diletant | 174:0f86eedd511c | 4 | //Dither latched counters typedefs |
Diletant | 174:0f86eedd511c | 5 | typedef struct _DeviceCountersDitherLatchedSettings { |
Diletant | 174:0f86eedd511c | 6 | } DeviceCountersDitherLatchedSettings; |
Diletant | 174:0f86eedd511c | 7 | |
Diletant | 174:0f86eedd511c | 8 | typedef struct _DeviceCountersDitherLatchedState { |
Diletant | 174:0f86eedd511c | 9 | int32_t delta[32]; //Cyclic buffer of QEI counts with (32 * oscillation frequency) update frequency |
Diletant | 174:0f86eedd511c | 10 | int32_t angle; //Sum of last 32 deltas from delta buffer - angle accumulated for 1 vibro cycle till now |
Diletant | 174:0f86eedd511c | 11 | int32_t displacement; //Sum of last 16 deltas minus sum of previous 16 deltas from delta buffer - displacement |
Diletant | 174:0f86eedd511c | 12 | int32_t amplitude; //Sum of positive displacements minus negative displacements from last 32 displacements - dither "amplitude" |
Diletant | 174:0f86eedd511c | 13 | int32_t frequency; //Sum of positive deltas minus negative deltas from last 32 deltas - dither "output frequency" |
Diletant | 174:0f86eedd511c | 14 | int32_t accumulator; //Angle accumulated between user read requests, or between periodic answers |
Diletant | 174:0f86eedd511c | 15 | } DeviceCountersDitherLatchedState; |
Diletant | 174:0f86eedd511c | 16 | |
Diletant | 174:0f86eedd511c | 17 | typedef struct _DeviceCountersDitherLatched { |
Diletant | 174:0f86eedd511c | 18 | DeviceCountersDitherLatchedSettings settings; |
Diletant | 174:0f86eedd511c | 19 | DeviceCountersDitherLatchedState state; |
Diletant | 174:0f86eedd511c | 20 | } DeviceCountersDitherLatched; |
Diletant | 174:0f86eedd511c | 21 | |
Diletant | 174:0f86eedd511c | 22 | //Reconstructed meander latched counters typedefs |
Diletant | 174:0f86eedd511c | 23 | typedef struct _DeviceCountersMeanderLatchedSettings { |
Diletant | 174:0f86eedd511c | 24 | } DeviceCountersMeanderLatchedSettings; |
Diletant | 174:0f86eedd511c | 25 | |
Diletant | 174:0f86eedd511c | 26 | typedef struct _DeviceCountersMeanderLatchedState { |
Diletant | 174:0f86eedd511c | 27 | int32_t a; //Positive counts |
Diletant | 174:0f86eedd511c | 28 | int32_t b; //Negative counts |
Diletant | 174:0f86eedd511c | 29 | } DeviceCountersMeanderLatchedState; |
Diletant | 174:0f86eedd511c | 30 | |
Diletant | 174:0f86eedd511c | 31 | typedef struct _DeviceCountersMeanderLatched { |
Diletant | 174:0f86eedd511c | 32 | DeviceCountersMeanderLatchedSettings settings; |
Diletant | 174:0f86eedd511c | 33 | DeviceCountersMeanderLatchedState state; |
Diletant | 174:0f86eedd511c | 34 | } DeviceCountersMeanderLatched; |
Diletant | 174:0f86eedd511c | 35 | |
Diletant | 174:0f86eedd511c | 36 | //Virtual zero sensor latched counters typedefs |
Diletant | 174:0f86eedd511c | 37 | typedef struct _DeviceCountersZeroLatchedSettings { |
Diletant | 174:0f86eedd511c | 38 | } DeviceCountersZeroLatchedSettings; |
Diletant | 174:0f86eedd511c | 39 | |
Diletant | 174:0f86eedd511c | 40 | typedef struct _DeviceCountersZeroLatchedState { |
Diletant | 174:0f86eedd511c | 41 | int32_t a; //Positive counts |
Diletant | 174:0f86eedd511c | 42 | int32_t b; //Negative counts |
Diletant | 174:0f86eedd511c | 43 | } DeviceCountersZeroLatchedState; |
Diletant | 174:0f86eedd511c | 44 | |
Diletant | 174:0f86eedd511c | 45 | typedef struct _DeviceCountersZeroLatched { |
Diletant | 174:0f86eedd511c | 46 | DeviceCountersZeroLatchedSettings settings; |
Diletant | 174:0f86eedd511c | 47 | DeviceCountersZeroLatchedState state; |
Diletant | 174:0f86eedd511c | 48 | } DeviceCountersZeroLatched; |
Diletant | 174:0f86eedd511c | 49 | |
Diletant | 174:0f86eedd511c | 50 | //Counters typedefs |
Diletant | 174:0f86eedd511c | 51 | typedef struct _DeviceCounters { |
Diletant | 174:0f86eedd511c | 52 | DeviceCountersDitherLatched dither; //Counters latched by dither (measurement) cycle |
Diletant | 174:0f86eedd511c | 53 | DeviceCountersMeanderLatched meander; //Counters latched by restored meander (angular velocity reverse latched) |
Diletant | 174:0f86eedd511c | 54 | DeviceCountersZeroLatched zero; //Counters latched by virtual zero position sensor |
Diletant | 174:0f86eedd511c | 55 | } DeviceCounters; |
Diletant | 174:0f86eedd511c | 56 | |
Diletant | 174:0f86eedd511c | 57 | /* |
Diletant | 156:e68ee0bcdcda | 58 | typedef struct _DeviceCountersSettings { |
Diletant | 156:e68ee0bcdcda | 59 | } DeviceCountersSettings; |
Diletant | 156:e68ee0bcdcda | 60 | |
Diletant | 156:e68ee0bcdcda | 61 | typedef struct _DeviceCountersState { |
Diletant | 161:efd949e8d536 | 62 | int32_t delta[32]; //Cyclic buffer of QEI counts with (32 * oscillation frequency) update frequency |
Diletant | 174:0f86eedd511c | 63 | int32_t angle; //Sum of last 32 deltas from delta buffer - angle accumulated for 1 vibro cycle till now |
Diletant | 156:e68ee0bcdcda | 64 | int32_t displacement; //Sum of last 16 deltas minus sum of previous 16 deltas from delta buffer - displacement |
Diletant | 174:0f86eedd511c | 65 | int32_t amplitude; //Sum of positive displacements minus negative displacements from last 32 displacements - dither "amplitude" |
Diletant | 161:efd949e8d536 | 66 | int32_t frequency; //Sum of positive deltas minus negative deltas from last 32 deltas - dither "output frequency" |
Diletant | 161:efd949e8d536 | 67 | int32_t accumulator; //Angle accumulated between user read requests, or between periodic answers |
Diletant | 156:e68ee0bcdcda | 68 | } DeviceCountersState; |
Diletant | 156:e68ee0bcdcda | 69 | |
Diletant | 156:e68ee0bcdcda | 70 | typedef struct _DeviceCounters { |
Diletant | 156:e68ee0bcdcda | 71 | DeviceCountersSettings settings; |
Diletant | 156:e68ee0bcdcda | 72 | DeviceCountersState state; |
Diletant | 156:e68ee0bcdcda | 73 | } DeviceCounters; |
Diletant | 174:0f86eedd511c | 74 | */ |
Diletant | 156:e68ee0bcdcda | 75 | |
Diletant | 167:bedc0a9d559a | 76 | void InitCountersDefaultSettings(void); |
Diletant | 167:bedc0a9d559a | 77 | void InitCountersState(void); |
Diletant | 167:bedc0a9d559a | 78 | void DeviceStartCounters(void); |
Diletant | 167:bedc0a9d559a | 79 | |
Diletant | 173:7f938afb0447 | 80 | void countersProcess(void); |
Diletant | 156:e68ee0bcdcda | 81 | |
Diletant | 156:e68ee0bcdcda | 82 | #endif /* __DEVICE_COUNTERS_H__ */ |