sensor_epsonCommon.c
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // sensor_epsonCommon.c - Epson IMU sensor protocol specific code common
4 // for all IMU models
5 //
6 //
7 // THE SOFTWARE IS RELEASED INTO THE PUBLIC DOMAIN.
8 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 // NONINFRINGEMENT, SECURITY, SATISFACTORY QUALITY, AND FITNESS FOR A
11 // PARTICULAR PURPOSE. IN NO EVENT SHALL EPSON BE LIABLE FOR ANY LOSS, DAMAGE
12 // OR CLAIM, ARISING FROM OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF THE
13 // SOFTWARE.
14 //
15 //==============================================================================
16 
17 #include <stdint.h>
18 #include <stdio.h>
19 #include <string.h>
20 
21 #include "hcl.h"
22 #include "hcl_gpio.h"
23 #include "sensor_epsonCommon.h"
24 
25 //----------------------------------------------------------------------
26 // Array of structs for Epson device properties on per model basis
27 //----------------------------------------------------------------------
29  [G_EMPTY] =
30  {
31  .model = G_EMPTY,
32  .product_id = "",
33  .feature_flags = 0,
34  .gyro_sf_dps = (0),
35  .accl_sf_mg = (0),
36  .tempc_sf_degc = (0.0),
37  .tempc_25c_offset = (0),
38  .rstcnt_sf_micros = (0),
39  .ang_sf_deg = (0),
40  .qtn_sf = (0),
41  .dlta0_sf_deg = (0),
42  .dltv0_sf_mps = (0),
43  .delay_reset_ms = (800),
44  .delay_flashtest_ms = (30),
45  .delay_flashbackup_ms = (200),
46  .delay_selftest_ms = (80),
47  .delay_filter_ms = (1),
48  .delay_atti_profile_ms = (1),
49  },
50  [G320PDG0] =
51  {
52  .model = G320PDG0,
53  .product_id = "G320PDG0",
54  .feature_flags = (HAS_DLT_OUTPUT),
55  .gyro_sf_dps = (1.0 / 125),
56  .accl_sf_mg = (1.0 / 5),
57  .tempc_sf_degc = (-0.0037918),
58  .tempc_25c_offset = (2364),
59  .rstcnt_sf_micros = (21333),
60  .ang_sf_deg = (0),
61  .qtn_sf = (0),
62  .dlta0_sf_deg = (1.0 / 125 * 1 / 2000),
63  .dltv0_sf_mps = (1.0 / 5 * 1 / 1000 * 1 / 2000 * 9.80665),
64  .delay_reset_ms = (800),
65  .delay_flashtest_ms = (5),
66  .delay_flashbackup_ms = (200),
67  .delay_selftest_ms = (80),
68  .delay_filter_ms = (1),
69  .delay_atti_profile_ms = (0),
70  },
71  [G320PDGN] =
72  {
73  .model = G320PDGN,
74  .product_id = "G320PDGN",
75  .feature_flags = (HAS_DLT_OUTPUT),
76  .gyro_sf_dps = (1.0 / 125),
77  .accl_sf_mg = (1.0 / 5),
78  .tempc_sf_degc = (-0.0037918),
79  .tempc_25c_offset = (2364),
80  .rstcnt_sf_micros = (21333),
81  .ang_sf_deg = (0),
82  .qtn_sf = (0),
83  .dlta0_sf_deg = (1.0 / 125 * 1 / 2000),
84  .dltv0_sf_mps = (1.0 / 5 * 1 / 1000 * 1 / 2000 * 9.80665),
85  .delay_reset_ms = (800),
86  .delay_flashtest_ms = (5),
87  .delay_flashbackup_ms = (200),
88  .delay_selftest_ms = (80),
89  .delay_filter_ms = (1),
90  .delay_atti_profile_ms = (0),
91  },
92  [G354PDH0] =
93  {
94  .model = G354PDH0,
95  .product_id = "G354PDH0",
96  .feature_flags = (HAS_DLT_OUTPUT),
97  .gyro_sf_dps = (1.0 / 62.5),
98  .accl_sf_mg = (1.0 / 5),
99  .tempc_sf_degc = (-0.0037918),
100  .tempc_25c_offset = (2364),
101  .rstcnt_sf_micros = (21333),
102  .ang_sf_deg = (0),
103  .qtn_sf = (0),
104  .dlta0_sf_deg = (1.0 / 62.5 * 1 / 2000),
105  .dltv0_sf_mps = (1.0 / 5 * 1 / 1000 * 1 / 2000 * 9.80665),
106  .delay_reset_ms = (800),
107  .delay_flashtest_ms = (5),
108  .delay_flashbackup_ms = (200),
109  .delay_selftest_ms = (80),
110  .delay_filter_ms = (1),
111  .delay_atti_profile_ms = (0),
112  },
113  [G364PDCA] =
114  {
115  .model = G364PDCA,
116  .product_id = "G364PDCA",
117  .feature_flags = (HAS_DLT_OUTPUT),
118  .gyro_sf_dps = (0.00375),
119  .accl_sf_mg = (1.0 / 8),
120  .tempc_sf_degc = (-0.0037918),
121  .tempc_25c_offset = (2364),
122  .rstcnt_sf_micros = (21333),
123  .ang_sf_deg = (0),
124  .qtn_sf = (0),
125  .dlta0_sf_deg = (0.00375 * 1 / 2000),
126  .dltv0_sf_mps = (1.0 / 8 * 1 / 1000 * 1 / 2000 * 9.80665),
127  .delay_reset_ms = (800),
128  .delay_flashtest_ms = (5),
129  .delay_flashbackup_ms = (200),
130  .delay_selftest_ms = (80),
131  .delay_filter_ms = (1),
132  .delay_atti_profile_ms = (0),
133  },
134  [G364PDC0] =
135  {
136  .model = G364PDC0,
137  .product_id = "G364PDC0",
138  .feature_flags = (HAS_DLT_OUTPUT),
139  .gyro_sf_dps = (0.00750),
140  .accl_sf_mg = (1.0 / 8),
141  .tempc_sf_degc = (-0.0037918),
142  .tempc_25c_offset = (2364),
143  .rstcnt_sf_micros = (21333),
144  .ang_sf_deg = (0),
145  .qtn_sf = (0),
146  .dlta0_sf_deg = (0.00750 * 1 / 2000),
147  .dltv0_sf_mps = (1.0 / 8 * 1 / 1000 * 1 / 2000 * 9.80665),
148  .delay_reset_ms = (800),
149  .delay_flashtest_ms = (5),
150  .delay_flashbackup_ms = (200),
151  .delay_selftest_ms = (80),
152  .delay_filter_ms = (1),
153  .delay_atti_profile_ms = (0),
154  },
155  [G365PDC1] =
156  {
157  .model = G365PDC1,
158  .product_id = "G365PDC1",
159  .feature_flags = (HAS_ATTITUDE_OUTPUT | HAS_DLT_OUTPUT | HAS_ATTI_ON_REG |
161  .gyro_sf_dps = (1.0 / 66),
162  .accl_sf_mg = (1.0 / 6.25),
163  .tempc_sf_degc = (-0.0037918),
164  .tempc_25c_offset = (2364),
165  .rstcnt_sf_micros = (16000),
166  .ang_sf_deg = (0.00699411),
167  .qtn_sf = (1.0 / (2 << 13)),
168  .dlta0_sf_deg = (1.0 / 66 * 1 / 2000),
169  .dltv0_sf_mps = (1.0 / 6.25 * 1 / 1000 * 1 / 2000 * 9.80665),
170  .delay_reset_ms = (800),
171  .delay_flashtest_ms = (5),
172  .delay_flashbackup_ms = (200),
173  .delay_selftest_ms = (80),
174  .delay_filter_ms = (1),
175  .delay_atti_profile_ms = (1),
176  },
177  [G365PDF1] =
178  {
179  .model = G365PDF1,
180  .product_id = "G365PDF1",
181  .feature_flags = (HAS_ATTITUDE_OUTPUT | HAS_DLT_OUTPUT | HAS_ATTI_ON_REG |
183  .gyro_sf_dps = (1.0 / 66),
184  .accl_sf_mg = (1.0 / 2.5),
185  .tempc_sf_degc = (-0.0037918),
186  .tempc_25c_offset = (2364),
187  .rstcnt_sf_micros = (16000),
188  .ang_sf_deg = (0.00699411),
189  .qtn_sf = (1.0 / (2 << 13)),
190  .dlta0_sf_deg = (1.0 / 66 * 1 / 2000),
191  .dltv0_sf_mps = (1.0 / 2.5 * 1 / 1000 * 1 / 2000 * 9.80665),
192  .delay_reset_ms = (800),
193  .delay_flashtest_ms = (5),
194  .delay_flashbackup_ms = (200),
195  .delay_selftest_ms = (80),
196  .delay_filter_ms = (1),
197  .delay_atti_profile_ms = (1),
198  },
199  [G370PDF1] =
200  {
201  .model = G370PDF1,
202  .product_id = "G370PDF1",
203  .feature_flags =
206  .gyro_sf_dps = (1.0 / 66),
207  .accl_sf_mg = (1.0 / 2.5),
208  .tempc_sf_degc = (-0.0037918),
209  .tempc_25c_offset = (2364),
210  .rstcnt_sf_micros = (16000),
211  .ang_sf_deg = (0),
212  .qtn_sf = (0),
213  .dlta0_sf_deg = (1.0 / 66 * 1 / 1000),
214  .dltv0_sf_mps = (1.0 / 2.5 * 1 / 1000 * 1 / 1000 * 9.80665),
215  .delay_reset_ms = (800),
216  .delay_flashtest_ms = (5),
217  .delay_flashbackup_ms = (200),
218  .delay_selftest_ms = (80),
219  .delay_filter_ms = (1),
220  .delay_atti_profile_ms = (0),
221  },
222  [G370PDFN] =
223  {
224  .model = G370PDFN,
225  .product_id = "G370PDFN",
226  .feature_flags =
229  .gyro_sf_dps = (1.0 / 66),
230  .accl_sf_mg = (1.0 / 2.5),
231  .tempc_sf_degc = (-0.0037918),
232  .tempc_25c_offset = (2364),
233  .rstcnt_sf_micros = (16000),
234  .ang_sf_deg = (0),
235  .qtn_sf = (0),
236  .dlta0_sf_deg = (1.0 / 66 * 1 / 1000),
237  .dltv0_sf_mps = (1.0 / 2.5 * 1 / 1000 * 1 / 1000 * 9.80665),
238  .delay_reset_ms = (800),
239  .delay_flashtest_ms = (5),
240  .delay_flashbackup_ms = (200),
241  .delay_selftest_ms = (150),
242  .delay_filter_ms = (1),
243  .delay_atti_profile_ms = (0),
244  },
245  [G370PDS0] =
246  {
247  .model = G370PDS0,
248  .product_id = "G370PDS0",
249  .feature_flags =
252  .gyro_sf_dps = (1.0 / 150),
253  .accl_sf_mg = (1.0 / 2.5),
254  .tempc_sf_degc = (-0.0037918),
255  .tempc_25c_offset = (2364),
256  .rstcnt_sf_micros = (16000),
257  .ang_sf_deg = (0),
258  .qtn_sf = (0),
259  .dlta0_sf_deg = (1.0 / 150 * 1 / 1000),
260  .dltv0_sf_mps = (1.0 / 2.5 * 1 / 1000 * 1 / 1000 * 9.80665),
261  .delay_reset_ms = (800),
262  .delay_flashtest_ms = (5),
263  .delay_flashbackup_ms = (200),
264  .delay_selftest_ms = (150),
265  .delay_filter_ms = (1),
266  .delay_atti_profile_ms = (0),
267  },
268  [G330PDG0] =
269  {
270  .model = G330PDG0,
271  .product_id = "G330PDG0",
272  .feature_flags =
275  .gyro_sf_dps = (1.0 / 66),
276  .accl_sf_mg = (1.0 / 4),
277  .tempc_sf_degc = (0.00390625),
278  .tempc_25c_offset = (0),
279  .rstcnt_sf_micros = (16000),
280  .ang_sf_deg = (0.00699411),
281  .qtn_sf = (1.0 / (2 << 13)),
282  .dlta0_sf_deg = (1.0 / 66 * 1 / 2000),
283  .dltv0_sf_mps = (1.0 / 4 * 1 / 1000 * 1 / 2000 * 9.80665),
284  .delay_reset_ms = (800),
285  .delay_flashtest_ms = (30),
286  .delay_flashbackup_ms = (200),
287  .delay_selftest_ms = (80),
288  .delay_filter_ms = (1),
289  .delay_atti_profile_ms = (1),
290  },
291  [G366PDG0] =
292  {
293  .model = G366PDG0,
294  .product_id = "G366PDG0",
295  .feature_flags =
298  .gyro_sf_dps = (1.0 / 66),
299  .accl_sf_mg = (1.0 / 4),
300  .tempc_sf_degc = (0.00390625),
301  .tempc_25c_offset = (0),
302  .rstcnt_sf_micros = (16000),
303  .ang_sf_deg = (0.00699411),
304  .qtn_sf = (1.0 / (2 << 13)),
305  .dlta0_sf_deg = (1.0 / 66 * 1 / 2000),
306  .dltv0_sf_mps = (1.0 / 4 * 1 / 1000 * 1 / 2000 * 9.80665),
307  .delay_reset_ms = (800),
308  .delay_flashtest_ms = (30),
309  .delay_flashbackup_ms = (200),
310  .delay_selftest_ms = (80),
311  .delay_filter_ms = (1),
312  .delay_atti_profile_ms = (1),
313  },
314  [G370PDG0] =
315  {
316  .model = G370PDG0,
317  .product_id = "G370PDG0",
318  .feature_flags =
321  .gyro_sf_dps = (1.0 / 66),
322  .accl_sf_mg = (1.0 / 4),
323  .tempc_sf_degc = (0.00390625),
324  .tempc_25c_offset = (0),
325  .rstcnt_sf_micros = (16000),
326  .ang_sf_deg = (0),
327  .qtn_sf = (0),
328  .dlta0_sf_deg = (1.0 / 66 * 1 / 2000),
329  .dltv0_sf_mps = (1.0 / 4 * 1 / 1000 * 1 / 2000 * 9.80665),
330  .delay_reset_ms = (800),
331  .delay_flashtest_ms = (30),
332  .delay_flashbackup_ms = (200),
333  .delay_selftest_ms = (80),
334  .delay_filter_ms = (1),
335  .delay_atti_profile_ms = (0),
336  },
337  [G370PDT0] =
338  {
339  .model = G370PDT0,
340  .product_id = "G370PDT0",
341  .feature_flags =
344  .gyro_sf_dps = (1.0 / 150),
345  .accl_sf_mg = (1.0 / 4),
346  .tempc_sf_degc = (0.00390625),
347  .tempc_25c_offset = (0),
348  .rstcnt_sf_micros = (16000),
349  .ang_sf_deg = (0),
350  .qtn_sf = (0),
351  .dlta0_sf_deg = (1.0 / 66 * 1 / 2000),
352  .dltv0_sf_mps = (1.0 / 4 * 1 / 1000 * 1 / 2000 * 9.80665),
353  .delay_reset_ms = (800),
354  .delay_flashtest_ms = (30),
355  .delay_flashbackup_ms = (200),
356  .delay_selftest_ms = (80),
357  .delay_filter_ms = (1),
358  .delay_atti_profile_ms = (0),
359  },
360  [G570PR20] =
361  {
362  .model = G570PR20,
363  .product_id = "G570PR20",
364  .feature_flags = (HAS_ROT_MATRIX | HAS_RANGE_OVER | HAS_INITIAL_BACKUP),
365  .gyro_sf_dps = (1.0 / 66),
366  .accl_sf_mg = (1.0 / 2),
367  .tempc_sf_degc = (0.00390625),
368  .tempc_25c_offset = (0),
369  .rstcnt_sf_micros = (1),
370  .ang_sf_deg = (0),
371  .qtn_sf = (0),
372  .dlta0_sf_deg = (0),
373  .dltv0_sf_mps = (0),
374  .delay_reset_ms = (5000),
375  .delay_flashtest_ms = (0),
376  .delay_flashbackup_ms = (200),
377  .delay_selftest_ms = (10000),
378  .delay_filter_ms = (0),
379  .delay_atti_profile_ms = (0),
380  },
381  [G_UNKNOWN] =
382  {
383  .model = G_UNKNOWN,
384  .product_id = "G_UNKNOWN",
385  .feature_flags = 0,
386  .gyro_sf_dps = (0),
387  .accl_sf_mg = (0),
388  .tempc_sf_degc = (0.0),
389  .tempc_25c_offset = (0),
390  .rstcnt_sf_micros = (0),
391  .ang_sf_deg = (0),
392  .qtn_sf = (0),
393  .dlta0_sf_deg = (0),
394  .dltv0_sf_mps = (0),
395  .delay_reset_ms = (800),
396  .delay_flashtest_ms = (30),
397  .delay_flashbackup_ms = (200),
398  .delay_selftest_ms = (80),
399  .delay_filter_ms = (1),
400  .delay_atti_profile_ms = (1),
401  },
402 
403 };
404 
405 /*****************************************************************************
406 ** Function name: sensorHWReset
407 ** Description: Toggle the RESET pin, delay 3secs, wait for NOT_READY
408 ** This is only applicable on embedded platforms with
409 ** GPIO pin connected to IMU RESET#
410 ** Parameters: None
411 ** Return value: OK or NG
412 *****************************************************************************/
413 int sensorHWReset(void) {
414  unsigned int debug = FALSE;
415  unsigned short rxData;
416  unsigned short retryCount = 3;
417 
418  gpioClr(EPSON_RESET); // Assert RESET (LOW)
420  gpioSet(EPSON_RESET); // De-assert RESET (HIGH)
422 
423  // Poll NOT_READY bit every 1msec until returns 0
424  // Exit after specified retries
425  do {
426  rxData = registerRead16(WIN_ID1, ADDR_GLOB_CMD_LO, debug);
427  seDelayMS(1);
428  retryCount--;
429  } while ((rxData & BIT10) && (retryCount > 0));
430 
431  if (retryCount == 0) {
432  printf("\r\n...Error: NOT_READY stuck HIGH.");
433  return NG;
434  }
435  return OK;
436 }
437 
438 /*****************************************************************************
439 ** Function name: sensorPowerOn
440 ** Description: Goto Config mode, check ID register,
441 ** Check for Hardware Error Flags
442 ** Parameters: None
443 ** Return value: OK or NG
444 *****************************************************************************/
445 int sensorPowerOn(void) {
446  unsigned short rxData = 0xFFFF;
447  const unsigned short ID_VAL = 0x5345;
448  unsigned int debug = FALSE;
449  unsigned short retryCount = 10;
450 
451  do {
453  rxData = registerRead16(WIN_ID0, ADDR_MODE_CTRL_LO, debug);
454  seDelayMS(200); // allow some time for device to CONFIG
455  retryCount--;
456  } while ((rxData & BIT10) == 0 && (retryCount > 0));
457 
458  if (retryCount == 0) {
459  printf("\r\n...Error: Stuck in Sampling Mode.");
460  printf("\r\n...Attempting Hardware Reset if connected.");
461  if (sensorHWReset() == NG) {
462  return NG;
463  }
464  }
465 
466  rxData = registerRead16(WIN_ID0, ADDR_ID, debug);
467  if (rxData != ID_VAL) {
468  printf("\r\n...Error: Unexpected ID return value - 0x%04X", rxData);
469  printf("\r\n...Attempting Hardware Reset if connected.");
470  if (sensorHWReset() == NG) {
471  return NG;
472  }
473  }
474 
475  // Check for error flags
476  rxData = registerRead16(WIN_ID0, ADDR_DIAG_STAT, debug);
477  if (rxData != 0x0000) {
478  printf("\r\n...Error: DIAG_STAT return value - 0x%04X", rxData);
479  return NG;
480  }
481  return OK;
482 }
483 
484 /*****************************************************************************
485 ** Function name: sensorStart
486 ** Description: Start sensor sampling (goto Sampling Mode)
487 ** Parameters: None
488 ** Return value: None
489 *****************************************************************************/
490 void sensorStart(void) {
491  unsigned int debug = FALSE;
492 
494  printf("\r\n...Sensor start.");
495 }
496 
497 /*****************************************************************************
498 ** Function name: sensorStop
499 ** Description: Stop sensor sampling (goto Config Mode)
500 ** assumes currently in Sampling mode & WIN_ID = 0
501 ** Parameters: None
502 ** Return value: None
503 *****************************************************************************/
504 void sensorStop(void) {
505  unsigned int debug = FALSE;
506 
508  seDelayMS(200); // Provide 200msec for sensor to finish sending sample
509 #ifndef SPI
510  // Flush the receive buffer of incoming residual data
511  purgeComPort();
512 #endif // #ifndef SPI
513  printf("\r\n...Sensor stop.");
514 }
515 
516 /*****************************************************************************
517 ** Function name: sensorReset
518 ** Description: Send Software Reset to Sensor + Delay 800 msec
519 ** Parameters: None
520 ** Return value: None
521 *****************************************************************************/
522 void sensorReset(const struct EpsonProperties* esensor) {
523  unsigned int debug = FALSE;
524  unsigned char SOFT_RST_BIT = 0x80;
525 
526  printf("\r\n...Software Reset begin.");
527  registerWriteByte(WIN_ID1, ADDR_GLOB_CMD_LO, SOFT_RST_BIT, debug);
528  seDelayMS(esensor->delay_reset_ms);
529  printf("\r\n...Software Reset complete.");
530 }
531 
532 /*****************************************************************************
533 ** Function name: sensorFlashTest
534 ** Description: Send Flashtest command to Sensor and check status
535 ** NOTE: Not supported for V340PDD0
536 ** Parameters: None
537 ** Return value: OK or NG
538 *****************************************************************************/
539 int sensorFlashTest(const struct EpsonProperties* esensor) {
540  unsigned int debug = FALSE;
541  unsigned short rxData;
542  unsigned short retryCount = 3000;
543  unsigned char FLASH_TEST_BIT = 0x08;
544 
545  printf("\r\n...Flash test begin.");
546  registerWriteByte(WIN_ID1, ADDR_MSC_CTRL_HI, FLASH_TEST_BIT, debug);
547  seDelayMS(esensor->delay_flashtest_ms);
548  do {
549  rxData = registerRead16(WIN_ID1, ADDR_MSC_CTRL_LO, debug);
550  retryCount--;
551  } while ((rxData & BIT11) && (retryCount > 0));
552  if (retryCount == 0) {
553  printf("\r\n...Error: Flashtest bit did not return to 0b.");
554  return NG;
555  }
556 
557  rxData = registerRead16(WIN_ID0, ADDR_DIAG_STAT, debug);
558  printf("\r\n...Flash test complete.");
559 
560  if ((rxData & BIT2) != 0x0000) return NG;
561  return OK;
562 }
563 
564 /*****************************************************************************
565 ** Function name: sensorSelfTest
566 ** Description: Send SelfTest command to Sensor and check status
567 ** Parameters: None
568 ** Return value: OK or NG
569 *****************************************************************************/
570 int sensorSelfTest(const struct EpsonProperties* esensor) {
571  unsigned int debug = FALSE;
572  unsigned short rxData;
573  unsigned short retryCount = 3000;
574  unsigned char SELF_TEST_BIT = 0x04;
575 
576  printf("\r\n...Self test begin.");
577  registerWriteByte(WIN_ID1, ADDR_MSC_CTRL_HI, SELF_TEST_BIT, debug);
578  seDelayMS(esensor->delay_selftest_ms);
579  do {
580  rxData = registerRead16(WIN_ID1, ADDR_MSC_CTRL_LO, debug);
581  retryCount--;
582  } while ((rxData & BIT10) && (retryCount > 0));
583  if (retryCount == 0) {
584  printf("\r\n...Error: Self test bit did not return to 0b.");
585  return NG;
586  }
587 
588  rxData = registerRead16(WIN_ID0, ADDR_DIAG_STAT, debug);
589  printf("\r\n...Self test complete.");
590 
591  if ((rxData & 0x7800) != 0) return NG;
592  return OK;
593 }
594 
595 /*****************************************************************************
596 ** Function name: sensorInitialBackup
597 ** Description: Send InitialBackup command (restore defaults) to Sensor
598 ** and check status
599 ** NOTE: Not supported by all models
600 ** Parameters: None
601 ** Return value: OK or NG
602 *****************************************************************************/
603 int sensorInitialBackup(const struct EpsonProperties* esensor) {
604  if (!(esensor->feature_flags & HAS_INITIAL_BACKUP)) {
605  // always return NG since InitialBackup bit does not exist
606  return NG;
607  }
608 
609  unsigned int debug = FALSE;
610  unsigned short rxData;
611  unsigned short retryCount = 3000;
612  unsigned char INITIAL_BACKUP_BIT = 0x10;
613 
614  printf("\r\n...InitialBackup begin.");
615  registerWriteByte(WIN_ID1, ADDR_GLOB_CMD_LO, INITIAL_BACKUP_BIT, debug);
617 
618  do {
619  rxData = registerRead16(WIN_ID1, ADDR_GLOB_CMD_LO, debug);
620  retryCount--;
621  } while ((rxData & BIT4) && (retryCount > 0));
622  if (retryCount == 0) {
623  printf("\r\n...Error: InitialBackup bit did not return to 0b.");
624  return NG;
625  }
626 
627  printf("\r\n...Initial Backup complete.");
628  return OK;
629 }
630 
631 /*****************************************************************************
632 ** Function name: sensorFlashBackup
633 ** Description: Send FlashBackup command (save defaults) to Sensor
634 ** and check status
635 ** Parameters: None
636 ** Return value: OK or NG
637 *****************************************************************************/
638 int sensorFlashBackup(const struct EpsonProperties* esensor) {
639  unsigned int debug = FALSE;
640  unsigned short rxData;
641  unsigned short retryCount = 3000;
642  unsigned char FLASH_BACKUP_BIT = 0x08;
643 
644  printf("\r\n...FlashBackup begin.");
645  registerWriteByte(WIN_ID1, ADDR_GLOB_CMD_LO, FLASH_BACKUP_BIT, debug);
647 
648  do {
649  rxData = registerRead16(WIN_ID1, ADDR_GLOB_CMD_LO, debug);
650  retryCount--;
651  } while ((rxData & BIT3) && (retryCount > 0));
652  if (retryCount == 0) {
653  printf("\r\n...Error: FlashBackup bit did not return to 0b.");
654  return NG;
655  }
656 
657  rxData = registerRead16(WIN_ID0, ADDR_DIAG_STAT, debug);
658  printf("\r\n...Flashback complete.");
659 
660  if ((rxData & BIT0) != 0) return NG;
661  return OK;
662 }
663 
664 /*****************************************************************************
665 ** Function name: sensorDataByteLength
666 ** Description: Determines the sensor burst read packet data length
667 ** based on the parameters in the EpsonOptions struct.
668 ** Parameters: pointer to options struct describing IMU configuration.
669 ** Return value: data byte length
670 *****************************************************************************/
671 unsigned int sensorDataByteLength(const struct EpsonProperties* esensor,
672  const struct EpsonOptions* options) {
673  unsigned int length = 0;
674 
675  // 16 bit ND_EA FLAG
676  if (options->flag_out) length += 2;
677 
678  // 16 or 32 bit Temperature Output
679  if (options->temp_out) {
680  if (options->temp_bit)
681  length += 4;
682  else
683  length += 2;
684  }
685 
686  // 16 or 32 bit Gyro X, Y, Z Output
687  if (options->gyro_out) {
688  if (options->gyro_bit)
689  length += 12;
690  else
691  length += 6;
692  }
693 
694  // 16 or 32 bit Accl X, Y, Z Output
695  if (options->accel_out) {
696  if (options->accel_bit)
697  length += 12;
698  else
699  length += 6;
700  }
701 
702  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
703  // 16 or 32 bit Delta Angle X, Y, Z Output
704  if (options->gyro_delta_out) {
705  if (options->gyro_delta_bit)
706  length += 12;
707  else
708  length += 6;
709  }
710 
711  // 16 or 32 bit Delta Velocity X, Y, Z Output
712  if (options->accel_delta_out) {
713  if (options->accel_delta_bit)
714  length += 12;
715  else
716  length += 6;
717  }
718  }
719 
720  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
721  if (options->qtn_out) {
722  if (options->qtn_bit)
723  length += 16;
724  else
725  length += 8;
726  }
727  // 16 or 32 bit Attitude X, Y, Z Output
728  if (options->atti_out) {
729  if (options->atti_bit)
730  length += 12;
731  else
732  length += 6;
733  }
734  }
735 
736  // 16 bit GPIO status output
737  if (options->gpio_out) {
738  length += 2;
739  }
740  // 16 bit Count output
741  if (options->count_out) {
742  length += 2;
743  }
744  // 16 bit Checksum output
745  if (options->checksum_out) {
746  length += 2;
747  }
748 
749 #ifndef SPI
750  // For Start and End byte when using UART interface
751  length += 2;
752 #endif
753 
754  return length;
755 }
756 
757 /*****************************************************************************
758 ** Function name: sensorDummyWrite
759 ** Description: Sets the WINDOW_ID of IMU to 0
760 ** This is a workaround to flush the UART port on embedded
761 ** Linux platform to prevent hanging if the first register
762 ** access is register read
763 ** Parameters: None
764 ** Return value: None
765 *****************************************************************************/
766 void sensorDummyWrite(void) {
767  unsigned int debug = FALSE;
768 
769  seDelayMS(100);
770  writeByte(ADDR_WIN_CTRL, 0x00, debug);
771  seDelayMS(100);
772  printf("...sensorDummyWrite...");
773 }
774 
775 /*****************************************************************************
776 ** Function name: getProductId
777 ** Description: Updates char array with Product ID ASCII
778 **
779 ** Parameters: pointer to String
780 ** Return value: pointer to String
781 *****************************************************************************/
782 char* sensorGetProductId(char* pcharArr) {
783  unsigned short prod_id1 = registerRead16(WIN_ID1, ADDR_PROD_ID1, FALSE);
784  unsigned short prod_id2 = registerRead16(WIN_ID1, ADDR_PROD_ID2, FALSE);
785  unsigned short prod_id3 = registerRead16(WIN_ID1, ADDR_PROD_ID3, FALSE);
786  unsigned short prod_id4 = registerRead16(WIN_ID1, ADDR_PROD_ID4, FALSE);
787 
788  pcharArr[0] = (char)prod_id1;
789  pcharArr[1] = (char)(prod_id1 >> 8);
790  pcharArr[2] = (char)prod_id2;
791  pcharArr[3] = (char)(prod_id2 >> 8);
792  pcharArr[4] = (char)prod_id3;
793  pcharArr[5] = (char)(prod_id3 >> 8);
794  pcharArr[6] = (char)prod_id4;
795  pcharArr[7] = (char)(prod_id4 >> 8);
796  pcharArr[8] = '\0';
797 
798  return (pcharArr);
799 }
800 
801 /*****************************************************************************
802 ** Function name: getSerialId
803 ** Description: Updates char array with Serial ID ASCII
804 **
805 ** Parameters: pointer to String
806 ** Return value: pointer to String
807 *****************************************************************************/
808 char* sensorGetSerialId(char* pcharArr) {
809  unsigned short ser_num1 = registerRead16(WIN_ID1, ADDR_SERIAL_NUM1, FALSE);
810  unsigned short ser_num2 = registerRead16(WIN_ID1, ADDR_SERIAL_NUM2, FALSE);
811  unsigned short ser_num3 = registerRead16(WIN_ID1, ADDR_SERIAL_NUM3, FALSE);
812  unsigned short ser_num4 = registerRead16(WIN_ID1, ADDR_SERIAL_NUM4, FALSE);
813 
814  pcharArr[0] = (char)ser_num1;
815  pcharArr[1] = (char)(ser_num1 >> 8);
816  pcharArr[2] = (char)ser_num2;
817  pcharArr[3] = (char)(ser_num2 >> 8);
818  pcharArr[4] = (char)ser_num3;
819  pcharArr[5] = (char)(ser_num3 >> 8);
820  pcharArr[6] = (char)ser_num4;
821  pcharArr[7] = (char)(ser_num4 >> 8);
822  pcharArr[8] = '\0';
823 
824  return pcharArr;
825 }
826 
827 /*****************************************************************************
828 ** Function name: sensorInitOptions
829 ** Description: Initialize the sensor hardware to desired settings
830 ** based on EpsonOptions
831 ** Parameters: struct EpsonOptions
832 ** Return value: OK or NG
833 **
834 *****************************************************************************/
835 int sensorInitOptions(const struct EpsonProperties* esensor,
836  struct EpsonOptions* options) {
837  unsigned int debug = FALSE;
838 
839  // Disable attitude/quaternion output if not supported
840  if (!(esensor->feature_flags & HAS_ATTITUDE_OUTPUT)) {
841  options->atti_out = 0;
842  options->qtn_out = 0;
843  }
844  // Disable delta output if not supported
845  if (!(esensor->feature_flags & HAS_DLT_OUTPUT)) {
846  options->gyro_delta_out = 0;
847  options->accel_delta_out = 0;
848  }
849  // Disable attitude output if delta output enabled
850  if (options->gyro_delta_out | options->accel_delta_out) {
851  options->atti_out = 0;
852  options->qtn_out = 0;
853  }
854 
855  // SIG_CTRL
856  // ND flags for gyro_delta_out X,Y,Z are enabled if gyro_delta_out is enabled
857  // ND flags for accel_delta_out X,Y,Z are enabled if accel_delta_out is
858  // enabled
859  int sig_ctrl_lo = 0;
860  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
861  sig_ctrl_lo = (options->accel_delta_out & 0x01) << 2 |
862  (options->accel_delta_out & 0x01) << 3 |
863  (options->accel_delta_out & 0x01) << 4 |
864  (options->gyro_delta_out & 0x01) << 5 |
865  (options->gyro_delta_out & 0x01) << 6 |
866  (options->gyro_delta_out & 0x01) << 7;
867  }
868 
869  // ND flags for gyro_out X,Y,Z are enabled if gyro_out is enabled
870  // ND flags for accel_out X,Y,Z are enabled if accel_out is enabled
871  // ND flag for temp_out is enabled if temp_out is enabled
872  int sig_ctrl_hi =
873  (options->accel_out & 0x01) << 1 | (options->accel_out & 0x01) << 2 |
874  (options->accel_out & 0x01) << 3 | (options->gyro_out & 0x01) << 4 |
875  (options->gyro_out & 0x01) << 5 | (options->gyro_out & 0x01) << 6 |
876  (options->temp_out & 0x01) << 7;
877 
878  // MSC_CTRL
879  // Configure DRDY function (if needed) & EXT pin function on GPIO2 (if needed)
880  // External Counter Reset is typically used when GPIO2 is connected to a
881  // PPS-like signal
882  int msc_ctrl_lo = 0;
883  if (esensor->model == G570PR20) {
884  msc_ctrl_lo =
885  ((options->drdy_pol & 0x01) << 1) | ((options->drdy_on & 0x01) << 2);
886  } else {
887  msc_ctrl_lo =
888  (options->drdy_pol & 0x01) << 1 | (options->drdy_on & 0x01) << 2 |
889  (options->ext_pol & 0x01) << 5 | (options->ext_sel & 0x03) << 6;
890  }
891 
892  // SMPL_CTRL
893  // Configures the Data Output Rate of the IMU.
894  // Refer to Datasheet for valid Data Output Rate & Filter Setting combinations
895  int smpl_ctrl_hi = (options->dout_rate & 0x0F);
896 
897  // FILTER_CTRL
898  // Configures the FIR filter of the IMU.
899  // Refer to Datasheet for valid Data Output Rate & Filter Setting combinations
900  int filter_ctrl_lo = (options->filter_sel & 0x1F);
901 
902  // BURST_CTRL1
903  // These enable or disable certain data fields in the burst read packet
904  // For G330 or G366 specifically, attitude output can be enabled or disabled.
905  int burst_ctrl1_lo = (options->checksum_out & 0x1) |
906  (options->count_out & 0x1) << 1 |
907  (options->gpio_out & 0x01) << 2;
908 
909  int burst_ctrl1_hi = 0;
910  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
911  burst_ctrl1_hi |=
912  ((options->atti_out & 0x1) | (options->qtn_out & 0x1) << 1);
913  }
914  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
915  burst_ctrl1_hi |= ((options->accel_delta_out & 0x1) << 2 |
916  (options->gyro_delta_out & 0x01) << 3);
917  }
918  burst_ctrl1_hi |=
919  ((options->accel_out & 0x01) << 4 | (options->gyro_out & 0x01) << 5 |
920  (options->temp_out & 0x01) << 6 | (options->flag_out & 0x01) << 7);
921 
922  // BURST_CTRL2
923  // If certain data fields are enabled, these bits determine if the
924  // data fields are 16 or 32 bit
925  int burst_ctrl2_hi = 0;
926  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
927  burst_ctrl2_hi |=
928  ((options->atti_bit & 0x1) | (options->qtn_bit & 0x01) << 1);
929  }
930  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
931  burst_ctrl2_hi |= ((options->accel_delta_bit & 0x01) << 2 |
932  (options->gyro_delta_bit & 0x01) << 3);
933  }
934  burst_ctrl2_hi |=
935  ((options->accel_bit & 0x01) << 4 | (options->gyro_bit & 0x01) << 5 |
936  (options->temp_bit & 0x01) << 6);
937 
938  // POL_CTRL
939  // If these bits are set, then the axis values are reverse polarity
940  int pol_ctrl_lo =
941  (options->invert_zaccel & 0x01) << 1 |
942  (options->invert_yaccel & 0x01) << 2 |
943  (options->invert_xaccel & 0x01) << 3 | (options->invert_zgyro & 0x01) << 4 |
944  (options->invert_ygyro & 0x01) << 5 | (options->invert_xgyro & 0x01) << 6;
945 
946  // DLT_CTRL
947  // Enable or disable Delta Angle/Velocity overflow flag in DIAG_STAT
948  // Set A_RANGE_CTRL bit if device supports it
949  // Set the Delta Angle/Velocity Scale Factor
950  int dlt_ctrl_hi = 0;
951  if (esensor->feature_flags & HAS_ARANGE) {
952  dlt_ctrl_hi = (options->a_range_ctrl & 0x01);
953  }
954 
955  int dlt_ctrl_lo = 0;
956  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
957  dlt_ctrl_lo = (options->dlta_range_ctrl & 0x0F) << 4 |
958  (options->dltv_range_ctrl & 0x0F);
959  }
960 
961  // ATTI_CTRL
962  // Attitude Output & Delta Angle/Velocity functions are mutually exclusive.
963  // User should only enable one or the other, but not both.
964  // Attitude Mode = 0=Inclination 1=Euler
965  int atti_ctrl_hi = 0;
966  int atti_ctrl_lo = 0;
967  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
968  atti_ctrl_hi |= (((options->atti_out | options->qtn_out) & 0x01) << 2 |
969  (options->atti_mode & 0x01) << 3);
970 
971  // Refer to datasheet to determine the different Euler Angle configurations
972  if (!options->qtn_out) {
973  atti_ctrl_lo = (options->atti_conv & 0x1f);
974  }
975  }
976  if ((esensor->feature_flags & (HAS_DLT_OUTPUT | HAS_ATTI_ON_REG)) ==
978  atti_ctrl_hi |=
979  (((options->gyro_delta_out & 0x01) | (options->accel_delta_out & 0x01))
980  << 1);
981  }
982 
983  // GLOB_CMD2
984  // Setting Attitude Motion Profile
985  int glob_cmd2_lo = 0;
986  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
987  glob_cmd2_lo = (options->atti_profile & 0x03) << 4;
988  }
989  if (!(esensor->model == G570PR20)) {
990  registerWriteByte(WIN_ID1, ADDR_SIG_CTRL_HI, sig_ctrl_hi, debug);
991  registerWriteByte(WIN_ID1, ADDR_SIG_CTRL_LO, sig_ctrl_lo, debug);
992  }
993  registerWriteByte(WIN_ID1, ADDR_MSC_CTRL_LO, msc_ctrl_lo, debug);
994  registerWriteByte(WIN_ID1, ADDR_SMPL_CTRL_HI, smpl_ctrl_hi, debug);
995  registerWriteByte(WIN_ID1, ADDR_FILTER_CTRL_LO, filter_ctrl_lo, debug);
996  seDelayMS(esensor->delay_filter_ms);
997 
998  // Check that the FILTER_BUSY bit returns 0
999  unsigned short rxData;
1000  unsigned short retryCount = 3000;
1001  do {
1002  rxData = registerRead16(WIN_ID1, ADDR_FILTER_CTRL_LO, debug);
1003  retryCount--;
1004  } while ((rxData & BIT5) && (retryCount > 0));
1005 
1006  if (retryCount == 0) {
1007  printf("\r\n...Error: Filter busy bit did not return to 0b.");
1008  return NG;
1009  }
1010 
1011 #ifdef SPI
1012  // Always disable UART_AUTO mode when using SPI IF
1014 #else
1015  // Always enable UART_AUTO mode when using UART IF
1017 #endif
1018 
1019  registerWriteByte(WIN_ID1, ADDR_BURST_CTRL1_LO, burst_ctrl1_lo, debug);
1020  registerWriteByte(WIN_ID1, ADDR_BURST_CTRL1_HI, burst_ctrl1_hi, debug);
1021  registerWriteByte(WIN_ID1, ADDR_BURST_CTRL2_HI, burst_ctrl2_hi, debug);
1022  registerWriteByte(WIN_ID1, ADDR_POL_CTRL_LO, pol_ctrl_lo, debug);
1023 
1024  if (esensor->feature_flags & HAS_ARANGE) {
1025  registerWriteByte(WIN_ID1, ADDR_DLT_CTRL_HI, dlt_ctrl_hi, debug);
1026  }
1027  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
1028  registerWriteByte(WIN_ID1, ADDR_DLT_CTRL_LO, dlt_ctrl_lo, debug);
1029  }
1030  if (esensor->feature_flags & HAS_ATTI_ON_REG) {
1031  registerWriteByte(WIN_ID1, ADDR_ATTI_CTRL_HI, atti_ctrl_hi, debug);
1032  }
1033  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
1034  registerWriteByte(WIN_ID1, ADDR_ATTI_CTRL_LO, atti_ctrl_lo, debug);
1035 
1036  registerWriteByte(WIN_ID1, ADDR_GLOB_CMD2_LO, glob_cmd2_lo, debug);
1037  seDelayMS(esensor->delay_atti_profile_ms);
1038 
1039  // Check that the ATTI_MOTION_PROFILE_STAT bit returns 0
1040  retryCount = 3000;
1041  do {
1042  rxData = registerRead16(WIN_ID1, ADDR_GLOB_CMD2_LO, debug);
1043  retryCount--;
1044  } while ((rxData & BIT6) && (retryCount > 0));
1045 
1046  if (retryCount == 0) {
1047  printf(
1048  "\r\n...Error: ATTI_MOTION_PROFILE_STAT bit did not return to 0b.");
1049  return NG;
1050  }
1051  }
1052  return OK;
1053 }
1054 
1055 /*****************************************************************************
1056 ** Function name: sensorDumpRegisters
1057 ** Description: Read all registers for debug purpose
1058 ** Parameters: None
1059 ** Return value: None
1060 *****************************************************************************/
1061 void sensorDumpRegisters(const struct EpsonProperties* esensor) {
1062  unsigned int debug = TRUE;
1063  printf("\r\nRegister Dump:\r\n");
1066  registerRead16(WIN_ID0, ADDR_FLAG, debug);
1067  printf("\r\n");
1068  registerRead16(WIN_ID0, ADDR_GPIO, debug);
1069 
1070  if (esensor->model != G570PR20) {
1072  }
1073 
1074  if (esensor->feature_flags & HAS_RANGE_OVER) {
1076  }
1077 
1078  if (esensor->model != G570PR20) {
1079  printf("\r\n");
1083  printf("\r\n");
1087  printf("\r\n");
1091  printf("\r\n");
1095  printf("\r\n");
1098  }
1099 
1100  if (esensor->feature_flags & HAS_RTDIAG) {
1102  }
1103  printf("\r\n");
1104  registerRead16(WIN_ID0, ADDR_ID, debug);
1105  printf("\r\n");
1106 
1107  // Output only QTN because ANG and DLTA share the same registers
1108  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
1112  printf("\r\n");
1116  printf("\r\n");
1119  printf("\r\n");
1120  }
1121 
1122  if (esensor->feature_flags & HAS_DLT_OUTPUT) {
1126  printf("\r\n");
1130  printf("\r\n");
1134  printf("\r\n");
1138  }
1139  printf("\r\n\r\n");
1140  if (esensor->model != G570PR20) {
1142  }
1145  printf("\r\n");
1149  printf("\r\n");
1153 
1154  if ((esensor->feature_flags & HAS_DLT_OUTPUT) |
1155  (esensor->feature_flags & HAS_ARANGE)) {
1156  printf("\r\n");
1158  }
1159 
1160  if (esensor->feature_flags & HAS_ATTI_ON_REG) {
1162  }
1163  if (esensor->feature_flags & HAS_ATTITUDE_OUTPUT) {
1165  }
1166 
1167  printf("\r\n");
1171  printf("\r\n");
1175  printf("\r\n");
1179  printf("\r\n");
1181  printf("\r\n");
1182 }
1183 
1184 /*****************************************************************************
1185 ** Function name: sensorGetDeviceModel
1186 ** Description: Identifies Epson device attached
1187 ** Parameters: pointer to EpsonProperties struct
1188 ** pointer to string for storing 8 ASCII Epson Product ID
1189 ** pointer to string for storing 8 ASCII Epson Serial ID
1190 ** Return value: OK or NG
1191 *****************************************************************************/
1192 int sensorGetDeviceModel(struct EpsonProperties* esensor, char* prod_id,
1193  char* serial_id) {
1194  int i;
1195 
1196  printf("\r\nReading device model and serial number...");
1197  sensorGetProductId(prod_id);
1198  sensorGetSerialId(serial_id);
1199  for (i = G_EMPTY; i < G_UNKNOWN; i++) {
1200  if (strcmp(epson_sensors[i].product_id, prod_id) == 0) break;
1201  }
1202 
1203  if ((i == G_EMPTY) || (i == G_UNKNOWN)) {
1204  printf("\r\nERROR: Could not identify product id.");
1205  return NG;
1206  }
1207 
1208  // Print out which model executable was compiled and identify model
1209  printf("\r\nPRODUCT ID:\t%s", prod_id);
1210  printf("\r\nSERIAL ID:\t%s", serial_id);
1211  *esensor = epson_sensors[i];
1212 
1213  return OK;
1214 }
ADDR_ATTI_CTRL_HI
#define ADDR_ATTI_CTRL_HI
Definition: sensor_epsonCommon.h:166
sensorInitOptions
int sensorInitOptions(const struct EpsonProperties *esensor, struct EpsonOptions *options)
Definition: sensor_epsonCommon.c:835
G370PDG0
@ G370PDG0
Definition: sensor_epsonCommon.h:296
ADDR_MSC_CTRL_HI
#define ADDR_MSC_CTRL_HI
Definition: sensor_epsonCommon.h:144
EpsonProperties
Definition: sensor_epsonCommon.h:314
EpsonOptions::invert_xgyro
int invert_xgyro
Definition: sensor_epsonCommon.h:377
EpsonOptions::accel_delta_bit
int accel_delta_bit
Definition: sensor_epsonCommon.h:372
G370PDFN
@ G370PDFN
Definition: sensor_epsonCommon.h:292
BIT2
#define BIT2
Definition: sensor_epsonCommon.h:36
ADDR_PROD_ID2
#define ADDR_PROD_ID2
Definition: sensor_epsonCommon.h:212
sensor_epsonCommon.h
EpsonOptions::ext_pol
int ext_pol
Definition: sensor_epsonCommon.h:343
EpsonProperties::delay_filter_ms
int delay_filter_ms
Definition: sensor_epsonCommon.h:331
G370PDF1
@ G370PDF1
Definition: sensor_epsonCommon.h:291
ADDR_SMPL_CTRL_LO
#define ADDR_SMPL_CTRL_LO
Definition: sensor_epsonCommon.h:145
EpsonOptions::atti_mode
int atti_mode
Definition: sensor_epsonCommon.h:391
EpsonOptions::drdy_on
int drdy_on
Definition: sensor_epsonCommon.h:344
EpsonOptions::ext_sel
int ext_sel
Definition: sensor_epsonCommon.h:342
EpsonOptions::filter_sel
int filter_sel
Definition: sensor_epsonCommon.h:351
HAS_ATTI_ON_REG
@ HAS_ATTI_ON_REG
Definition: sensor_epsonCommon.h:305
sensorSelfTest
int sensorSelfTest(const struct EpsonProperties *esensor)
Definition: sensor_epsonCommon.c:570
ADDR_XACCL_LOW
#define ADDR_XACCL_LOW
Definition: sensor_epsonCommon.h:102
EpsonOptions::invert_ygyro
int invert_ygyro
Definition: sensor_epsonCommon.h:378
G370PDT0
@ G370PDT0
Definition: sensor_epsonCommon.h:297
ADDR_MODE_CTRL_LO
#define ADDR_MODE_CTRL_LO
Definition: sensor_epsonCommon.h:86
BIT5
#define BIT5
Definition: sensor_epsonCommon.h:39
ADDR_XDLTV_LOW
#define ADDR_XDLTV_LOW
Definition: sensor_epsonCommon.h:134
ADDR_PROD_ID1
#define ADDR_PROD_ID1
Definition: sensor_epsonCommon.h:211
seDelayMS
void seDelayMS(uint32_t millis)
Definition: hcl_linux.c:47
ADDR_SIG_CTRL_HI
#define ADDR_SIG_CTRL_HI
Definition: sensor_epsonCommon.h:142
ADDR_GPIO
#define ADDR_GPIO
Definition: sensor_epsonCommon.h:90
ADDR_XDLTA_HIGH
#define ADDR_XDLTA_HIGH
Definition: sensor_epsonCommon.h:127
ADDR_XDLTA_LOW
#define ADDR_XDLTA_LOW
Definition: sensor_epsonCommon.h:128
ADDR_WIN_CTRL
#define ADDR_WIN_CTRL
Definition: sensor_epsonCommon.h:220
registerRead16
unsigned short registerRead16(unsigned char, unsigned char, unsigned int)
Definition: sensor_epsonSpi.c:101
CMD_SAMPLING
#define CMD_SAMPLING
Definition: sensor_epsonCommon.h:226
ADDR_MSC_CTRL_LO
#define ADDR_MSC_CTRL_LO
Definition: sensor_epsonCommon.h:143
ADDR_MODE_CTRL_HI
#define ADDR_MODE_CTRL_HI
Definition: sensor_epsonCommon.h:87
ADDR_BURST_CTRL1_HI
#define ADDR_BURST_CTRL1_HI
Definition: sensor_epsonCommon.h:154
EpsonProperties::delay_reset_ms
int delay_reset_ms
Definition: sensor_epsonCommon.h:327
registerWriteByte
void registerWriteByte(unsigned char, unsigned char, unsigned char, unsigned int)
Definition: sensor_epsonSpi.c:60
EpsonOptions::temp_bit
int temp_bit
Definition: sensor_epsonCommon.h:368
purgeComPort
int purgeComPort(void)
Definition: hcl_uart.c:146
EpsonProperties::delay_atti_profile_ms
int delay_atti_profile_ms
Definition: sensor_epsonCommon.h:332
BIT10
#define BIT10
Definition: sensor_epsonCommon.h:44
hcl_gpio.h
ADDR_SIG_CTRL_LO
#define ADDR_SIG_CTRL_LO
Definition: sensor_epsonCommon.h:141
EpsonOptions::drdy_pol
int drdy_pol
Definition: sensor_epsonCommon.h:345
HAS_ATTITUDE_OUTPUT
@ HAS_ATTITUDE_OUTPUT
Definition: sensor_epsonCommon.h:303
ADDR_ZDLTV_LOW
#define ADDR_ZDLTV_LOW
Definition: sensor_epsonCommon.h:138
sensorGetSerialId
char * sensorGetSerialId(char *pcharArr)
Definition: sensor_epsonCommon.c:808
ADDR_QTN2_HIGH
#define ADDR_QTN2_HIGH
Definition: sensor_epsonCommon.h:115
ADDR_XDLTV_HIGH
#define ADDR_XDLTV_HIGH
Definition: sensor_epsonCommon.h:133
EpsonOptions::gpio_out
int gpio_out
Definition: sensor_epsonCommon.h:363
EpsonOptions
Definition: sensor_epsonCommon.h:340
ADDR_POL_CTRL_LO
#define ADDR_POL_CTRL_LO
Definition: sensor_epsonCommon.h:157
ADDR_YGYRO_LOW
#define ADDR_YGYRO_LOW
Definition: sensor_epsonCommon.h:98
ADDR_ZGYRO_HIGH
#define ADDR_ZGYRO_HIGH
Definition: sensor_epsonCommon.h:99
ADDR_QTN0_HIGH
#define ADDR_QTN0_HIGH
Definition: sensor_epsonCommon.h:111
ADDR_BURST_CTRL2_LO
#define ADDR_BURST_CTRL2_LO
Definition: sensor_epsonCommon.h:155
ADDR_QTN3_HIGH
#define ADDR_QTN3_HIGH
Definition: sensor_epsonCommon.h:117
EpsonProperties::dltv0_sf_mps
double dltv0_sf_mps
Definition: sensor_epsonCommon.h:326
EpsonOptions::dout_rate
int dout_rate
Definition: sensor_epsonCommon.h:348
BIT4
#define BIT4
Definition: sensor_epsonCommon.h:38
hcl.h
EpsonOptions::gyro_bit
int gyro_bit
Definition: sensor_epsonCommon.h:369
ADDR_PROD_ID3
#define ADDR_PROD_ID3
Definition: sensor_epsonCommon.h:213
EpsonOptions::qtn_out
int qtn_out
Definition: sensor_epsonCommon.h:360
HAS_RANGE_OVER
@ HAS_RANGE_OVER
Definition: sensor_epsonCommon.h:307
EpsonOptions::accel_out
int accel_out
Definition: sensor_epsonCommon.h:357
EpsonOptions::atti_profile
int atti_profile
Definition: sensor_epsonCommon.h:395
ADDR_DLT_CTRL_HI
#define ADDR_DLT_CTRL_HI
Definition: sensor_epsonCommon.h:161
EpsonOptions::invert_yaccel
int invert_yaccel
Definition: sensor_epsonCommon.h:381
ADDR_YGYRO_HIGH
#define ADDR_YGYRO_HIGH
Definition: sensor_epsonCommon.h:97
ADDR_COUNT
#define ADDR_COUNT
Definition: sensor_epsonCommon.h:91
ADDR_QTN2_LOW
#define ADDR_QTN2_LOW
Definition: sensor_epsonCommon.h:116
ADDR_SERIAL_NUM3
#define ADDR_SERIAL_NUM3
Definition: sensor_epsonCommon.h:218
BIT3
#define BIT3
Definition: sensor_epsonCommon.h:37
EpsonProperties::qtn_sf
double qtn_sf
Definition: sensor_epsonCommon.h:324
EpsonOptions::count_out
int count_out
Definition: sensor_epsonCommon.h:364
ADDR_YACCL_HIGH
#define ADDR_YACCL_HIGH
Definition: sensor_epsonCommon.h:103
EpsonProperties::delay_flashtest_ms
int delay_flashtest_ms
Definition: sensor_epsonCommon.h:328
ADDR_GLOB_CMD2_LO
#define ADDR_GLOB_CMD2_LO
Definition: sensor_epsonCommon.h:167
HAS_INITIAL_BACKUP
@ HAS_INITIAL_BACKUP
Definition: sensor_epsonCommon.h:310
G_EMPTY
@ G_EMPTY
Definition: sensor_epsonCommon.h:283
ADDR_PROD_ID4
#define ADDR_PROD_ID4
Definition: sensor_epsonCommon.h:214
ADDR_YDLTA_LOW
#define ADDR_YDLTA_LOW
Definition: sensor_epsonCommon.h:130
ADDR_SERIAL_NUM1
#define ADDR_SERIAL_NUM1
Definition: sensor_epsonCommon.h:216
ADDR_BURST_CTRL2_HI
#define ADDR_BURST_CTRL2_HI
Definition: sensor_epsonCommon.h:156
ADDR_XACCL_HIGH
#define ADDR_XACCL_HIGH
Definition: sensor_epsonCommon.h:101
gpioSet
void gpioSet(__attribute__((unused)) uint8_t pin)
Definition: hcl_gpio.c:48
ADDR_QTN1_HIGH
#define ADDR_QTN1_HIGH
Definition: sensor_epsonCommon.h:113
BIT0
#define BIT0
Definition: sensor_epsonCommon.h:34
ADDR_FLAG
#define ADDR_FLAG
Definition: sensor_epsonCommon.h:89
EpsonOptions::flag_out
int flag_out
Definition: sensor_epsonCommon.h:354
EpsonOptions::checksum_out
int checksum_out
Definition: sensor_epsonCommon.h:365
EpsonProperties::feature_flags
int feature_flags
Definition: sensor_epsonCommon.h:317
EpsonOptions::atti_bit
int atti_bit
Definition: sensor_epsonCommon.h:374
G365PDF1
@ G365PDF1
Definition: sensor_epsonCommon.h:290
ADDR_RANGE_OVER
#define ADDR_RANGE_OVER
Definition: sensor_epsonCommon.h:92
EpsonOptions::invert_zgyro
int invert_zgyro
Definition: sensor_epsonCommon.h:379
ADDR_ZDLTA_LOW
#define ADDR_ZDLTA_LOW
Definition: sensor_epsonCommon.h:132
WIN_ID0
#define WIN_ID0
Definition: sensor_epsonCommon.h:222
sensorFlashTest
int sensorFlashTest(const struct EpsonProperties *esensor)
Definition: sensor_epsonCommon.c:539
ADDR_UART_CTRL_LO
#define ADDR_UART_CTRL_LO
Definition: sensor_epsonCommon.h:149
ADDR_GLOB_CMD_LO
#define ADDR_GLOB_CMD_LO
Definition: sensor_epsonCommon.h:151
EpsonProperties::gyro_sf_dps
double gyro_sf_dps
Definition: sensor_epsonCommon.h:318
ADDR_ID
#define ADDR_ID
Definition: sensor_epsonCommon.h:110
HAS_DLT_OUTPUT
@ HAS_DLT_OUTPUT
Definition: sensor_epsonCommon.h:304
G364PDC0
@ G364PDC0
Definition: sensor_epsonCommon.h:288
G320PDGN
@ G320PDGN
Definition: sensor_epsonCommon.h:285
EpsonProperties::delay_flashbackup_ms
int delay_flashbackup_ms
Definition: sensor_epsonCommon.h:329
ADDR_XGYRO_HIGH
#define ADDR_XGYRO_HIGH
Definition: sensor_epsonCommon.h:95
EpsonProperties::rstcnt_sf_micros
int rstcnt_sf_micros
Definition: sensor_epsonCommon.h:322
ADDR_XGYRO_LOW
#define ADDR_XGYRO_LOW
Definition: sensor_epsonCommon.h:96
HAS_RTDIAG
@ HAS_RTDIAG
Definition: sensor_epsonCommon.h:308
ADDR_BURST_CTRL1_LO
#define ADDR_BURST_CTRL1_LO
Definition: sensor_epsonCommon.h:153
ADDR_QTN0_LOW
#define ADDR_QTN0_LOW
Definition: sensor_epsonCommon.h:112
sensorFlashBackup
int sensorFlashBackup(const struct EpsonProperties *esensor)
Definition: sensor_epsonCommon.c:638
sensorStop
void sensorStop(void)
Definition: sensor_epsonCommon.c:504
EPSON_RESET
#define EPSON_RESET
Definition: hcl_gpio.h:32
WIN_ID1
#define WIN_ID1
Definition: sensor_epsonCommon.h:223
EpsonOptions::a_range_ctrl
int a_range_ctrl
Definition: sensor_epsonCommon.h:384
sensorPowerOn
int sensorPowerOn(void)
Definition: sensor_epsonCommon.c:445
G370PDS0
@ G370PDS0
Definition: sensor_epsonCommon.h:293
gpioClr
void gpioClr(__attribute__((unused)) uint8_t pin)
Definition: hcl_gpio.c:56
ADDR_DLT_CTRL_LO
#define ADDR_DLT_CTRL_LO
Definition: sensor_epsonCommon.h:160
EpsonProperties::tempc_sf_degc
double tempc_sf_degc
Definition: sensor_epsonCommon.h:320
sensorInitialBackup
int sensorInitialBackup(const struct EpsonProperties *esensor)
Definition: sensor_epsonCommon.c:603
ADDR_SERIAL_NUM2
#define ADDR_SERIAL_NUM2
Definition: sensor_epsonCommon.h:217
ADDR_YDLTV_LOW
#define ADDR_YDLTV_LOW
Definition: sensor_epsonCommon.h:136
sensorHWReset
int sensorHWReset(void)
Definition: sensor_epsonCommon.c:413
ADDR_ZGYRO_LOW
#define ADDR_ZGYRO_LOW
Definition: sensor_epsonCommon.h:100
ADDR_SMPL_CTRL_HI
#define ADDR_SMPL_CTRL_HI
Definition: sensor_epsonCommon.h:146
ADDR_DIAG_STAT
#define ADDR_DIAG_STAT
Definition: sensor_epsonCommon.h:88
ADDR_ZDLTV_HIGH
#define ADDR_ZDLTV_HIGH
Definition: sensor_epsonCommon.h:137
ADDR_YDLTV_HIGH
#define ADDR_YDLTV_HIGH
Definition: sensor_epsonCommon.h:135
ADDR_VERSION
#define ADDR_VERSION
Definition: sensor_epsonCommon.h:215
ADDR_SERIAL_NUM4
#define ADDR_SERIAL_NUM4
Definition: sensor_epsonCommon.h:219
sensorStart
void sensorStart(void)
Definition: sensor_epsonCommon.c:490
EpsonOptions::atti_out
int atti_out
Definition: sensor_epsonCommon.h:361
EpsonOptions::gyro_delta_out
int gyro_delta_out
Definition: sensor_epsonCommon.h:358
ADDR_ATTI_CTRL_LO
#define ADDR_ATTI_CTRL_LO
Definition: sensor_epsonCommon.h:165
sensorGetProductId
char * sensorGetProductId(char *pcharArr)
Definition: sensor_epsonCommon.c:782
EpsonOptions::gyro_out
int gyro_out
Definition: sensor_epsonCommon.h:356
ADDR_ZACCL_LOW
#define ADDR_ZACCL_LOW
Definition: sensor_epsonCommon.h:106
EPSON_RESET_LOW_WIDTH_MS
#define EPSON_RESET_LOW_WIDTH_MS
Definition: sensor_epsonCommon.h:51
sensorReset
void sensorReset(const struct EpsonProperties *esensor)
Definition: sensor_epsonCommon.c:522
EpsonProperties::accl_sf_mg
double accl_sf_mg
Definition: sensor_epsonCommon.h:319
ADDR_ZACCL_HIGH
#define ADDR_ZACCL_HIGH
Definition: sensor_epsonCommon.h:105
sensorDumpRegisters
void sensorDumpRegisters(const struct EpsonProperties *esensor)
Definition: sensor_epsonCommon.c:1061
EpsonOptions::temp_out
int temp_out
Definition: sensor_epsonCommon.h:355
EpsonOptions::dlta_range_ctrl
int dlta_range_ctrl
Definition: sensor_epsonCommon.h:387
G_UNKNOWN
@ G_UNKNOWN
Definition: sensor_epsonCommon.h:299
EpsonOptions::accel_bit
int accel_bit
Definition: sensor_epsonCommon.h:370
length
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
EpsonProperties::model
int model
Definition: sensor_epsonCommon.h:315
ADDR_ZDLTA_HIGH
#define ADDR_ZDLTA_HIGH
Definition: sensor_epsonCommon.h:131
ADDR_TEMP_HIGH
#define ADDR_TEMP_HIGH
Definition: sensor_epsonCommon.h:93
writeByte
void writeByte(unsigned char, unsigned char, unsigned int)
Definition: sensor_epsonSpi.c:39
EpsonOptions::dltv_range_ctrl
int dltv_range_ctrl
Definition: sensor_epsonCommon.h:388
ADDR_YDLTA_HIGH
#define ADDR_YDLTA_HIGH
Definition: sensor_epsonCommon.h:129
EpsonOptions::atti_conv
int atti_conv
Definition: sensor_epsonCommon.h:392
NG
#define NG
Definition: hcl.h:30
G570PR20
@ G570PR20
Definition: sensor_epsonCommon.h:298
HAS_ROT_MATRIX
@ HAS_ROT_MATRIX
Definition: sensor_epsonCommon.h:306
G365PDC1
@ G365PDC1
Definition: sensor_epsonCommon.h:289
ADDR_QTN3_LOW
#define ADDR_QTN3_LOW
Definition: sensor_epsonCommon.h:118
epson_sensors
struct EpsonProperties epson_sensors[]
Definition: sensor_epsonCommon.c:28
G330PDG0
@ G330PDG0
Definition: sensor_epsonCommon.h:294
sensorDataByteLength
unsigned int sensorDataByteLength(const struct EpsonProperties *esensor, const struct EpsonOptions *options)
Definition: sensor_epsonCommon.c:671
BIT6
#define BIT6
Definition: sensor_epsonCommon.h:40
sensorDummyWrite
void sensorDummyWrite(void)
Definition: sensor_epsonCommon.c:766
EpsonOptions::invert_zaccel
int invert_zaccel
Definition: sensor_epsonCommon.h:382
EPSON_RESET_DELAY_MS
#define EPSON_RESET_DELAY_MS
Definition: sensor_epsonCommon.h:52
G366PDG0
@ G366PDG0
Definition: sensor_epsonCommon.h:295
EpsonOptions::accel_delta_out
int accel_delta_out
Definition: sensor_epsonCommon.h:359
ADDR_YACCL_LOW
#define ADDR_YACCL_LOW
Definition: sensor_epsonCommon.h:104
BIT11
#define BIT11
Definition: sensor_epsonCommon.h:45
EpsonOptions::qtn_bit
int qtn_bit
Definition: sensor_epsonCommon.h:373
ADDR_QTN1_LOW
#define ADDR_QTN1_LOW
Definition: sensor_epsonCommon.h:114
ADDR_FILTER_CTRL_LO
#define ADDR_FILTER_CTRL_LO
Definition: sensor_epsonCommon.h:147
ADDR_GLOB_CMD3_LO
#define ADDR_GLOB_CMD3_LO
Definition: sensor_epsonCommon.h:162
OK
#define OK
Definition: hcl.h:26
G364PDCA
@ G364PDCA
Definition: sensor_epsonCommon.h:287
EpsonOptions::invert_xaccel
int invert_xaccel
Definition: sensor_epsonCommon.h:380
EpsonOptions::gyro_delta_bit
int gyro_delta_bit
Definition: sensor_epsonCommon.h:371
ADDR_TEMP_LOW
#define ADDR_TEMP_LOW
Definition: sensor_epsonCommon.h:94
HAS_ARANGE
@ HAS_ARANGE
Definition: sensor_epsonCommon.h:309
G354PDH0
@ G354PDH0
Definition: sensor_epsonCommon.h:286
sensorGetDeviceModel
int sensorGetDeviceModel(struct EpsonProperties *esensor, char *prod_id, char *serial_id)
Definition: sensor_epsonCommon.c:1192
EpsonProperties::delay_selftest_ms
int delay_selftest_ms
Definition: sensor_epsonCommon.h:330
ADDR_RT_DIAG
#define ADDR_RT_DIAG
Definition: sensor_epsonCommon.h:108
G320PDG0
@ G320PDG0
Definition: sensor_epsonCommon.h:284
CMD_CONFIG
#define CMD_CONFIG
Definition: sensor_epsonCommon.h:227
EpsonProperties::product_id
const char * product_id
Definition: sensor_epsonCommon.h:316


ess_imu_driver
Author(s):
autogenerated on Wed Dec 11 2024 03:06:30