42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55#include "drv_spi_master.h"
68#define GAUSSMETER_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
75 cfg.trg = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
76 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
83#define GAUSSMETER_MASTER_I2C 0
84#define GAUSSMETER_MASTER_SPI 1
91#define GAUSSMETER_RETVAL uint8_t
93#define GAUSSMETER_OK 0x00
94#define GAUSSMETER_INIT_ERROR 0xFF
101#define GAUSSMETER_CONFIG1_REG 0x00
102#define GAUSSMETER_CONFIG2_REG 0x01
103#define GAUSSMETER_CONFIG3_REG 0x02
104#define GAUSSMETER_CONFIG4_REG 0x03
105#define GAUSSMETER_OFFSET_X_REG 0x04
106#define GAUSSMETER_OFFSET_Y_REG 0x05
107#define GAUSSMETER_OFFSET_Z_REG 0x06
108#define GAUSSMETER_WOCXY_THRESHOLD_REG 0x07
109#define GAUSSMETER_WOCZ_THRESHOLD_REG 0x08
110#define GAUSSMETER_WOCT_THRESHOLD_REG 0x09
112#define GAUSSMETER_GAIN_0 0x0000
113#define GAUSSMETER_GAIN_1 0x0010
114#define GAUSSMETER_GAIN_2 0x0020
115#define GAUSSMETER_GAIN_3 0x0030
116#define GAUSSMETER_GAIN_4 0x0040
117#define GAUSSMETER_GAIN_5 0x0050
118#define GAUSSMETER_GAIN_6 0x0060
119#define GAUSSMETER_GAIN_7 0x0070
120#define GAUSSMETER_BUILT_IN_SELF_TEST_DIS 0x0000
121#define GAUSSMETER_BUILT_IN_SELF_TEST_EN 0x0100
122#define GAUSSMETER_DIS_Z_MEASURE_PLATES 0x0000
123#define GAUSSMETER_EN_Z_MEASURE_PLATES 0x0080
124#define GAUSSMETER_TRIG_MODE 0x0000
125#define GAUSSMETER_INT_MODE 0x8000
126#define GAUSSMETER_SPI_ONLY 0x4000
127#define GAUSSMETER_I2C_ONLY 0x0600
128#define GAUSSMETER_BOTH_DRIVER 0x0000
129#define GAUSSMETER_WOC_DIFF_DIS 0x0000
130#define GAUSSMETER_WOC_DIFF_EN 0x1000
131#define GAUSSMETER_EXT_TRIG_DIS 0x0000
132#define GAUSSMETER_EXT_TRIG_EN 0x0800
133#define GAUSSMETER_TCMP_DIS 0x0000
134#define GAUSSMETER_TCMP_EN 0x0400
135#define GAUSSMETER_RES_0 0x0000
136#define GAUSSMETER_RES_1 0x0020
137#define GAUSSMETER_RES_2 0x0040
138#define GAUSSMETER_RES_3 0x0060
140#define GAUSSMETER_START_BURST_MODE_COMM 0x10
141#define GAUSSMETER_START_WOC_MODE_COMM 0x20
142#define GAUSSMETER_START_SINGLE_MEAS_MODE_COMM 0x30
143#define GAUSSMETER_READ_MEAS_COMM 0x40
144#define GAUSSMETER_READ_REG_COMM 0x50
145#define GAUSSMETER_WRITE_REG_COMM 0x60
146#define GAUSSMETER_EXIT_MODE_COMM 0x80
147#define GAUSSMETER_MEM_RECALL_COMM 0xD0
148#define GAUSSMETER_MEM_STORE_COMM 0xE0
149#define GAUSSMETER_RESET_COMM 0xF0
151#define GAUSSMETER_EN_Z_AXIS 0x01
152#define GAUSSMETER_DIS_Z_AXIS 0x00
153#define GAUSSMETER_EN_Y_AXIS 0x01
154#define GAUSSMETER_DIS_Y_AXIS 0x00
155#define GAUSSMETER_EN_X_AXIS 0x01
156#define GAUSSMETER_DIS_X_AXIS 0x00
157#define GAUSSMETER_EN_TEMP_MEAS 0x01
158#define GAUSSMETER_DIS_TEMP_MEAS 0x00
160#define GAUSSMETER_EN_SPI_DRIVER 0x00
161#define GAUSSMETER_DIS_SPI_DRIVER 0x01
#define GAUSSMETER_RETVAL
Definition gaussmeter.h:91
void gaussmeter_default_cfg(gaussmeter_t *ctx)
Click Default Configuration function.
void gaussmeter_generic_data_transfer(gaussmeter_t *ctx, uint8_t *write_buf, uint8_t write_len, uint8_t *read_buf, uint8_t read_len)
Generic read function.
uint8_t gaussmeter_get_data(gaussmeter_t *ctx, float *output_data)
Get data function.
uint8_t gaussmeter_digital_read_int(gaussmeter_t *ctx)
Digital read interrupt function.
uint8_t gaussmeter_write_reg(gaussmeter_t *ctx, uint8_t reg_addr, uint16_t transfer_data)
Write register function.
uint8_t gaussmeter_send_command(gaussmeter_t *ctx, uint8_t command)
Send command function.
uint8_t gaussmeter_digital_read_pwm(gaussmeter_t *ctx)
Digital read pwm function.
GAUSSMETER_RETVAL gaussmeter_init(gaussmeter_t *ctx, gaussmeter_cfg_t *cfg)
Initialization function.
void gaussmeter_enable_measure(gaussmeter_t *ctx, uint8_t temp)
Enable measure function.
void gaussmeter_cfg_setup(gaussmeter_cfg_t *cfg)
Config Object Initialization function.
uint8_t gaussmeter_select_t
Communication type.
Definition gaussmeter.h:174
struct gaussmeter_s gaussmeter_t
Click ctx object definition.
void(* gaussmeter_master_io_t)(struct gaussmeter_s *, uint8_t *, uint8_t, uint8_t *, uint8_t)
Definition gaussmeter.h:180
Auxiliary object definition.
Definition gaussmeter.h:197
uint8_t command_byte_low
Definition gaussmeter.h:198
uint16_t select_res
Definition gaussmeter.h:200
uint16_t select_gain
Definition gaussmeter.h:199
Axis object definition.
Definition gaussmeter.h:186
uint8_t x
Definition gaussmeter.h:187
uint8_t y
Definition gaussmeter.h:188
uint8_t z
Definition gaussmeter.h:189
Click configuration structure definition.
Definition gaussmeter.h:239
gaussmeter_select_t sel
Definition gaussmeter.h:263
uint32_t i2c_speed
Definition gaussmeter.h:256
spi_master_chip_select_polarity_t cs_polarity
Definition gaussmeter.h:261
pin_name_t sck
Definition gaussmeter.h:246
gaussmeter_aux_t aux
Definition gaussmeter.h:264
spi_master_mode_t spi_mode
Definition gaussmeter.h:260
pin_name_t mosi
Definition gaussmeter.h:245
uint32_t spi_speed
Definition gaussmeter.h:259
pin_name_t scl
Definition gaussmeter.h:242
pin_name_t int_pin
Definition gaussmeter.h:252
pin_name_t trg
Definition gaussmeter.h:251
pin_name_t miso
Definition gaussmeter.h:244
pin_name_t sda
Definition gaussmeter.h:243
pin_name_t cs
Definition gaussmeter.h:247
uint8_t i2c_address
Definition gaussmeter.h:257
Click ctx object definition.
Definition gaussmeter.h:208
digital_out_t cs
Definition gaussmeter.h:211
digital_in_t trg
Definition gaussmeter.h:215
spi_master_t spi
Definition gaussmeter.h:221
gaussmeter_master_io_t data_transfer_f
Definition gaussmeter.h:227
gaussmeter_aux_t aux
Definition gaussmeter.h:230
digital_in_t int_pin
Definition gaussmeter.h:216
i2c_master_t i2c
Definition gaussmeter.h:220
gaussmeter_axis_t axis
Definition gaussmeter.h:231
uint8_t slave_address
Definition gaussmeter.h:225
gaussmeter_select_t master_sel
Definition gaussmeter.h:228
pin_name_t chip_select
Definition gaussmeter.h:226