sensor_epsonG354.c
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // sensor_epsonG354.c - Epson IMU sensor protocol specific code for
4 // G320/G354/G364
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 IMPLIED,
9 // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT,
10 // SECURITY, SATISFACTORY QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
11 // SHALL EPSON BE LIABLE FOR ANY LOSS, DAMAGE OR CLAIM, ARISING FROM OR IN CONNECTION
12 // WITH THE SOFTWARE OR THE USE OF THE SOFTWARE.
13 //
14 //==============================================================================
15 #include "sensor_epsonCommon.h"
16 #include "hcl.h"
17 #include "hcl_gpio.h"
18 
19 /*****************************************************************************
20 ** Function name: sensorInit
21 ** Description: Initialize the sensor hardware to desired settings
22 ** Data Output Rate, Filter Setting, Burst Read Sensor Data
23 ** Parameters: None
24 ** Return value: 1=success, 0=fail
25 *****************************************************************************/
26 int sensorInit(void)
27 {
28  unsigned short rxData;
29  unsigned int debug = FALSE;
30  unsigned short retryCount = 3000;
31 
32  // Safety Measure, Incase Device is in Sampling Mode, goto Config Mode
33  do
34  {
37  seDelayMicroSecs(1000);
38  retryCount--;
39  } while((rxData & 0x0400) == 0x0000 && (retryCount != 0));
40 
41  if (retryCount == 0)
42  {
43  printf("\r\n...Error: Stuck in Sampling Mode.");
44  return FALSE;
45  }
46 
47  // POL_CTRL = Not Inverted
49 
50  // Enable new data flags for gyros and accls
52 
53  // EXT=Reset Counter, EXT_POL=Positive Logic, DRDY_ON=Data_Ready, DRDY_POL = Active Low
55 
56  // Set samples per second to 125
58 
59  // Filter TAP = 16
61 
62  // Delay for filter config
64 
65  retryCount = 3000;
66  do
67  {
69  retryCount--;
70  } while((rxData & 0x0020) == 0x0020 && (retryCount != 0));
71 
72  if (retryCount == 0)
73  {
74  printf("\r\n...Error: Filter busy bit did not return to 0b.");
75  return FALSE;
76  }
77 
78  // AUTO_START=Disable, UART_AUTO=Enable (For UART Interface)
80 
81  // Enable COUNT and CHKSM data for burst mode
83 
84  // Enable GYRO and ACCL data for burst mode
86 
87  // Enable 32-bit Output for Gyro & Accel
89 
90  return TRUE; /* success */
91 }
92 
93 
94 /*****************************************************************************
95 ** Function name: registerDump
96 ** Description: Read all registers for debug purpose
97 ** Parameters: None
98 ** Return value: None
99 *****************************************************************************/
100 void registerDump(void)
101 {
102  unsigned int debug = TRUE;
103  printf("\r\nRegister Dump:\r\n");
104  registerRead16(0x00, 0x02, debug);
105  registerRead16(0x00, 0x04, debug);
106  registerRead16(0x00, 0x06, debug);
107  printf("\r\n");
108  registerRead16(0x00, 0x08, debug);
109  registerRead16(0x00, 0x0A, debug);
110  registerRead16(0x00, 0x0E, debug);
111  printf("\r\n");
112  registerRead16(0x00, 0x10, debug);
113  registerRead16(0x00, 0x12, debug);
114  registerRead16(0x00, 0x14, debug);
115  printf("\r\n");
116  registerRead16(0x00, 0x16, debug);
117  registerRead16(0x00, 0x18, debug);
118  registerRead16(0x00, 0x1A, debug);
119  printf("\r\n");
120  registerRead16(0x00, 0x1C, debug);
121  registerRead16(0x00, 0x1E, debug);
122  registerRead16(0x00, 0x20, debug);
123  printf("\r\n");
124  registerRead16(0x00, 0x22, debug);
125  registerRead16(0x00, 0x24, debug);
126  registerRead16(0x00, 0x26, debug);
127  printf("\r\n");
128  registerRead16(0x00, 0x28, debug);
129  registerRead16(0x00, 0x64, debug);
130  registerRead16(0x00, 0x68, debug);
131  printf("\r\n");
132  registerRead16(0x00, 0x6C, debug);
133  registerRead16(0x00, 0x6E, debug);
134  registerRead16(0x00, 0x70, debug);
135  printf("\r\n");
136  registerRead16(0x00, 0x72, debug);
137  registerRead16(0x00, 0x74, debug);
138  registerRead16(0x00, 0x76, debug);
139  printf("\r\n");
140  registerRead16(0x00, 0x78, debug);
141  registerRead16(0x00, 0x7A, debug);
142  printf("\r\n");
143  registerRead16(0x01, 0x00, debug);
144  registerRead16(0x01, 0x02, debug);
145  printf("\r\n");
146  registerRead16(0x01, 0x04, debug);
147  registerRead16(0x01, 0x06, debug);
148  registerRead16(0x01, 0x08, debug);
149  printf("\r\n");
150  registerRead16(0x01, 0x0A, debug);
151  registerRead16(0x01, 0x0C, debug);
152  registerRead16(0x01, 0x0E, debug);
153  printf("\r\n");
154  registerRead16(0x01, 0x6A, debug);
155  registerRead16(0x01, 0x6C, debug);
156  registerRead16(0x01, 0x6E, debug);
157  printf("\r\n");
158  registerRead16(0x01, 0x70, debug);
159  registerRead16(0x01, 0x72, debug);
160  registerRead16(0x01, 0x74, debug);
161  printf("\r\n");
162  registerRead16(0x01, 0x76, debug);
163  registerRead16(0x01, 0x78, debug);
164  registerRead16(0x01, 0x7A, debug);
165  printf("\r\n");
166  registerRead16(0x01, 0x7E, debug);
167  printf("\r\n");
168 }
void registerDump(void)
#define ADDR_BURST_CTRL2_HI
#define ADDR_SIG_CTRL_HI
#define ADDR_MSC_CTRL_LO
#define CMD_EN_BRSTDATA_HI
#define EPSON_FILTER_DELAY
#define CMD_EN_NDFLAGS
#define CMD_RSTCNTR_DRDY
#define ADDR_BURST_CTRL1_HI
#define CMD_RATE125
#define CMD_WINDOW1
#define FALSE
Definition: hcl_uart.c:32
#define ADDR_SMPL_CTRL_HI
#define TRUE
Definition: hcl_uart.c:31
#define CMD_EN_BRSTDATA_LO
#define CMD_WINDOW0
#define ADDR_MODE_CTRL_HI
#define ADDR_MODE_CTRL_LO
void seDelayMicroSecs(uint32_t micros)
Definition: hcl_linux.c:67
unsigned short registerRead16(unsigned char, unsigned char, unsigned int)
void registerWriteByte(unsigned char, unsigned char, unsigned char, unsigned int)
#define CMD_END_SAMPLING
int sensorInit(void)
#define CMD_FLTAP16
#define ADDR_UART_CTRL_LO
#define ADDR_FILTER_CTRL_LO
void seDelayMS(uint32_t millis)
Definition: hcl_linux.c:54
#define ADDR_POL_CTRL_LO
#define CMD_32BIT
#define ADDR_BURST_CTRL1_LO


epson_g364_imu_driver
Author(s):
autogenerated on Mon Jun 10 2019 13:12:32