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"
61#define COMPASS_CTRL_REG1 0x20
62#define COMPASS_CTRL_REG2 0x21
63#define COMPASS_CTRL_REG3 0x22
64#define COMPASS_CTRL_REG4 0x23
65#define COMPASS_CTRL_REG5 0x24
66#define COMPASS_CTRL_REG6 0x25
67#define COMPASS_FIFO_CTRL_REG 0x2E
68#define COMPASS_STATUS_REG 0x27
69#define COMPASS_INT1_CFG 0x30
70#define COMPASS_INT2_CFG 0x34
76#define COMPASS_CRA_REG 0x00
77#define COMPASS_CRB_REG 0x01
78#define COMPASS_MR_REG 0x02
79#define COMPASS_SR_REG 0x09
81#define COMPASS_IRA_REG 0x0A
82#define COMPASS_IRB_REG 0x0B
83#define COMPASS_IRC_REG 0x0C
85#define COMPASS_OUT_MAGNET_X_HIGH 0x03
86#define COMPASS_OUT_MAGNET_X_LOW 0x04
87#define COMPASS_OUT_MAGNET_Z_HIGH 0x05
88#define COMPASS_OUT_MAGNET_Z_LOW 0x06
89#define COMPASS_OUT_MAGNET_Y_HIGH 0x07
90#define COMPASS_OUT_MAGNET_Y_LOW 0x08
92#define COMPASS_TEMP_OUT_HIGH 0x31
93#define COMPASS_TEMP_OUT_LOW 0x32
99#define COMPASS_OUT_ACCEL_X_LOW 0x28
100#define COMPASS_OUT_ACCEL_X_HIGH 0x29
101#define COMPASS_OUT_ACCEL_Y_LOW 0x2A
102#define COMPASS_OUT_ACCEL_Y_HIGH 0x2B
103#define COMPASS_OUT_ACCEL_Z_LOW 0x2C
104#define COMPASS_OUT_ACCEL_Z_HIGH 0x2D
110#define COMPASS_MAP_MIKROBUS( cfg, mikrobus ) \
111 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
112 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
113 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_RST ); \
114 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
121#define COMPASS_RETVAL uint8_t
123#define COMPASS_OK 0x00
124#define COMPASS_INIT_ERROR 0xFF
#define COMPASS_RETVAL
Definition compass.h:121
void compass_magnet_generic_write(compass_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic magnet write function.
void compass_accel_generic_read(compass_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic accel read function.
COMPASS_RETVAL compass_init(compass_t *ctx, compass_cfg_t *cfg)
Initialization function.
void compass_magnet_generic_read(compass_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic magnet read function.
void compass_read_magnet_axis(compass_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Magnet axes read function.
void compass_read_accel_axis(compass_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Accel axes read function.
void compass_accel_generic_write(compass_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic accel write function.
void compass_default_config(compass_t *ctx)
Default config function.
void compass_cfg_setup(compass_cfg_t *cfg)
Config Object Initialization function.
uint8_t i2c_magnet_address
Definition compass.h:174
uint8_t i2c_accel_address
Definition compass.h:173
uint32_t i2c_speed
Definition compass.h:172
uint8_t magnet_slave_address
Definition compass.h:151
uint8_t accel_slave_address
Definition compass.h:150
digital_in_t int_pin
Definition compass.h:142
i2c_master_t i2c
Definition compass.h:146
pin_name_t scl
Definition compass.h:162
pin_name_t int_pin
Definition compass.h:168
pin_name_t rdy
Definition compass.h:167
pin_name_t sda
Definition compass.h:163
digital_in_t rdy
Definition compass.h:141
Click configuration structure definition.
Definition compass.h:159
Click ctx object definition.
Definition compass.h:138