compass2 2.0.0.0
compass2.h File Reference

This file contains API for Compass 2 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  compass2_s
 Click ctx object definition. More...
 
struct  compass2_cfg_t
 Click configuration structure definition. More...
 

Macros

#define COMPASS2_MAP_MIKROBUS(cfg, mikrobus)
 
#define COMPASS2_MASTER_I2C   0
 
#define COMPASS2_MASTER_SPI   1
 
#define COMPASS2_RETVAL   uint8_t
 
#define COMPASS2_OK   0x00
 
#define COMPASS2_INIT_ERROR   0xFF
 
#define COMPASS2_REG_DEVICE_ID   0x00
 
#define COMPASS2_REG_INFORMATION   0x01
 
#define COMPASS2_REG_STATUS_1   0x02
 
#define COMPASS2_REG_AXIS_X_LOW   0x03
 
#define COMPASS2_REG_AXIS_X_HIGH   0x04
 
#define COMPASS2_REG_AXIS_Y_LOW   0x05
 
#define COMPASS2_REG_AXIS_Y_HIGH   0x06
 
#define COMPASS2_REG_AXIS_Z_LOW   0x07
 
#define COMPASS2_REG_AXIS_Z_HIGH   0x08
 
#define COMPASS2_REG_STATUS_2   0x09
 
#define COMPASS2_REG_CNTRL1   0x0A
 
#define COMPASS2_REG_CNTRL2   0x0B
 
#define COMPASS2_REG_SELF_TEST   0x0C
 
#define COMPASS2_REG_TEST_1   0x0D
 
#define COMPASS2_REG_TEST_2   0x0E
 
#define COMPASS2_REG_I2C_DISABLE   0x0F
 
#define COMPASS2_REG_X_AXIS_SENS   0x10
 
#define COMPASS2_REG_Y_AXIS_SENS   0x11
 
#define COMPASS2_REG_Z_AXIS_SENS   0x12
 
#define COMPASS2_MODE_POWER_DOWN   0x00
 
#define COMPASS2_MODE_SINGL_MEASUR   0x01
 
#define COMPASS2_MODE_CONT_MEAS_1   0x02
 
#define COMPASS2_MODE_CONT_MEAS_2   0x06
 
#define COMPASS2_MODE_EXT_TRIG   0x04
 
#define COMPASS2_MODE_SELF_TEST   0x08
 
#define COMPASS2_MODE_FUSE_ROM   0x0F
 
#define COMPASS2_SET_RESOLUTION_14bit   0x00
 
#define COMPASS2_SET_RESOLUTION_16bit   0x10
 
#define COMPASS2_MODE_SPI   0x00
 
#define COMPASS2_MODE_I2C   0x01
 
#define COMPASS2_X_AXIS   0x00
 
#define COMPASS2_Y_AXIS   0x01
 
#define COMPASS2_Z_AXIS   0x02
 

Typedefs

typedef uint8_t compass2_select_t
 Communication type.
 
typedef void(* compass2_master_io_t) (struct compass2_s *, uint8_t, uint8_t *, uint8_t)
 Master Input/Output type.
 
typedef struct compass2_s compass2_t
 Click ctx object definition.
 

Functions

void compass2_cfg_setup (compass2_cfg_t *cfg)
 Config Object Initialization function.
 
COMPASS2_RETVAL compass2_init (compass2_t *ctx, compass2_cfg_t *cfg)
 Initialization function.
 
void compass2_default_cfg (compass2_t *ctx)
 Click Default Configuration function.
 
void compass2_generic_write (compass2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function.
 
void compass2_generic_read (compass2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function.
 
void compass2_write_byte (compass2_t *ctx, uint8_t reg, uint8_t data_buf)
 Write byte function.
 
uint8_t compass2_read_byte (compass2_t *ctx, uint8_t reg)
 Read byte function.
 
void compass2_reset (compass2_t *ctx)
 Hardware reset function.
 
void compass2_i2c_disable (compass2_t *ctx)
 Switch from I2C to SPI mode function.
 
void compass2_software_reset (compass2_t *ctx)
 Software reset function.
 
float compass2_get_resolution_parameter (uint8_t res)
 Get resolution function.
 
uint8_t compass2_get_rdy (compass2_t *ctx)
 Get ready function.
 
uint8_t compass2_get_data_overrun (compass2_t *ctx)
 Get data overrun function.
 
void compass2_get_adjustment (compass2_t *ctx, uint8_t *x, uint8_t *y, uint8_t *z)
 Get axis adjustment function.
 
void compass2_set_out_resolution (compass2_t *ctx, uint8_t res)
 Set output resolution function.
 
void compass2_set_mode (compass2_t *ctx, uint8_t mode)
 Set output resolution function.
 
void compass2_get_all_data (compass2_t *ctx, int16_t *x, int16_t *y, int16_t *z)
 Get all data function.
 
int16_t compass2_get_axis_data (compass2_t *ctx, uint8_t axis)
 Get one axis data function.
 
void compass2_new_measurement (compass2_t *ctx)
 New measurement function.
 

Detailed Description

This file contains API for Compass 2 Click driver.