-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.h
186 lines (163 loc) · 4.76 KB
/
main.h
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//=========================================================================
// main.h
//
// An interface for the RM3100 3-axis magnetometer from PNI Sensor Corp.
//
// Author: David Witten, KD0EAG
// Date: April 21, 2020
// License: GPL 3.0
//=========================================================================
#ifndef SWX3100MAIN_h
#define SWX3100MAIN_h
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <math.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <time.h>
#include <sys/time.h>
#include <fcntl.h>
#include <memory.h>
#include <linux/i2c-dev.h>
#include "device_defs.h"
#include "i2c.h"
#include "MCP9808.h"
#define _DEBUG 0
#define USE_PIPES FALSE
#define RUNMAG_VERSION "0.1.2"
#define UTCBUFLEN 64
#define MAXPATHBUFLEN 1025
#define JSONBUFLEN 1025
#define JSONBUFTOKENCOUNT 1024
#define SITEPREFIXLEN 32
//------------------------------------------
// Parameter List struct
//------------------------------------------
typedef struct tag_pList
{
int SBCType;
int boardType;
int boardMode;
int doBistMask;
int buildLogPath;
int cc_x;
int cc_y;
int cc_z;
int x_gain;
int y_gain;
int z_gain;
int TMRCRate;
int CMMSampleRate;
int samplingMode;
int NOSRegValue;
int DRDYdelay;
int readBackCCRegs;
int magRevId;
int hideRaw;
int i2cBusNumber;
int i2c_fd;
int jsonFlag;
int localTempOnly;
int localTempAddr;
int magnetometerOnly;
int magnetometerAddr;
int remoteTempOnly;
int remoteTempAddr;
int outDelay;
int quietFlag;
int showParameters;
int singleRead;
int tsMilliseconds;
int verboseFlag;
int showTotal;
char *outputFilePath;
char *sitePrefix;
char *logOutputTime;
int logOutput;
char *Version;
int useOutputPipe;
char *pipeInPath;
char *pipeOutPath;
} pList;
//-------------------------------------------
// Device paths for different platforms
//-------------------------------------------
#define OTHER_BUS ""
#define KHADAS_EDGE_I2C3 "/dev/i2c-3"
#define KHADAS_VIM3_I2C3 "/dev/i2c-3"
#define KHADAS_VIM3_I2C4 "/dev/i2c-4"
#define ODROIDC0_I2C_BUS "/dev/i2c-1"
#define ODROIDC1_I2C_BUS "/dev/i2c-1"
#define ODROIDC2_I2C_BUS "/dev/i2c-1"
#define ODROIDC4_I2C_BUS "/dev/i2c-2"
#define ODROIDC4_I2C_BUS3 "/dev/i2c-3"
#define ODROIDN2_I2C_BUS "/dev/i2c-2"
#define ODROIDN2_I2C_BUS3 "/dev/i2c-3"
#define ODROIDN2PLUS_I2C_BUS0 "/dev/i2c-0"
#define ODROIDN2PLUS_I2C_BUS1 "/dev/i2c-1"
#define NV_XAVIER_I2C_BUS "/dev/i2c-8"
#define NV_NANO_I2C_BUS "/dev/i2c-1"
#define RASPI_I2C_BUS "/dev/i2c-1"
//-------------------------------------------
// Known SBC device platforms
//-------------------------------------------
#define sOTHER_BUS "Other "
#define sKHADAS_EDGE_BUS3 "KHADAS EDGE bus 3 "
#define sVIM3_I2C_BUS3 "KHADAS VIM3 bus 3 "
#define sVIM3_I2C_BUS4 "KHADAS VIM3 bus 4 "
#define sNV_XAVIER_I2C_BUS "NV Xavier bus 8 "
#define sNV_NANO_I2C_BUS "NV Nano bus 1 "
#define sODROIDC0_I2C_BUS "Odroid CO bus 1 "
#define sODROIDC1_I2C_BUS "Odroid C1 bus 1 "
#define sODROIDC2_I2C_BUS "Odroid C2 bus 1 "
#define sODROIDC4_I2C_BUS "Odroid C4 bus 1 "
#define sODROIDC4_I2C_BUS3 "Odroid C4 bus 3 "
#define sODROIDN2_I2C_BUS "Odroid N2 bus 2 "
#define sODROIDN2_I2C_BUS3 "Odroid N2 bus 3 "
#define sODROIDN2PLUS_I2C_BUS0 "Odroid N2+ bus 0 "
#define sODROIDN2PLUS_I2C_BUS1 "Odroid N2+ bus 1 "
#define sRASPI_I2C_BUS "Raspberry Pi 3/4 "
//-------------------------------------------
// Device paths for different platforms
//-------------------------------------------
typedef enum
{
eKHADAS_EDGE_I2C3 = 0,
eVIM3_I2C_BUS3,
eVIM3_I2C_BUS4,
eNV_XAVIER_I2C_BUS,
eNV_NANO_I2C_BUS,
eODROIDC0_I2C_BUS,
eODROIDC1_I2C_BUS,
eODROIDC2_I2C_BUS,
eODROIDC4_I2C_BUS,
eODROIDC4_I2C_BUS3,
eODROIDN2_I2C_BUS,
eODROIDN2_I2C_BUS3,
eODROIDN2PLUS_I2C_BUS0,
eODROIDN2PLUS_I2C_BUS1,
eRASPI_I2C_BUS,
} i2cBusEnum;
//-------------------------------------------
// I2C Bus Path entries
//-------------------------------------------
struct busDev
{
const char *devPath;
const char *SBCString;
int enumVal;
int busNumber;
};
//------------------------------------------
// Prototypes
//------------------------------------------
int readTemp(pList *p, int devAddr);
int readMagCMM(pList *p, int devAddr, int32_t *XYZ);
int readMagPOLL(pList *p, int devAddr, int32_t *XYZ);
int main(int argc, char** argv);
#endif //SWX3100MAIN_h