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 
38 #include "drv_digital_in.h"
39 #include "drv_i2c_master.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define C6DOFIMU7_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
53  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
54  cfg.int2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
55  cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_INT )
56 
62 #define C6DOFIMU7_RETVAL uint8_t
63 
64 #define C6DOFIMU7_OK 0x00
65 #define C6DOFIMU7_INIT_ERROR 0xFF
66 
72 #define C6DOFIMU7_SLAVE_ADDRESS 0x68
73 #define C6DOFIMU7_PWR_MGMT 0x06
74 #define C6DOFIMU7_PWM_MGMT_L 0x80
75 #define C6DOFIMU7_PWM_MGMT_H 0x01
76 #define C6DOFIMU7_TEMP_OUT_H 0x39
77 #define C6DOFIMU7_ACCEL_XOUT_H 0x2D
78 #define C6DOFIMU7_ACCEL_YOUT_H 0x2F
79 #define C6DOFIMU7_ACCEL_ZOUT_H 0x31
80 #define C6DOFIMU7_GYRO_XOUT_H 0x33
81 #define C6DOFIMU7_GYRO_YOUT_H 0x35
82 #define C6DOFIMU7_GYRO_ZOUT_H 0x37
83 
89 #define C6DOFIMU7_TEMPERATURE_SENSITIVITY 333.87
90 #define C6DOFIMU7_TEMPERATURE_OFFSET 6.3
91 #define C6DOFIMU7_ACCEL_SENSITIVITY 8.192
92 #define C6DOFIMU7_GYRO_SENSITIVITY 65.5
93  // End group macro
96 // --------------------------------------------------------------- PUBLIC TYPES
105 typedef struct
106 {
107  float x_axis;
108  float y_axis;
109  float z_axis;
110 
112 
116 typedef struct
117 {
118  // Input pins
119 
120  digital_in_t int2;
121  digital_in_t int1;
122 
123  // Modules
124 
125  i2c_master_t i2c;
126 
127  // ctx variable
128 
129  uint8_t slave_address;
130 
131 } c6dofimu7_t;
132 
136 typedef struct
137 {
138  // Communication gpio pins
139 
140  pin_name_t scl;
141  pin_name_t sda;
142 
143  // Additional gpio pins
144 
145  pin_name_t int2;
146  pin_name_t int1;
147 
148  // static variable
149 
150  uint32_t i2c_speed;
151  uint8_t i2c_address;
152 
154  // End types group
156 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
157 
163 #ifdef __cplusplus
164 extern "C"{
165 #endif
166 
176 
186 
195 
206 void c6dofimu7_generic_write ( c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
207 
218 void c6dofimu7_generic_read ( c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
219 
228 int16_t c6dofimu7_read_word ( c6dofimu7_t *ctx, uint8_t address );
229 
239 float c6dofimu7_get_temp_data ( c6dofimu7_t *ctx, float temp_sensitivity, float temp_offset );
240 
250 void c6dofimu7_get_accel_data ( c6dofimu7_t *ctx, c6dofimu7_axis_t *accel, float sensitivity );
251 
261 void c6dofimu7_get_gyro_data ( c6dofimu7_t *ctx, c6dofimu7_axis_t *gyro, float sensitivity );
262 
271 
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 #endif // _C6DOFIMU7_H_
285  // End public_function group
288 
289 // ------------------------------------------------------------------------- END
c6dofimu7_cfg_t::int1
pin_name_t int1
Definition: c6dofimu7.h:146
c6dofimu7_t::int2
digital_in_t int2
Definition: c6dofimu7.h:120
c6dofimu7_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: c6dofimu7.h:150
c6dofimu7_cfg_t::scl
pin_name_t scl
Definition: c6dofimu7.h:140
C6DOFIMU7_RETVAL
#define C6DOFIMU7_RETVAL
Definition: c6dofimu7.h:62
c6dofimu7_axis_t::z_axis
float z_axis
Definition: c6dofimu7.h:109
c6dofimu7_axis_t::x_axis
float x_axis
Definition: c6dofimu7.h:107
c6dofimu7_generic_read
void c6dofimu7_generic_read(c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
c6dofimu7_cfg_t
Click configuration structure definition.
Definition: c6dofimu7.h:137
c6dofimu7_cfg_t::i2c_address
uint8_t i2c_address
Definition: c6dofimu7.h:151
c6dofimu7_cfg_setup
void c6dofimu7_cfg_setup(c6dofimu7_cfg_t *cfg)
Config Object Initialization function.
c6dofimu7_get_int_input
uint8_t c6dofimu7_get_int_input(c6dofimu7_t *ctx)
Get INT input function.
c6dofimu7_get_gyro_data
void c6dofimu7_get_gyro_data(c6dofimu7_t *ctx, c6dofimu7_axis_t *gyro, float sensitivity)
Get gyroscope data function.
c6dofimu7_read_word
int16_t c6dofimu7_read_word(c6dofimu7_t *ctx, uint8_t address)
Read word function.
c6dofimu7_axis_t
Sensor axis structure.
Definition: c6dofimu7.h:106
c6dofimu7_get_pwm_input
uint8_t c6dofimu7_get_pwm_input(c6dofimu7_t *ctx)
Get PWM input function.
c6dofimu7_t::i2c
i2c_master_t i2c
Definition: c6dofimu7.h:125
c6dofimu7_cfg_t::sda
pin_name_t sda
Definition: c6dofimu7.h:141
c6dofimu7_cfg_t::int2
pin_name_t int2
Definition: c6dofimu7.h:145
c6dofimu7_generic_write
void c6dofimu7_generic_write(c6dofimu7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
c6dofimu7_t
Click ctx object definition.
Definition: c6dofimu7.h:117
c6dofimu7_axis_t::y_axis
float y_axis
Definition: c6dofimu7.h:108
c6dofimu7_t::int1
digital_in_t int1
Definition: c6dofimu7.h:121
c6dofimu7_default_cfg
void c6dofimu7_default_cfg(c6dofimu7_t *ctx)
Click Default Configuration function.
c6dofimu7_get_temp_data
float c6dofimu7_get_temp_data(c6dofimu7_t *ctx, float temp_sensitivity, float temp_offset)
Get temperature data function.
c6dofimu7_init
C6DOFIMU7_RETVAL c6dofimu7_init(c6dofimu7_t *ctx, c6dofimu7_cfg_t *cfg)
Initialization function.
c6dofimu7_get_accel_data
void c6dofimu7_get_accel_data(c6dofimu7_t *ctx, c6dofimu7_axis_t *accel, float sensitivity)
Get accelerometer data function.
c6dofimu7_t::slave_address
uint8_t slave_address
Definition: c6dofimu7.h:129