compass4 2.0.0.0
compass4.h File Reference

This file contains API for Compass 4 Click driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"
#include "drv_spi_master.h"

Go to the source code of this file.

Data Structures

struct  compass4_axis_t
 
struct  compass4_flux_t
 
struct  compass4_s
 Click ctx object definition. More...
 
struct  compass4_cfg_t
 Click configuration structure definition. More...
 

Macros

#define COMPASS4_MAP_MIKROBUS(cfg, mikrobus)
 
#define COMPASS4_MASTER_I2C   0
 
#define COMPASS4_MASTER_SPI   1
 
#define COMPASS4_RETVAL   uint8_t
 
#define COMPASS4_OK   0x00
 
#define COMPASS4_INIT_ERROR   0xFF
 
#define COMPASS4_REG_COMPANY_ID   0x00
 
#define COMPASS4_REG_DEVICE_ID   0x01
 
#define COMPASS4_REG_INFO   0x03
 
#define COMPASS4_REG_STATUS_1   0x10
 
#define COMPASS4_REG_X_AXIS_LSB   0x11
 
#define COMPASS4_REG_X_AXIS_MSB   0x12
 
#define COMPASS4_REG_Y_AXIS_LSB   0x13
 
#define COMPASS4_REG_Y_AXIS_MSB   0x14
 
#define COMPASS4_REG_Z_AXIS_LSB   0x15
 
#define COMPASS4_REG_Z_AXIS_MSB   0x16
 
#define COMPASS4_REG_TMPS   0x17
 
#define COMPASS4_REG_STATUS_2   0x18
 
#define COMPASS4_REG_CONTROL_1   0x30
 
#define COMPASS4_REG_CONTROL_2   0x31
 
#define COMPASS4_REG_CONTROL_3   0x32
 
#define COMPASS4_REG_TS_1   0x33
 
#define COMPASS4_REG_TS_2   0x34
 
#define COMPASS4_REG_TS_3   0x35
 
#define COMPASS4_REG_I2C_DISABLE   0x36
 
#define COMPASS4_REG_TS_4   0x37
 
#define COMPASS4_REG_ASAX   0x60
 
#define COMPASS4_REG_ASAY   0x61
 
#define COMPASS4_REG_ASAZ   0x62
 
#define COMPASS4_REG_TPH_1   0xC0
 
#define COMPASS4_REG_TPH_2   0xC1
 
#define COMPASS4_REG_RR   0xC2
 
#define COMPASS4_REG_SYT   0xC3
 
#define COMPASS4_REG_DT   0xC4
 
#define COMPASS4_DEF_COMPANY_ID   0x48
 
#define COMPASS4_DEF_DEVICE_ID   0x10
 
#define COMPASS4_CTRL1_WM_STEP_1   0x00
 
#define COMPASS4_CTRL1_WM_STEPS_2   0x01
 
#define COMPASS4_CTRL1_WM_STEPS_3   0x02
 
#define COMPASS4_CTRL1_WM_STEPS_4   0x03
 
#define COMPASS4_CTRL1_WM_STEPS_5   0x04
 
#define COMPASS4_CTRL1_WM_STEPS_6   0x05
 
#define COMPASS4_CTRL1_WM_STEPS_7   0x06
 
#define COMPASS4_CTRL1_WM_STEPS_8   0x07
 
#define COMPASS4_CTRL1_WM_STEPS_9   0x08
 
#define COMPASS4_CTRL1_WM_STEPS_10   0x09
 
#define COMPASS4_CTRL1_WM_STEPS_11   0x0A
 
#define COMPASS4_CTRL1_WM_STEPS_12   0x0B
 
#define COMPASS4_CTRL1_WM_STEPS_13   0x0C
 
#define COMPASS4_CTRL1_WM_STEPS_14   0x0D
 
#define COMPASS4_CTRL1_WM_STEPS_15   0x0E
 
#define COMPASS4_CTRL1_WM_STEPS_16   0x0F
 
#define COMPASS4_CTRL1_WM_STEPS_17   0x10
 
#define COMPASS4_CTRL1_WM_STEPS_18   0x11
 
#define COMPASS4_CTRL1_WM_STEPS_19   0x12
 
#define COMPASS4_CTRL1_WM_STEPS_20   0x13
 
#define COMPASS4_CTRL1_WM_STEPS_21   0x14
 
#define COMPASS4_CTRL1_WM_STEPS_22   0x15
 
#define COMPASS4_CTRL1_WM_STEPS_23   0x16
 
#define COMPASS4_CTRL1_WM_STEPS_24   0x17
 
#define COMPASS4_CTRL1_WM_STEPS_25   0x18
 
