sensor_epsonG350.c
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // sensor_epsonG350.c - Epson IMU sensor protocol specific code for G350
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  // EXT=GPIO2, EXT_POL=Positive Logic, DRDY_ON=Data_Ready, DRDY_POL = Active Low
51 
52  // Set samples per second to 125
54 
55  // Filter TAP = 16
57 
58  // AUTO_START=Disable, UART_AUTO=Enable (For UART Interface)
60 
61  // Enable COUNT
63 
64  return TRUE; /* success */
65 }
66 
67 
68 /*****************************************************************************
69 ** Function name: registerDump
70 ** Description: Read all registers for debug purpose
71 ** Parameters: None
72 ** Return value: None
73 *****************************************************************************/
74 void registerDump(void)
75 {
76  unsigned int debug = TRUE;
77  printf("\r\nRegister Dump:\r\n");
78  registerRead16(0x00, 0x00, debug);
79  registerRead16(0x00, 0x02, debug);
80  registerRead16(0x00, 0x04, debug);
81  printf("\r\n");
82  registerRead16(0x00, 0x06, debug);
83  registerRead16(0x00, 0x08, debug);
84  registerRead16(0x00, 0x0A, debug);
85  printf("\r\n");
86  registerRead16(0x00, 0x0C, debug);
87  registerRead16(0x00, 0x0E, debug);
88  registerRead16(0x00, 0x10, debug);
89  printf("\r\n");
90  registerRead16(0x00, 0x12, debug);
91  registerRead16(0x00, 0x32, debug);
92  registerRead16(0x00, 0x34, debug);
93  printf("\r\n");
94  registerRead16(0x00, 0x36, debug);
95  registerRead16(0x00, 0x38, debug);
96  registerRead16(0x00, 0x3A, debug);
97  printf("\r\n");
98  registerRead16(0x00, 0x3C, debug);
99  registerRead16(0x00, 0x3E, debug);
100  registerRead16(0x00, 0x50, debug);
101  printf("\r\n");
102 }
#define CMD_DRDY_GPIO1
#define ADDR_MSC_CTRL_LO
#define ADDR_COUNT_CTRL_LO
#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_WINDOW0
void registerDump(void)
#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
#define ADDR_SIG_CTRL_LO
#define CMD_FLTAP16
#define ADDR_UART_CTRL_LO
int sensorInit(void)


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