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"
66#define MAGNETO8_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
79#define MAGNETO8_ERROR -1
86#define MAGNETO8_REG_ZMCO 0x00
87#define MAGNETO8_REG_ZPOS_MSB 0x01
88#define MAGNETO8_REG_ZPOS_LSB 0x02
89#define MAGNETO8_REG_CONF_C1 0x07
90#define MAGNETO8_REG_CONF_C2 0x08
91#define MAGNETO8_REG_ABN 0x09
92#define MAGNETO8_REG_PUSHTHR 0x0A
99#define MAGNETO8_REG_RAW_ANGLE_MSB 0x0C
100#define MAGNETO8_REG_RAW_ANGLE_LSB 0x0D
101#define MAGNETO8_REG_ANGLE_MSB 0x0E
102#define MAGNETO8_REG_ANGLE_LSB 0x0F
109#define MAGNETO8_REG_STATUS 0x0B
110#define MAGNETO8_REG_AGC 0x1A
111#define MAGNETO8_REG_MAGNITUDE_MSB 0x1B
112#define MAGNETO8_REG_MAGNITUDE_LSB 0x1C
119#define MAGNETO8_REG_BURN 0xFF
120#define MAGNETO8_BURN_ANGLE 0x80
121#define MAGNETO8_BURN_SETTING 0x40
128#define MAGNETO8_CFG_MODE_NOM 0x0000
129#define MAGNETO8_CFG_MODE_LPM1 0x0001
130#define MAGNETO8_CFG_MODE_LPM2 0x0002
131#define MAGNETO8_CFG_MODE_LPM3 0x0003
133#define MAGNETO8_CFG_HYST_OFF 0x0000
134#define MAGNETO8_CFG_HYST_1_LSB 0x0004
135#define MAGNETO8_CFG_HYST_2_LSB 0x0008
136#define MAGNETO8_CFG_HYST_3_LSB 0x000C
138#define MAGNETO8_CFG_SF_16x 0x0000
139#define MAGNETO8_CFG_SF_8x 0x0100
140#define MAGNETO8_CFG_SF_4x 0x0200
141#define MAGNETO8_CFG_SF_2x 0x0300
143#define MAGNETO8_CFG_FTH_SLOW 0x0000
144#define MAGNETO8_CFG_FTH_6_LSB 0x0400
145#define MAGNETO8_CFG_FTH_7_LSB 0x0800
146#define MAGNETO8_CFG_FTH_9_LSB 0x0C00
147#define MAGNETO8_CFG_FTH_18_LSB 0x1000
148#define MAGNETO8_CFG_FTH_21_LSB 0x1400
149#define MAGNETO8_CFG_FTH_24_LSB 0x1800
150#define MAGNETO8_CFG_FTH_10_LSB 0x1C00
152#define MAGNETO8_CFG_WD_OFF 0x2000
153#define MAGNETO8_CFG_WD_ON 0x2000
160#define MAGNETO8_ABN_8 0x00
161#define MAGNETO8_ABN_16 0x01
162#define MAGNETO8_ABN_32 0x02
163#define MAGNETO8_ABN_64 0x03
164#define MAGNETO8_ABN_128 0x04
165#define MAGNETO8_ABN_256 0x05
166#define MAGNETO8_ABN_512 0x06
167#define MAGNETO8_ABN_1024 0x07
168#define MAGNETO8_ABN_2048 0x08
175#define MAGNETO8_STATUS_MD 0x20
176#define MAGNETO8_STATUS_ML 0x10
177#define MAGNETO8_STATUS_MH 0x08
179#define MAGNETO8_SLAVE_ADDR 0x36
uint8_t magneto8_generic_read(magneto8_t *ctx, uint8_t reg)
Generic read function.
err_t magneto8_init(magneto8_t *ctx, magneto8_cfg_t *cfg)
Initialization function.
uint8_t magneto8_get_status(magneto8_t *ctx)
Gets status data.
uint8_t magneto8_a_pin_state(magneto8_t *ctx)
Gets A pin state.
void magneto8_cfg_setup(magneto8_cfg_t *cfg)
Config Object Initialization function.
float magneto8_get_angle_data(magneto8_t *ctx)
Gets Angle data.
void magneto8_generic_write(magneto8_t *ctx, uint8_t reg, uint8_t tx_data)
Generic write function.
uint16_t magneto8_get_raw_angle(magneto8_t *ctx)
Gets Angle raw data.
uint8_t magneto8_get_zmco(magneto8_t *ctx)
Gets ZMCO data.
uint8_t magneto8_psh_pin_state(magneto8_t *ctx)
Gets PSH pin state.
uint8_t magneto8_b_pin_state(magneto8_t *ctx)
Gets B pin state.
uint8_t magneto8_get_agc(magneto8_t *ctx)
Gets AGC data.
void magneto8_default_cfg(magneto8_t *ctx)
Click Default Configuration function.
uint16_t magneto8_get_magnitude(magneto8_t *ctx)
Gets magnitude data.
Click configuration structure definition.
Definition magneto8.h:214
uint32_t i2c_speed
Definition magneto8.h:228
pin_name_t scl
Definition magneto8.h:217
pin_name_t int_pin
Definition magneto8.h:224
pin_name_t sda
Definition magneto8.h:218
pin_name_t rst
Definition magneto8.h:222
pin_name_t cs
Definition magneto8.h:223
uint8_t i2c_address
Definition magneto8.h:229
Click ctx object definition.
Definition magneto8.h:193
digital_in_t cs
Definition magneto8.h:197
digital_in_t int_pin
Definition magneto8.h:198
i2c_master_t i2c
Definition magneto8.h:202
digital_in_t rst
Definition magneto8.h:196
uint8_t slave_address
Definition magneto8.h:206