compass7 2.0.0.0
Compass 7 Click Driver

API for configuring and manipulating Compass 7 Click driver. More...

Topics

 Compass 7 Registers List
 List of registers of Compass 7 Click driver.
 
 Compass 7 Registers Settings
 Settings for registers of Compass 7 Click driver.
 
 Compass 7 MikroBUS Map
 MikroBUS pin mapping of Compass 7 Click driver.
 

Functions

void compass7_cfg_setup (compass7_cfg_t *cfg)
 Compass 7 configuration object setup function.
 
err_t compass7_init (compass7_t *ctx, compass7_cfg_t *cfg)
 Compass 7 initialization function.
 
err_t compass7_default_cfg (compass7_t *ctx)
 Compass 7 default configuration function.
 
err_t compass7_generic_write (compass7_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Compass 7 I2C writing function.
 
err_t compass7_generic_read (compass7_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Compass 7 I2C reading function.
 
err_t compass7_write_register (compass7_t *ctx, uint8_t reg, uint8_t data_in)
 Compass 7 write register function.
 
err_t compass7_read_register (compass7_t *ctx, uint8_t reg, uint8_t *data_out)
 Compass 7 read register function.
 
err_t compass7_check_communication (compass7_t *ctx)
 Compass 7 check communication function.
 
err_t compass7_soft_reset (compass7_t *ctx)
 Compass 7 soft reset function.
 
err_t compass7_set_measurement_mode (compass7_t *ctx, uint8_t mode)
 Compass 7 set measurement mode function.
 
err_t compass7_get_magnetic_flux (compass7_t *ctx, compass7_magnetic_flux_t *flux)
 Compass 7 get magnetic flux function.
 
err_t compass7_get_temperature (compass7_t *ctx, float *temperature)
 Compass 7 get temperature function.
 

Detailed Description

API for configuring and manipulating Compass 7 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ compass7_cfg_setup()

void compass7_cfg_setup ( compass7_cfg_t * cfg)

Compass 7 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See compass7_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ compass7_check_communication()

err_t compass7_check_communication ( compass7_t * ctx)

Compass 7 check communication function.

This function checks the communication by reading and verifying the product ID.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_default_cfg()

err_t compass7_default_cfg ( compass7_t * ctx)

Compass 7 default configuration function.

This function executes a default configuration of Compass 7 click board.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ compass7_generic_read()

err_t compass7_generic_read ( compass7_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Compass 7 I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_generic_write()

err_t compass7_generic_write ( compass7_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Compass 7 I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_get_magnetic_flux()

err_t compass7_get_magnetic_flux ( compass7_t * ctx,
compass7_magnetic_flux_t * flux )

Compass 7 get magnetic flux function.

This function reads the raw values of X, Y, and Z axis and converts them to magnetic flux data in Gauss.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[out]compass7_magnetic_flux_t: Flux data of X, Y, and Z axis in Gauss. See compass7_magnetic_flux_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_get_temperature()

err_t compass7_get_temperature ( compass7_t * ctx,
float * temperature )

Compass 7 get temperature function.

This function reads the temperature measurements in Celsius.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[out]temperature: Temperature in Celsius.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_init()

err_t compass7_init ( compass7_t * ctx,
compass7_cfg_t * cfg )

Compass 7 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See compass7_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See compass7_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_read_register()

err_t compass7_read_register ( compass7_t * ctx,
uint8_t reg,
uint8_t * data_out )

Compass 7 read register function.

This function reads data from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_set_measurement_mode()

err_t compass7_set_measurement_mode ( compass7_t * ctx,
uint8_t mode )

Compass 7 set measurement mode function.

This function sets the control and ODR registers for the selected measurement mode.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[in]mode: Measurement mode:
  • 0 - Single temperature,
  • 1 - Single magnetic,
  • 2 - Continuous magnetic at 1 Hz ODR,
  • 3 - Continuous magnetic at 2 Hz ODR,
  • 4 - Continuous magnetic at 5 Hz ODR,
  • 5 - Continuous magnetic at 10 Hz ODR,
  • 6 - Continuous magnetic at 25 Hz ODR,
  • 7 - Continuous magnetic at 50 Hz ODR,
  • 8 - Continuous magnetic at 100 Hz ODR,
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ compass7_soft_reset()

err_t compass7_soft_reset ( compass7_t * ctx)

Compass 7 soft reset function.

This function performs the software reset by setting a desired bit in the Control 1 register.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
At least 20ms delay for the power-on time is required after reset.

◆ compass7_write_register()

err_t compass7_write_register ( compass7_t * ctx,
uint8_t reg,
uint8_t data_in )

Compass 7 write register function.

This function writes a desired data to the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See compass7_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.