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 
62 #define C3DHALL2_DEVICE_ADDRESS 0x5E
63 
68 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_0 0x00
69 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_1 0x20
70 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_2 0x40
71 #define C3DHALL2_M1_I2C_SLAVE_ADDRESS_3 0x60
72 #define C3DHALL2_M1_INTERRUPT_ENABLE 0x04
73 #define C3DHALL2_M1_INTERRUPT_DISABLE 0x00
74 #define C3DHALL2_M1_FAST_MODE_ENABLE 0x02
75 #define C3DHALL2_M1_FAST_MODE_DISABLE 0x00
76 #define C3DHALL2_M1_LOW_POWER_MODE_ENABLE 0x01
77 #define C3DHALL2_M1_LOW_POWER_MODE_DISABLE 0x00
78 
84 #define C3DHALL2_M2_TEMPERATURE_ENABLE 0x00
85 #define C3DHALL2_M2_TEMPERATURE_DISABLE 0x80
86 #define C3DHALL2_M2_LOW_POWER_PERIOD_100MS 0x00
87 #define C3DHALL2_M2_LOW_POWER_PERIOD_12MS 0x40
88 #define C3DHALL2_M2_PARITY_TEST_ENABLE 0x00
89 #define C3DHALL2_M2_PARITY_TEST_DISABLE 0x20
90  // End group macro
93 // --------------------------------------------------------------- PUBLIC TYPES
102 typedef struct
103 {
104 
105  // Modules
106 
107  i2c_master_t i2c;
108 
109  // ctx variable
110 
111  uint8_t slave_address;
112 
113 } c3dhall2_t;
114 
118 typedef struct
119 {
120  // Communication gpio pins
121 
122  pin_name_t scl;
123  pin_name_t sda;
124 
125  // static variable
126 
127  uint32_t i2c_speed;
128  uint8_t i2c_address;
129 
131 
136 typedef enum
137 {
139  C3DHALL2_ERROR = -1
140 
142  // End types group
144 
145 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
146 
152 #ifdef __cplusplus
153 extern "C"{
154 #endif
155 
165 
175 
185 
195 err_t c3dhall2_write_data ( c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len );
196 
206 err_t c3dhall2_read_data ( c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len );
207 
217 err_t c3dhall2_get_axis_temp_data ( c3dhall2_t *ctx, float *axis_data, float *temp_data );
218 
241 err_t c3dhall2_configuration ( c3dhall2_t *ctx, uint8_t settings1, uint8_t settings2 );
242 
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 #endif // _C3DHALL2_H_
248  // End public_function group
251 
252 // ------------------------------------------------------------------------- END
c3dhall2_t::i2c
i2c_master_t i2c
Definition: c3dhall2.h:107
c3dhall2_get_axis_temp_data
err_t c3dhall2_get_axis_temp_data(c3dhall2_t *ctx, float *axis_data, float *temp_data)
Functions for getting Hall axis data and Temperature data.
c3dhall2_write_data
err_t c3dhall2_write_data(c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len)
Generic write function.
c3dhall2_default_cfg
err_t c3dhall2_default_cfg(c3dhall2_t *ctx)
Default configuration initialization function.
c3dhall2_configuration
err_t c3dhall2_configuration(c3dhall2_t *ctx, uint8_t settings1, uint8_t settings2)
Functions for settings chip for measurement.
c3dhall2_cfg_t::i2c_address
uint8_t i2c_address
Definition: c3dhall2.h:128
c3dhall2_t
Click ctx object definition.
Definition: c3dhall2.h:103
c3dhall2_cfg_t::sda
pin_name_t sda
Definition: c3dhall2.h:123
c3dhall2_cfg_setup
void c3dhall2_cfg_setup(c3dhall2_cfg_t *cfg)
Config Object Initialization function.
C3DHALL2_OK
@ C3DHALL2_OK
Definition: c3dhall2.h:138
C3DHALL2_ERROR
@ C3DHALL2_ERROR
Definition: c3dhall2.h:139
c3dhall2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: c3dhall2.h:127
c3dhall2_read_data
err_t c3dhall2_read_data(c3dhall2_t *ctx, uint8_t *data_buf, uint16_t len)
Generic read function.
c3dhall2_init
err_t c3dhall2_init(c3dhall2_t *ctx, c3dhall2_cfg_t *cfg)
Initialization function.
c3dhall2_cfg_t
Click configuration structure definition.
Definition: c3dhall2.h:119
c3dhall2_t::slave_address
uint8_t slave_address
Definition: c3dhall2.h:111
c3dhall2_return_value_t
c3dhall2_return_value_t
3D Hall 2 Click return value data.
Definition: c3dhall2.h:137
c3dhall2_cfg_t::scl
pin_name_t scl
Definition: c3dhall2.h:122