c3dhall6 2.0.0.0
c3dhall6.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 C3DHALL6_H
36#define C3DHALL6_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_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define C3DHALL6_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
78#define C3DHALL6_OK 0
79#define C3DHALL6_ERROR -1
86#define C3DHALL6_CHANNEL_0 0x00
87#define C3DHALL6_CHANNEL_1 0x40
88#define C3DHALL6_CHANNEL_2 0x80
89#define C3DHALL6_CHANNEL_3 0xC0
96#define C3DHALL6_DIE_A 0x01
97#define C3DHALL6_DIE_B 0x02
104#define SINGLE_PI_CONST 3.14
105#define HALF_PI_CONST 1.57
108 // End group macro
109// --------------------------------------------------------------- PUBLIC TYPES
115typedef struct
116{
117 uint16_t aux_ch0;
118 uint16_t aux_ch1;
119 uint16_t aux_ch2;
120 uint16_t aux_ch3;
121
123
124typedef struct
125{
130
132
142
157
161typedef struct
162{
163 // Communication gpio pins
164 pin_name_t miso;
165 pin_name_t mosi;
166 pin_name_t sck;
167 pin_name_t cs;
168
169 // static variable
170 uint32_t spi_speed;
171 spi_master_mode_t spi_mode;
172 spi_master_chip_select_polarity_t cs_polarity;
173
175
177
178 // End types group
179// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
180
185#ifdef __cplusplus
186extern "C"{
187#endif
188
198
208
217
231
241void c3dhall6_get_adc_value ( c3dhall6_t *ctx, uint8_t channel_no, uint16_t *adc_value );
242
252void c3dhall6_get_volt( c3dhall6_t *ctx, uint8_t channel_no, float *channel_voltage );
253
263void c3dhall6_get_angle_deg ( c3dhall6_t *ctx, uint8_t die, float *angle_value );
264
274void c3dhall6_get_angle_rad ( c3dhall6_t *ctx, uint8_t die, float *angle_value );
275
276#ifdef __cplusplus
277}
278#endif
279#endif // _C3DHALL6_H_
280
281 // End public_function group
283
284// ------------------------------------------------------------------------- END
void c3dhall6_default_cfg(c3dhall6_t *ctx)
Click Default Configuration function.
void c3dhall6_get_angle_rad(c3dhall6_t *ctx, uint8_t die, float *angle_value)
GGetting angle value function.
void c3dhall6_set_reference_values(c3dhall6_t *ctx, c3dhall6_aux_ref_t ref_val)
Setting reference values function.
void c3dhall6_get_volt(c3dhall6_t *ctx, uint8_t channel_no, float *channel_voltage)
Getting voltage on each channel function.
void c3dhall6_get_adc_value(c3dhall6_t *ctx, uint8_t channel_no, uint16_t *adc_value)
Getting ADC value on each channel function.
err_t c3dhall6_init(c3dhall6_t *ctx, c3dhall6_cfg_t *cfg)
Initialization function.
void c3dhall6_get_angle_deg(c3dhall6_t *ctx, uint8_t die, float *angle_value)
GGetting angle value function.
void c3dhall6_cfg_setup(c3dhall6_cfg_t *cfg)
Config Object Initialization function.
Definition c3dhall6.h:116
uint16_t aux_ch1
Definition c3dhall6.h:118
uint16_t aux_ch2
Definition c3dhall6.h:119
uint16_t aux_ch0
Definition c3dhall6.h:117
uint16_t aux_ch3
Definition c3dhall6.h:120
Definition c3dhall6.h:125
float aux_float_ch1
Definition c3dhall6.h:127
float aux_float_ch0
Definition c3dhall6.h:126
float aux_float_ch3
Definition c3dhall6.h:129
float aux_float_ch2
Definition c3dhall6.h:128
Definition c3dhall6.h:134
float aux_ref_adc_ch0
Definition c3dhall6.h:135
float aux_ref_adc_ch2
Definition c3dhall6.h:137
float aux_ref_adc_ch3
Definition c3dhall6.h:138
float aux_ref_volt
Definition c3dhall6.h:139
float aux_ref_adc_ch1
Definition c3dhall6.h:136
Click configuration structure definition.
Definition c3dhall6.h:162
spi_master_chip_select_polarity_t cs_polarity
Definition c3dhall6.h:172
pin_name_t sck
Definition c3dhall6.h:166
spi_master_mode_t spi_mode
Definition c3dhall6.h:171
pin_name_t mosi
Definition c3dhall6.h:165
uint32_t spi_speed
Definition c3dhall6.h:170
pin_name_t miso
Definition c3dhall6.h:164
c3dhall6_aux_ref_t dev_aux_ref
Definition c3dhall6.h:174
pin_name_t cs
Definition c3dhall6.h:167
Click ctx object definition.
Definition c3dhall6.h:147
spi_master_t spi
Definition c3dhall6.h:149
c3dhall6_aux_ref_t device_aux_ref
Definition c3dhall6.h:152
c3dhall6_aux_ch_t device_aux_ch
Definition c3dhall6.h:153
c3dhall6_aux_float_ch_t device_float_ch
Definition c3dhall6.h:154
pin_name_t chip_select
Definition c3dhall6.h:150