c3dhall2  2.0.0.0
c3dhall2.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 C3DHALL2_H
36 #define C3DHALL2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define C3DHALL2_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
55 
61 #define C3DHALL2_RETVAL uint8_t
62 #define C3DHALL2_OK 0x00
63 #define C3DHALL2_INIT_ERROR 0xFF
64 
66 #define C3DHALL2_DEF_SLAVE_ADDRESS 0x00
67 
72 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_0 0x00
73 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_1 0x20
74 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_2 0x40
75 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_3 0x60
76 #define C3DHALL2_M1_INTERRUPT_ENABLE 0x04
77 #define C3DHALL2_M1_INTERRUPT_DISABLE 0x00
78 #define C3DHALL2_M1_FAST_MODE_ENABLE 0x02
79 #define C3DHALL2_M1_FAST_MODE_DISABLE 0x00
80 #define C3DHALL2_M1_LOW_POWER_MODE_ENABLE 0x01
81 #define C3DHALL2_M1_LOW_POWER_MODE_DISABLE 0x00
82 
88 #define C3DHALL2_M2_TEMPERATURE_ENABLE 0x00
89 #define C3DHALL2_M2_TEMPERATURE_DISABLE 0x80
90 #define C3DHALL2_M2_LOW_POWER_PERIOD_100ms 0x00
91 #define C3DHALL2_M2_LOW_POWER_PERIOD_12ms 0x40
92 #define C3DHALL2_M2_PARITY_TEST_ENABLE 0x00
93 #define C3DHALL2_M2_PARITY_TEST_DISABLE 0x20
94  // End group macro
97 // --------------------------------------------------------------- PUBLIC TYPES
106 typedef struct
107 {
108 
109  // Modules
110 
111  i2c_master_t i2c;
112 
113  // ctx variable
114 
115  uint8_t slave_address;
116 
117 } c3dhall2_t;
118 
122 typedef struct
123 {
124  // Communication gpio pins
125 
126  pin_name_t scl;
127  pin_name_t sda;
128 
129  // static variable
130 
131  uint32_t i2c_speed;
132  uint8_t i2c_address;
133 
135  // End types group
137 
138 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
139 
145 #ifdef __cplusplus
146 extern "C"{
147 #endif
148 
157 void c3dhall2_cfg_setup ( c3dhall2_cfg_t *cfg );
158 
168 
177 void c3dhall2_default_cfg ( c3dhall2_t *ctx );
178 
188 void c3dhall2_write_data ( c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len );
189 
199 void c3dhall2_read_data ( c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len );
200 
210 void c3dhall2_get_axis_temp_data ( c3dhall2_t *ctx, float *axis_data, float *temp_data );
211 
234 void c3dhall2_configuration ( c3dhall2_t *ctx, uint8_t settings1, uint8_t settings2 );
235 
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 #endif // _C3DHALL2_H_
241  // End public_function group
244 
245 // ------------------------------------------------------------------------- END
void c3dhall2_get_axis_temp_data(c3dhall2_t *ctx, float *axis_data, float *temp_data)
Functions for getting Hall axis data and Temperature data.
#define C3DHALL2_RETVAL
Definition: c3dhall2.h:61
void c3dhall2_cfg_setup(c3dhall2_cfg_t *cfg)
Config Object Initialization function.
void c3dhall2_write_data(c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len)
Generic write function.
uint8_t slave_address
Definition: c3dhall2.h:115
C3DHALL2_RETVAL c3dhall2_init(c3dhall2_t *ctx, c3dhall2_cfg_t *cfg)
Initialization function.
uint8_t i2c_address
Definition: c3dhall2.h:132
Click configuration structure definition.
Definition: c3dhall2.h:122
pin_name_t sda
Definition: c3dhall2.h:127
uint32_t i2c_speed
Definition: c3dhall2.h:131
void c3dhall2_configuration(c3dhall2_t *ctx, uint8_t settings1, uint8_t settings2)
Functions for settings chip for measurement.
Click ctx object definition.
Definition: c3dhall2.h:106
i2c_master_t i2c
Definition: c3dhall2.h:111
void c3dhall2_default_cfg(c3dhall2_t *ctx)
Default configuration initialization function.
void c3dhall2_read_data(c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len)
Generic read function.
pin_name_t scl
Definition: c3dhall2.h:126