Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
47 #define COMPASS_CTRL_REG1 0x20
48 #define COMPASS_CTRL_REG2 0x21
49 #define COMPASS_CTRL_REG3 0x22
50 #define COMPASS_CTRL_REG4 0x23
51 #define COMPASS_CTRL_REG5 0x24
52 #define COMPASS_CTRL_REG6 0x25
53 #define COMPASS_FIFO_CTRL_REG 0x2E
54 #define COMPASS_STATUS_REG 0x27
55 #define COMPASS_INT1_CFG 0x30
56 #define COMPASS_INT2_CFG 0x34
62 #define COMPASS_CRA_REG 0x00
63 #define COMPASS_CRB_REG 0x01
64 #define COMPASS_MR_REG 0x02
65 #define COMPASS_SR_REG 0x09
67 #define COMPASS_IRA_REG 0x0A
68 #define COMPASS_IRB_REG 0x0B
69 #define COMPASS_IRC_REG 0x0C
71 #define COMPASS_OUT_MAGNET_X_HIGH 0x03
72 #define COMPASS_OUT_MAGNET_X_LOW 0x04
73 #define COMPASS_OUT_MAGNET_Z_HIGH 0x05
74 #define COMPASS_OUT_MAGNET_Z_LOW 0x06
75 #define COMPASS_OUT_MAGNET_Y_HIGH 0x07
76 #define COMPASS_OUT_MAGNET_Y_LOW 0x08
78 #define COMPASS_TEMP_OUT_HIGH 0x31
79 #define COMPASS_TEMP_OUT_LOW 0x32
85 #define COMPASS_OUT_ACCEL_X_LOW 0x28
86 #define COMPASS_OUT_ACCEL_X_HIGH 0x29
87 #define COMPASS_OUT_ACCEL_Y_LOW 0x2A
88 #define COMPASS_OUT_ACCEL_Y_HIGH 0x2B
89 #define COMPASS_OUT_ACCEL_Z_LOW 0x2C
90 #define COMPASS_OUT_ACCEL_Z_HIGH 0x2D
96 #define COMPASS_MAP_MIKROBUS( cfg, mikrobus ) \
97 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
98 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
99 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_RST ); \
100 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
107 #define COMPASS_RETVAL uint8_t
109 #define COMPASS_OK 0x00
110 #define COMPASS_INIT_ERROR 0xFF
281 #endif // _COMPASS_H_
void compass_default_config(compass_t *ctx)
Default config function.
pin_name_t int_pin
Definition: compass.h:154
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.
i2c_master_t i2c
Definition: compass.h:132
uint32_t i2c_speed
Definition: compass.h:158
pin_name_t rdy
Definition: compass.h:153
digital_in_t int_pin
Definition: compass.h:128
digital_in_t rdy
Definition: compass.h:127
pin_name_t scl
Definition: compass.h:148
uint8_t i2c_magnet_address
Definition: compass.h:160
void compass_magnet_generic_read(compass_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic magnet read function.
void compass_cfg_setup(compass_cfg_t *cfg)
Config Object Initialization function.
uint8_t accel_slave_address
Definition: compass.h:136
COMPASS_RETVAL compass_init(compass_t *ctx, compass_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition: compass.h:124
uint8_t i2c_accel_address
Definition: compass.h:159
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.
#define COMPASS_RETVAL
Definition: compass.h:107
pin_name_t sda
Definition: compass.h:149
Click configuration structure definition.
Definition: compass.h:145
void compass_accel_generic_write(compass_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic accel write function.
uint8_t magnet_slave_address
Definition: compass.h:137