39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define COMPASS7_REG_XOUT0 0x00
74#define COMPASS7_REG_XOUT1 0x01
75#define COMPASS7_REG_YOUT0 0x02
76#define COMPASS7_REG_YOUT1 0x03
77#define COMPASS7_REG_ZOUT0 0x04
78#define COMPASS7_REG_ZOUT1 0x05
79#define COMPASS7_REG_XOUT2 0x06
80#define COMPASS7_REG_YOUT2 0x07
81#define COMPASS7_REG_ZOUT2 0x08
82#define COMPASS7_REG_TOUT 0x09
83#define COMPASS7_REG_TPH0 0x0A
84#define COMPASS7_REG_TPH1 0x0B
85#define COMPASS7_REG_TU 0x0C
86#define COMPASS7_REG_STATUS1 0x18
87#define COMPASS7_REG_STATUS0 0x19
88#define COMPASS7_REG_ODR 0x1A
89#define COMPASS7_REG_CONTROL0 0x1B
90#define COMPASS7_REG_CONTROL1 0x1C
91#define COMPASS7_REG_CONTROL2 0x1D
92#define COMPASS7_REG_ST_X_TH 0x1E
93#define COMPASS7_REG_ST_Y_TH 0x1F
94#define COMPASS7_REG_ST_Z_TH 0x20
95#define COMPASS7_REG_ST_X 0x27
96#define COMPASS7_REG_ST_Y 0x28
97#define COMPASS7_REG_ST_Z 0x29
98#define COMPASS7_REG_PRODUCT_ID 0x39
116#define COMPASS7_STATUS1_MEAS_T_DONE 0x80
117#define COMPASS7_STATUS1_MEAS_M_DONE 0x40
118#define COMPASS7_STATUS1_SAT_SENSOR 0x20
119#define COMPASS7_STATUS1_OTP_READ_DONE 0x10
120#define COMPASS7_STATUS1_ST_FAIL 0x08
121#define COMPASS7_STATUS1_MDT_FLAG_INT 0x04
122#define COMPASS7_STATUS1_MEAS_T_DONE_INT 0x02
123#define COMPASS7_STATUS1_MEAS_M_DONE_INT 0x01
129#define COMPASS7_CONTROL0_CMM_FREQ_EN 0x80
130#define COMPASS7_CONTROL0_AUTO_ST_EN 0x40
131#define COMPASS7_CONTROL0_AUTO_SR_EN 0x20
132#define COMPASS7_CONTROL0_DO_RESET 0x10
133#define COMPASS7_CONTROL0_DO_SET 0x08
134#define COMPASS7_CONTROL0_START_MDT 0x04
135#define COMPASS7_CONTROL0_TAKE_MEAS_T 0x02
136#define COMPASS7_CONTROL0_TAKE_MEAS_M 0x01
142#define COMPASS7_CONTROL1_SW_RESET 0x80
143#define COMPASS7_CONTROL1_ST_ENM 0x40
144#define COMPASS7_CONTROL1_ST_ENP 0x20
145#define COMPASS7_CONTROL1_Z_INHIBIT 0x10
146#define COMPASS7_CONTROL1_Y_INHIBIT 0x08
147#define COMPASS7_CONTROL1_X_INHIBIT 0x04
148#define COMPASS7_CONTROL1_BW_6p6MS 0x00
149#define COMPASS7_CONTROL1_BW_3p5MS 0x01
150#define COMPASS7_CONTROL1_BW_2p0MS 0x02
151#define COMPASS7_CONTROL1_BW_1p2MS 0x03
152#define COMPASS7_CONTROL1_BW_BIT_MASK 0x03
158#define COMPASS7_CONTROL2_HPOWER 0x80
159#define COMPASS7_CONTROL2_INT_MEAS_DONE_EN 0x40
160#define COMPASS7_CONTROL2_INT_MDT_EN 0x20
161#define COMPASS7_CONTROL2_CMM_EN 0x10
162#define COMPASS7_CONTROL2_EN_PRD_SET 0x08
163#define COMPASS7_CONTROL2_PRD_SET_1_SMPL 0x00
164#define COMPASS7_CONTROL2_PRD_SET_25_SMPL 0x01
165#define COMPASS7_CONTROL2_PRD_SET_75_SMPL 0x02
166#define COMPASS7_CONTROL2_PRD_SET_100_SMPL 0x03
167#define COMPASS7_CONTROL2_PRD_SET_250_SMPL 0x04
168#define COMPASS7_CONTROL2_PRD_SET_500_SMPL 0x05
169#define COMPASS7_CONTROL2_PRD_SET_1000_SMPL 0x06
170#define COMPASS7_CONTROL2_PRD_SET_2000_SMPL 0x07
171#define COMPASS7_CONTROL2_PRD_SET_BIT_MASK 0x07
177#define COMPASS7_ODR_DISABLE 0
178#define COMPASS7_ODR_1HZ 1
179#define COMPASS7_ODR_2HZ 2
180#define COMPASS7_ODR_5HZ 5
181#define COMPASS7_ODR_10HZ 10
182#define COMPASS7_ODR_25HZ 25
183#define COMPASS7_ODR_50HZ 50
184#define COMPASS7_ODR_100HZ 100
190#define COMPASS7_MAGNETIC_OFFSET 0x080000l
191#define COMPASS7_MAGNETIC_RESOLUTION 0.0625
192#define COMPASS7_MILLIGAUSS_TO_GAUSS 0.001
193#define COMPASS7_TEMPERATURE_OFFSET 75
194#define COMPASS7_TEMPERATURE_RESOLUTION 0.8
195#define COMPASS7_TIMEOUT 2000
201#define COMPASS7_MEAS_SINGLE_T 0
202#define COMPASS7_MEAS_SINGLE_M 1
203#define COMPASS7_MEAS_CONTINUOUS_M_1HZ 2
204#define COMPASS7_MEAS_CONTINUOUS_M_2HZ 3
205#define COMPASS7_MEAS_CONTINUOUS_M_5HZ 4
206#define COMPASS7_MEAS_CONTINUOUS_M_10HZ 5
207#define COMPASS7_MEAS_CONTINUOUS_M_25HZ 6
208#define COMPASS7_MEAS_CONTINUOUS_M_50HZ 7
209#define COMPASS7_MEAS_CONTINUOUS_M_100HZ 8
215#define COMPASS7_PRODUCT_ID 0x10
222#define COMPASS7_DEVICE_ADDRESS 0x30
240#define COMPASS7_MAP_MIKROBUS( cfg, mikrobus ) \
241 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
242 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
compass7_return_value_t
Compass 7 Click return value data.
Definition compass7.h:292
@ COMPASS7_OK
Definition compass7.h:293
@ COMPASS7_ERROR
Definition compass7.h:294
void compass7_cfg_setup(compass7_cfg_t *cfg)
Compass 7 configuration object setup function.
err_t compass7_set_measurement_mode(compass7_t *ctx, uint8_t mode)
Compass 7 set measurement mode function.
err_t compass7_read_register(compass7_t *ctx, uint8_t reg, uint8_t *data_out)
Compass 7 read register function.
err_t compass7_get_magnetic_flux(compass7_t *ctx, compass7_magnetic_flux_t *flux)
Compass 7 get magnetic flux function.
err_t compass7_soft_reset(compass7_t *ctx)
Compass 7 soft reset function.
err_t compass7_check_communication(compass7_t *ctx)
Compass 7 check communication function.
err_t compass7_init(compass7_t *ctx, compass7_cfg_t *cfg)
Compass 7 initialization function.
err_t compass7_write_register(compass7_t *ctx, uint8_t reg, uint8_t data_in)
Compass 7 write register function.
err_t compass7_generic_write(compass7_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Compass 7 I2C writing function.
err_t compass7_get_temperature(compass7_t *ctx, float *temperature)
Compass 7 get temperature function.
err_t compass7_generic_read(compass7_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Compass 7 I2C reading function.
err_t compass7_default_cfg(compass7_t *ctx)
Compass 7 default configuration function.
Compass 7 Click configuration object.
Definition compass7.h:266
uint32_t i2c_speed
Definition compass7.h:270
pin_name_t scl
Definition compass7.h:267
pin_name_t sda
Definition compass7.h:268
uint8_t i2c_address
Definition compass7.h:271
Compass 7 magnetic flux data object.
Definition compass7.h:280
float z_axis
Definition compass7.h:283
float x_axis
Definition compass7.h:281
float y_axis
Definition compass7.h:282
Compass 7 Click context object.
Definition compass7.h:252
i2c_master_t i2c
Definition compass7.h:254
uint8_t slave_address
Definition compass7.h:257