c6dofimu7 2.0.0.0
c6dofimu7.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef C6DOFIMU7_H
36#define C6DOFIMU7_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define C6DOFIMU7_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.int2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69 cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define C6DOFIMU7_RETVAL uint8_t
77
78#define C6DOFIMU7_OK 0x00
79#define C6DOFIMU7_INIT_ERROR 0xFF
86#define C6DOFIMU7_SLAVE_ADDRESS 0x68
87#define C6DOFIMU7_PWR_MGMT 0x06
88#define C6DOFIMU7_PWM_MGMT_L 0x80
89#define C6DOFIMU7_PWM_MGMT_H 0x01
90#define C6DOFIMU7_TEMP_OUT_H 0x39
91#define C6DOFIMU7_ACCEL_XOUT_H 0x2D
92#define C6DOFIMU7_ACCEL_YOUT_H 0x2F
93#define C6DOFIMU7_ACCEL_ZOUT_H 0x31
94#define C6DOFIMU7_GYRO_XOUT_H 0x33
95#define C6DOFIMU7_GYRO_YOUT_H 0x35
96#define C6DOFIMU7_GYRO_ZOUT_H 0x37
103#define C6DOFIMU7_TEMPERATURE_SENSITIVITY 333.87
104#define C6DOFIMU7_TEMPERATURE_OFFSET 6.3
105#define C6DOFIMU7_ACCEL_SENSITIVITY 8.192
106#define C6DOFIMU7_GYRO_SENSITIVITY 65.5
109 // End group macro
110// --------------------------------------------------------------- PUBLIC TYPES
119typedef struct
120{
121 float x_axis;
122 float y_axis;
123 float z_axis;
124
126
130typedef struct
131{
132 // Input pins
133
134 digital_in_t int2;
135 digital_in_t int1;
136
137 // Modules
138
139 i2c_master_t i2c;
140
141 // ctx variable
142
144
146
150typedef struct
151{
152 // Communication gpio pins
153
154 pin_name_t scl;
155 pin_name_t sda;
156
157 // Additional gpio pins
158
159 pin_name_t int2;
160 pin_name_t int1;
161
162 // static variable
163
164 uint32_t i2c_speed;
165 uint8_t i2c_address;
166
168
169 // End types group
170// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
171
177#ifdef __cplusplus
178extern "C"{
179#endif
180
190
200
209
220void c6dofimu7_generic_write ( c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
221
232void c6dofimu7_generic_read ( c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
233
242int16_t c6dofimu7_read_word ( c6dofimu7_t *ctx, uint8_t address );
243
253float c6dofimu7_get_temp_data ( c6dofimu7_t *ctx, float temp_sensitivity, float temp_offset );
254
264void c6dofimu7_get_accel_data ( c6dofimu7_t *ctx, c6dofimu7_axis_t *accel, float sensitivity );
265
275void c6dofimu7_get_gyro_data ( c6dofimu7_t *ctx, c6dofimu7_axis_t *gyro, float sensitivity );
276
285
294
295#ifdef __cplusplus
296}
297#endif
298#endif // _C6DOFIMU7_H_
299
300 // End public_function group
302
303// ------------------------------------------------------------------------- END
#define C6DOFIMU7_RETVAL
Definition c6dofimu7.h:76
float c6dofimu7_get_temp_data(c6dofimu7_t *ctx, float temp_sensitivity, float temp_offset)
Get temperature data function.
void c6dofimu7_cfg_setup(c6dofimu7_cfg_t *cfg)
Config Object Initialization function.
C6DOFIMU7_RETVAL c6dofimu7_init(c6dofimu7_t *ctx, c6dofimu7_cfg_t *cfg)
Initialization function.
void c6dofimu7_get_gyro_data(c6dofimu7_t *ctx, c6dofimu7_axis_t *gyro, float sensitivity)
Get gyroscope data function.
void c6dofimu7_generic_read(c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
int16_t c6dofimu7_read_word(c6dofimu7_t *ctx, uint8_t address)
Read word function.
void c6dofimu7_generic_write(c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void c6dofimu7_get_accel_data(c6dofimu7_t *ctx, c6dofimu7_axis_t *accel, float sensitivity)
Get accelerometer data function.
uint8_t c6dofimu7_get_int_input(c6dofimu7_t *ctx)
Get INT input function.
uint8_t c6dofimu7_get_pwm_input(c6dofimu7_t *ctx)
Get PWM input function.
void c6dofimu7_default_cfg(c6dofimu7_t *ctx)
Click Default Configuration function.
Sensor axis structure.
Definition c6dofimu7.h:120
float z_axis
Definition c6dofimu7.h:123
float x_axis
Definition c6dofimu7.h:121
float y_axis
Definition c6dofimu7.h:122
Click configuration structure definition.
Definition c6dofimu7.h:151
pin_name_t int1
Definition c6dofimu7.h:160
pin_name_t int2
Definition c6dofimu7.h:159
uint32_t i2c_speed
Definition c6dofimu7.h:164
pin_name_t scl
Definition c6dofimu7.h:154
pin_name_t sda
Definition c6dofimu7.h:155
uint8_t i2c_address
Definition c6dofimu7.h:165
Click ctx object definition.
Definition c6dofimu7.h:131
digital_in_t int2
Definition c6dofimu7.h:134
digital_in_t int1
Definition c6dofimu7.h:135
i2c_master_t i2c
Definition c6dofimu7.h:139
uint8_t slave_address
Definition c6dofimu7.h:143