Main Page
Classes
Class List
Class Members
All
a
c
d
e
f
g
h
i
m
n
o
p
q
r
s
t
Functions
Variables
a
c
d
e
f
g
h
i
m
n
o
p
q
r
t
Files
File List
File Members
All
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
u
v
w
Functions
c
d
g
i
m
n
o
p
r
s
u
w
Variables
Enumerations
Enumerator
Macros
a
b
c
d
e
f
m
n
o
r
s
v
w
src
main_regdump.c
Go to the documentation of this file.
1
//==============================================================================
2
//
3
// main_regdump.c - Epson IMU sensor test application
4
// - This program reads all registers values for debug purpose
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
#include <stdint.h>
17
#include <stdio.h>
18
#include <string.h>
19
#include <
time.h
>
20
21
#ifndef SPI
22
#include <termios.h>
23
#endif // !SPI
24
25
#include "
hcl.h
"
26
#include "
hcl_gpio.h
"
27
28
#ifdef SPI
29
#include "
hcl_spi.h
"
30
#else
31
#include "
hcl_uart.h
"
32
#endif // SPI
33
34
#include "
sensor_epsonCommon.h
"
35
36
#ifndef SPI
37
// Modify below as needed for hardware
38
const
char
*
IMUSERIAL
=
"/dev/ttyUSB0"
;
39
#endif // !SPI
40
41
int
main
(
int
argc,
char
* argv[]) {
42
char
prod_id[9];
// Device Product ID
43
char
ser_id[9];
// Device Serial ID
44
struct
EpsonProperties
epson_sensor =
epson_sensors
[
G_UNKNOWN
];
45
46
// 1) Initialize the Seiko Epson HCL layer
47
printf(
"\r\nInitializing HCL layer..."
);
48
if
(!
seInit
()) {
49
printf(
50
"\r\nError: could not initialize the Seiko Epson HCL layer. "
51
"Exiting...\r\n"
);
52
return
-1;
53
}
54
printf(
"...done.\r\n"
);
55
56
// 2) Initialize the GPIO interfaces, For GPIO control of pins SPI CS, RESET,
57
// DRDY
58
printf(
"\r\nInitializing GPIO interface..."
);
59
if
(!
gpioInit
()) {
60
printf(
"\r\nError: could not initialize the GPIO layer. Exiting...\r\n"
);
61
seRelease
();
62
return
-1;
63
}
64
printf(
"...done.\r\n"
);
65
66
#ifdef SPI
67
// 3) Initialize SPI Interface
68
printf(
"\r\nInitializing SPI interface..."
);
69
// The max SPI clock rate is 1MHz for burst reads in Epson IMUs
70
if
(!
spiInit
(
SPI_MODE3
, 1000000)) {
71
printf(
"\r\nError: could not initialize SPI interface. Exiting...\r\n"
);
72
gpioRelease
();
73
seRelease
();
74
return
-1;
75
}
76
sensorDummyWrite
();
77
#else
78
// 3) Initialize UART Interface
79
// The baudrate value should be set the the same setting as currently
80
// flashed value in the IMU UART_CTRL BAUD_RATE register
81
printf(
"\r\nInitializing UART interface..."
);
82
if
(!
uartInit
(
IMUSERIAL
,
BAUD_460800
)) {
83
printf(
"\r\nError: could not initialize UART interface. Exiting...\r\n"
);
84
gpioRelease
();
85
seRelease
();
86
return
-1;
87
}
88
#endif // SPI
89
90
printf(
"...done.\r\n"
);
91
92
// 4) Power on sequence - force sensor to config mode, read ID and
93
// check for errors
94
95
printf(
"\r\nSensor starting up..."
);
96
if
(!
sensorPowerOn
()) {
97
printf(
"\r\nError: failed to power on sensor. Exiting...\r\n"
);
98
99
#ifdef SPI
100
spiRelease
();
101
#else
102
uartRelease
();
103
#endif
104
105
gpioRelease
();
106
seRelease
();
107
return
-1;
108
}
109
printf(
"...done.\r\n"
);
110
111
// Auto-Detect Epson Sensor Model Properties
112
printf(
"\r\nDetecting sensor model..."
);
113
if
(!
sensorGetDeviceModel
(&epson_sensor, prod_id, ser_id)) {
114
printf(
"\r\nError: could not detect Epson Sensor. Exiting...\r\n"
);
115
116
#ifdef SPI
117
spiRelease
();
118
#else
119
uartRelease
();
120
#endif
121
122
gpioRelease
();
123
seRelease
();
124
return
-1;
125
}
126
127
sensorDumpRegisters
(&epson_sensor);
128
129
#ifdef SPI
130
spiRelease
();
131
#else
132
uartRelease
();
133
#endif
134
gpioRelease
();
135
seRelease
();
136
printf(
"\r\n"
);
137
138
return
0;
139
}
spiRelease
int spiRelease(void)
Definition:
hcl_spi_rpi.c:67
EpsonProperties
Definition:
sensor_epsonCommon.h:314
sensor_epsonCommon.h
time.h
hcl_gpio.h
IMUSERIAL
const char * IMUSERIAL
Definition:
main_regdump.c:38
gpioInit
int gpioInit(void)
Definition:
hcl_gpio.c:32
hcl.h
seRelease
int seRelease(void)
Definition:
hcl_linux.c:39
BAUD_460800
#define BAUD_460800
Definition:
hcl_uart.h:26
main
int main(int argc, char *argv[])
Definition:
main_regdump.c:41
uartInit
int uartInit(const char *comPortPath, int baudrate)
Definition:
hcl_uart.c:50
gpioRelease
int gpioRelease(void)
Definition:
hcl_gpio.c:40
uartRelease
int uartRelease(void)
Definition:
hcl_uart.c:98
hcl_spi.h
sensorPowerOn
int sensorPowerOn(void)
Definition:
sensor_epsonCommon.c:445
SPI_MODE3
@ SPI_MODE3
Definition:
hcl_spi.h:26
sensorDumpRegisters
void sensorDumpRegisters(const struct EpsonProperties *esensor)
Definition:
sensor_epsonCommon.c:1061
G_UNKNOWN
@ G_UNKNOWN
Definition:
sensor_epsonCommon.h:299
spiInit
int spiInit(uint8_t mode, uint32_t khzspeed)
Definition:
hcl_spi_rpi.c:45
epson_sensors
struct EpsonProperties epson_sensors[]
Definition:
sensor_epsonCommon.c:28
sensorDummyWrite
void sensorDummyWrite(void)
Definition:
sensor_epsonCommon.c:766
seInit
int seInit(void)
Definition:
hcl_linux.c:31
sensorGetDeviceModel
int sensorGetDeviceModel(struct EpsonProperties *esensor, char *prod_id, char *serial_id)
Definition:
sensor_epsonCommon.c:1192
hcl_uart.h
ess_imu_driver
Author(s):
autogenerated on Wed Dec 11 2024 03:06:30