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


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