42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
54#include "drv_spi_master.h"
67#define GEOMAGNETIC_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
71 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
72 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
73 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
74 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
81#define GEOMAGNETIC_MASTER_I2C 0
82#define GEOMAGNETIC_MASTER_SPI 1
89#define GEOMAGNETIC_RETVAL uint8_t
91#define GEOMAGNETIC_OK 0x00
92#define GEOMAGNETIC_INIT_ERROR 0xFF
99#define GEOMAG_DUMMY 0x00
100#define GEOMAG_SPI_INTERFACE 0x00
101#define GEOMAG_I2C_INTERFACE 0x01
102#define GEOMAG_READ_CMD 0x80
103#define GEOMAG_DEV_ADDR 0x10
104#define GEOMAG_ID_REG 0x40
105#define GEOMAG_RESERVED1_REG 0x41
106#define GEOMAG_DATAX_LSB_REG 0x42
107#define GEOMAG_DATAX_MSB_REG 0x43
108#define GEOMAG_DATAY_LSB_REG 0x44
109#define GEOMAG_DATAY_MSB_REG 0x45
110#define GEOMAG_DATAZ_LSB_REG 0x46
111#define GEOMAG_DATAZ_MSB_REG 0x47
112#define GEOMAG_RHALL_LSB_REG 0x48
113#define GEOMAG_RHALL_MSB_REG 0x49
114#define GEOMAG_INTERRUPT_STATUS_REG 0x4A
115#define GEOMAG_POWER_AND_RESET_CON_REG 0x4B
116#define GEOMAG_DATARATE_AND_OPMODE_CON_REG 0x4C
117#define GEOMAG_INTERR_AND_AXIS_EN_REG 0x4D
118#define GEOMAG_INTERR_AND_CHANNEL_EN_REG 0x4E
119#define GEOMAG_LOW_THRESHOLD_REG 0x4F
120#define GEOMAG_HIGH_THRESHOLD_REG 0x50
121#define GEOMAG_REPETITION_XY_CON_REG 0x51
122#define GEOMAG_REPETITION_Z_CON_REG 0x52
123#define GEOMAG_RESERVED2_REG 0x53
124#define GEOMAG_RESERVED3_REG 0x54
125#define GEOMAG_RESERVED4_REG 0x55
126#define GEOMAG_RESERVED5_REG 0x56
127#define GEOMAG_RESERVED6_REG 0x57
128#define GEOMAG_RESERVED7_REG 0x58
129#define GEOMAG_RESERVED8_REG 0x59
130#define GEOMAG_RESERVED9_REG 0x5A
131#define GEOMAG_RESERVED10_REG 0x5B
132#define GEOMAG_RESERVED11_REG 0x5C
133#define GEOMAG_RESERVED12_REG 0x5D
134#define GEOMAG_RESERVED13_REG 0x5E
135#define GEOMAG_RESERVED14_REG 0x5F
136#define GEOMAG_RESERVED15_REG 0x60
137#define GEOMAG_RESERVED16_REG 0x61
138#define GEOMAG_RESERVED17_REG 0x62
139#define GEOMAG_RESERVED18_REG 0x63
140#define GEOMAG_RESERVED19_REG 0x64
141#define GEOMAG_RESERVED20_REG 0x65
142#define GEOMAG_RESERVED21_REG 0x66
143#define GEOMAG_RESERVED22_REG 0x67
144#define GEOMAG_RESERVED23_REG 0x68
145#define GEOMAG_RESERVED24_REG 0x69
146#define GEOMAG_RESERVED25_REG 0x6A
147#define GEOMAG_RESERVED26_REG 0x6B
148#define GEOMAG_RESERVED27_REG 0x6C
149#define GEOMAG_RESERVED28_REG 0x6D
150#define GEOMAG_RESERVED29_REG 0x6E
151#define GEOMAG_RESERVED30_REG 0x6F
152#define GEOMAG_RESERVED31_REG 0x70
153#define GEOMAG_RESERVED32_REG 0x71
154#define GEOMAG_OK 0x00
155#define GEOMAG_ADDR_ERR 0x01
156#define GEOMAG_INTERRUPT_OCCURED 0x02
157#define GEOMAG_NBYTES_ERR 0x03
158#define GEOMAG_DATA_READY 0x01
159#define GEOMAG_DATA_NOT_READY 0x00
160#define GEOMAG_SUSPEND_MODE_SPI4_EN 0x00
161#define GEOMAG_SLEEP_MODE 0x01
162#define GEOMAG_SOFT_RESET_EN 0x82
163#define GEOMAG_SPI3_EN 0x04
164#define GEOMAG_NORMAL_OPMODE_DR_10HZ 0x00
165#define GEOMAG_FORCED_OPMODE 0x02
166#define GEOMAG_SLEEP_OPMODE 0x06
167#define GEOMAG_DR_2HZ 0x08
168#define GEOMAG_DR_6HZ 0x10
169#define GEOMAG_DR_8HZ 0x18
170#define GEOMAG_DR_15HZ 0x20
171#define GEOMAG_DR_20HZ 0x28
172#define GEOMAG_DR_25HZ 0x30
173#define GEOMAG_DR_30HZ 0x38
174#define GEOMAG_INTERR_DISABLED_THRESHOLDS_ENABLED 0x00
175#define GEOMAG_LOWTHRESHOLD_X_DISABLED 0x01
176#define GEOMAG_LOWTHRESHOLD_Y_DISABLED 0x02
177#define GEOMAG_LOWTHRESHOLD_Z_DISABLED 0x04
178#define GEOMAG_HIGHTHRESHOLD_X_DISABLED 0x08
179#define GEOMAG_HIGHTHRESHOLD_Y_DISABLED 0x10
180#define GEOMAG_HIGHTHRESHOLD_Z_DISABLED 0x20
181#define GEOMAG_OVERFLOW_PIN_IND_EN 0x40
182#define GEOMAG_DATAOVERRUN_IND_EN 0x80
183#define GEOMAG_CHANNELS_ENABLED_INTERR_DATAREADY_ACTIVE_LOW 0x00
184#define GEOMAG_INTERR_PIN_ACTIVE_HIGH 0x01
185#define GEOMAG_INTERR_LATCHED 0x02
186#define GEOMAG_DATAREADY_ACTIVE_HIGH 0x04
187#define GEOMAG_CHANNEL_X_DISABLED 0x08
188#define GEOMAG_CHANNEL_Y_DISABLED 0x10
189#define GEOMAG_CHANNEL_Z_DISABLED 0x20
190#define GEOMAG_INTERR_PIN_EN 0x40
191#define GEOMAG_DATAREADY_PIN_EN 0x80
387*geomag_axis, uint16_t *resolution_hall );
#define GEOMAGNETIC_RETVAL
Definition geomagnetic.h:89
GEOMAGNETIC_RETVAL geomagnetic_write_byte(geomagnetic_t *ctx, uint8_t input_data, uint8_t address)
Write byte function.
GEOMAGNETIC_RETVAL geomagnetic_init(geomagnetic_t *ctx, geomagnetic_cfg_t *cfg)
Initialization function.
uint8_t get_interrupt(geomagnetic_t *ctx)
Get interrupt function.
void geomagnetic_software_reset(geomagnetic_t *ctx)
Software reset function.
void geomagnetic_generic_read(geomagnetic_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void geomagnetic_cfg_setup(geomagnetic_cfg_t *cfg)
Config Object Initialization function.
void geomagnetic_generic_write(geomagnetic_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
GEOMAGNETIC_RETVAL geomagnetic_check_interrupt(geomagnetic_t *ctx)
Check interrupt function.
void geomagnetic_read_axis_data(geomagnetic_t *ctx, geomagnetic_axis_t *geomag_axis, uint16_t *resolution_hall)
Read axis data function.
uint8_t geomagnetic_check_ready(geomagnetic_t *ctx)
Check ready function.
GEOMAGNETIC_RETVAL geomagnetic_read_data(geomagnetic_t *ctx, uint8_t *out_buf, uint8_t address, uint8_t len)
Read data function.
void geomagnetic_default_cfg(geomagnetic_t *ctx)
Click Default Configuration function.
void geomagnetic_power_on_reset(geomagnetic_t *ctx)
Power ON reset function.
struct geomagnetic_s geomagnetic_t
Click ctx object definition.
void(* geomagnetic_master_io_t)(struct geomagnetic_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition geomagnetic.h:209
uint8_t geomagnetic_select_t
Communication type.
Definition geomagnetic.h:204
GeoMagnetic axis structure.
Definition geomagnetic.h:215
int16_t x_axis
Definition geomagnetic.h:216
int16_t z_axis
Definition geomagnetic.h:218
int16_t y_axis
Definition geomagnetic.h:217
Click configuration structure definition.
Definition geomagnetic.h:254
geomagnetic_select_t sel
Definition geomagnetic.h:277
uint32_t i2c_speed
Definition geomagnetic.h:270
spi_master_chip_select_polarity_t cs_polarity
Definition geomagnetic.h:275
pin_name_t sck
Definition geomagnetic.h:261
spi_master_mode_t spi_mode
Definition geomagnetic.h:274
pin_name_t mosi
Definition geomagnetic.h:260
uint32_t spi_speed
Definition geomagnetic.h:273
pin_name_t scl
Definition geomagnetic.h:257
pin_name_t int_pin
Definition geomagnetic.h:266
pin_name_t miso
Definition geomagnetic.h:259
pin_name_t sda
Definition geomagnetic.h:258
pin_name_t cs
Definition geomagnetic.h:262
uint8_t i2c_address
Definition geomagnetic.h:271
Click ctx object definition.
Definition geomagnetic.h:226
digital_out_t cs
Definition geomagnetic.h:229
geomagnetic_master_io_t read_f
Definition geomagnetic.h:245
spi_master_t spi
Definition geomagnetic.h:238
digital_in_t int_pin
Definition geomagnetic.h:233
i2c_master_t i2c
Definition geomagnetic.h:237
uint8_t slave_address
Definition geomagnetic.h:242
geomagnetic_master_io_t write_f
Definition geomagnetic.h:244
pin_name_t chip_select
Definition geomagnetic.h:243
geomagnetic_select_t master_sel
Definition geomagnetic.h:246