#define COMPASS4_CTRL1_WM_STEPS_26   0x19
 
#define COMPASS4_CTRL1_WM_STEPS_27   0x1A
 
#define COMPASS4_CTRL1_WM_STEPS_28   0x1B
 
#define COMPASS4_CTRL1_WM_STEPS_29   0x1C
 
#define COMPASS4_CTRL1_WM_STEPS_30   0x1D
 
#define COMPASS4_CTRL1_WM_STEPS_31   0x1E
 
#define COMPASS4_CTRL1_WM_STEPS_32   0x1F
 
#define COMPASS4_CTRL1_NOISE_DISABLE   0x00
 
#define COMPASS4_CTRL1_NOISE_ENABLE   0x20
 
#define COMPASS4_CTRL2_MODE_POWER_DOWN   0x00
 
#define COMPASS4_CTRL2_MODE_SINGLE   0x01
 
#define COMPASS4_CTRL2_MODE_CONT_1   0x02
 
#define COMPASS4_CTRL2_MODE_CONT_2   0x04
 
#define COMPASS4_CTRL2_MODE_CONT_3   0x06
 
#define COMPASS4_CTRL2_MODE_CONT_4   0x08
 
#define COMPASS4_CTRL2_MODE_CONT_5   0x0A
 
#define COMPASS4_CTRL2_MODE_CONT_6   0x0C
 
#define COMPASS4_CTRL2_MODE_SELF_TEST   0x10
 
#define COMPASS4_CTRL2_SDR_LOW_POWER   0x00
 
#define COMPASS4_CTRL2_SDR_LOW_NOISE   0x40
 
#define COMPASS4_CTRL2_FIFO_ENABLE   0x80
 
#define COMPASS4_CTRL2_FIFO_DISABLE   0x00
 
#define COMPASS4_CTRL3_SOFT_RESET   0x01
 
#define COMPASS4_SLAVE_ADDRESS_GND_GND   0x0C
 
#define COMPASS4_SLAVE_ADDRESS_GND_VCC   0x0D
 
#define COMPASS4_SLAVE_ADDRESS_VCC_GND   0x0E
 
#define COMPASS4_SLAVE_ADDRESS_VCC_VCC   0x0F
 
#define COMPASS4_GET_STATUS_1   0x01
 
#define COMPASS4_GET_STATUS_2   0x02
 
#define COMPASS4_X_AXIS_DATA   0x11
 
#define COMPASS4_Y_AXIS_DATA   0x13
 
#define COMPASS4_Z_AXIS_DATA   0x15
 
#define FLUX_CONSTANT   0.15
 

Typedefs

typedef uint8_t compass4_select_t
 Communication type.
 
typedef void(* compass4_master_io_t) (struct compass4_s *, uint8_t, uint8_t *, uint8_t)
 Master Input/Output type.
 
typedef struct compass4_s compass4_t
 Click ctx object definition.
 

Functions

void compass4_cfg_setup (compass4_cfg_t *cfg)
 Config Object Initialization function.
 
COMPASS4_RETVAL compass4_init (compass4_t *ctx, compass4_cfg_t *cfg)
 Initialization function.
 
void compass4_generic_write (compass4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function.
 
void compass4_generic_read (compass4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function.
 
void compass4_hardware_reset (compass4_t *ctx)
 Hardware reset function.
 
void compass4_set_rst_pin_state (compass4_t *ctx, uint8_t state)
 Sets RST pin state.
 
void compass4_software_reset (compass4_t *ctx)
 Software reset function.
 
void compass4_configuration (compass4_t *ctx, uint8_t cfg1, uint8_t cfg2)
 Configuration function.
 
uint8_t compass4_get_status (compass4_t *ctx, uint8_t status)
 Get status.
 
uint8_t compass4_check_device (compass4_t *ctx)
 Check device function.
 
uint8_t compass4_get_interrupt (compass4_t *ctx)
 Gets INT pin state (DRDY pin)
 
uint8_t compass4_get_axis (compass4_t *ctx, compass4_axis_t *axis)
 Gets X\Y\Z Axis value.
 
uint8_t compass4_get_single_axis (compass4_t *ctx, uint8_t axis_reg, int16_t *axis_data)
 Gets single axis value.
 
uint8_t compass4_get_magnetic_flux (compass4_t *ctx, compass4_flux_t *flux)
 Gets magnetic flux of X\Y\Z axis value.
 
uint8_t compass4_get_single_magnetic_flux (compass4_t *ctx, uint8_t axis, float *flux_data)
 Gets single axis flux value.
 

Detailed Description

This file contains API for Compass 4 Click driver.