aboutsummaryrefslogtreecommitdiff
path: root/arm-probe.h
blob: 36d5630c1de536a75e4d1114b2b58816cde55a60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "avg-mean-us.h"

#define MAX_PROBES 8
#define CHANNELS_PER_PROBE 3

enum state {
	APP_INIT_MAGIC,
	APP_INIT_VERSION,
	APP_INIT_VENDOR,
	APP_INIT_RATE,
	APP_INIT_CONFIG,

	APP_FRAME_L,
	APP_FRAME_H,
	APP_VOLTAGE_L,
	APP_VOLTAGE_H,
	APP_CURRENT_L,
	APP_CURRENT_H,
	APP_SWALLOW,
};

struct samples {
	unsigned short v;
	unsigned short i;
};

struct aep_channel {
	char channel_name[64];
	char channel_name_pretty[64];
	int pretrigger_ms;
	int pretrigger_samples_taken;
	double rshunt;
	double voffset[2];
	double vnoise[2];

	struct samples *pretrig_ring;
	int ring_samples;
	int head;
	int tail;
	int trigger_filter;

	struct avg_mean_us avg_mean_voltage;
	struct avg_mean_us avg_mean_current;

	/* 0: corrected V,
	 * 1: corrected A,
	 * 2: corrected W,
	 * 3: uncorrected V1,
	 * 4: uncorrected V2
	 */	

	double min[5];
	double max[5];

	int decimation_counter;
	unsigned long samples_seen;
};

struct aep {
	int fd;
	char name[64];
	char dev_filepath[64];
	int index;
	int head;
	int tail;
	unsigned int version;
	unsigned int rate;
	enum state state;
	unsigned short predicted_frame;
	unsigned short voltage;
	unsigned short current;
	int invalid;
	int ignore;
	int triggered;
	unsigned char ring[4096];
	int counter;
	int sec_last_traffic;
	int started;
	int selected_channel;
	int done_config;
	unsigned long samples;
	int rx_count;
	struct aep_channel ch[CHANNELS_PER_PROBE];
};

struct aep aeps[MAX_PROBES];

enum aep_commands {
	AEPC_RESET = 0xff,
	AEPC_VERSION = 0x01,
	AEPC_VENDOR = 0x03,
	AEPC_RATE = 0x05,
	AEPC_CONFIG = 0x07,
	AEPC_START = 0x09,
	AEPC_STOP = 0x0b,
};

extern int configure(struct aep *aep, const char *dev_filepath,
	const char *config_filepath, struct aep_channel *wch);
extern char configuration_name[64];
extern unsigned int ms_pretrigger;