magneticrotary4 2.0.0.0
Magnetic Rotary 4 Click Driver

API for configuring and manipulating Magnetic Rotary 4 Click driver. More...

Topics

 Magnetic Rotary 4 Registers List
 List of registers of Magnetic Rotary 4 Click driver.
 
 Magnetic Rotary 4 Registers Settings
 Settings for registers of Magnetic Rotary 4 Click driver.
 
 Magnetic Rotary 4 MikroBUS Map
 MikroBUS pin mapping of Magnetic Rotary 4 Click driver.
 

Functions

void magneticrotary4_cfg_setup (magneticrotary4_cfg_t *cfg)
 Magnetic Rotary 4 configuration object setup function.
 
err_t magneticrotary4_init (magneticrotary4_t *ctx, magneticrotary4_cfg_t *cfg)
 Magnetic Rotary 4 initialization function.
 
err_t magneticrotary4_write_register (magneticrotary4_t *ctx, uint16_t reg, uint16_t data_in)
 Magnetic Rotary 4 write register function.
 
err_t magneticrotary4_read_register (magneticrotary4_t *ctx, uint16_t reg, uint16_t *data_out)
 Magnetic Rotary 4 read register function.
 
err_t magneticrotary4_get_angle (magneticrotary4_t *ctx, float *angle)
 Magnetic Rotary 4 get angle function.
 
err_t magneticrotary4_calibrate_zero_position (magneticrotary4_t *ctx)
 Magnetic Rotary 4 calibrate zero position function.
 
err_t magneticrotary4_set_rotation_direction (magneticrotary4_t *ctx, uint8_t direction)
 Magnetic Rotary 4 set rotation direction function.
 

Detailed Description

API for configuring and manipulating Magnetic Rotary 4 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

◆ magneticrotary4_calibrate_zero_position()

err_t magneticrotary4_calibrate_zero_position ( magneticrotary4_t * ctx)

Magnetic Rotary 4 calibrate zero position function.

This function calibrates the sensor to zero Angle position.

Parameters
[in]ctx: Click context object. See magneticrotary4_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function will clear the comp_l_error_en and comp_h_error_en bits from ZPOSL register.

◆ magneticrotary4_cfg_setup()

void magneticrotary4_cfg_setup ( magneticrotary4_cfg_t * cfg)

Magnetic Rotary 4 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ magneticrotary4_get_angle()

err_t magneticrotary4_get_angle ( magneticrotary4_t * ctx,
float * angle )

Magnetic Rotary 4 get angle function.

This function reads the absolute position raw data and converts it to degrees (Angle).

Parameters
[in]ctx: Click context object. See magneticrotary4_t object definition for detailed explanation.
[out]angle: Angle in degrees [0-360].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ magneticrotary4_init()

err_t magneticrotary4_init ( magneticrotary4_t * ctx,
magneticrotary4_cfg_t * cfg )

Magnetic Rotary 4 initialization function.

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

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

◆ magneticrotary4_read_register()

err_t magneticrotary4_read_register ( magneticrotary4_t * ctx,
uint16_t reg,
uint16_t * data_out )

Magnetic Rotary 4 read register function.

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

Parameters
[in]ctx: Click context object. See magneticrotary4_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.

◆ magneticrotary4_set_rotation_direction()

err_t magneticrotary4_set_rotation_direction ( magneticrotary4_t * ctx,
uint8_t direction )

Magnetic Rotary 4 set rotation direction function.

This function sets the magnet rotation direction to clockwise or counter-clockwise.

Parameters
[in]ctx: Click context object. See magneticrotary4_t object definition for detailed explanation.
[in]direction:
  • 0 - Clockwise,
  • 1 - Counter-clockwise.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function will set the DIR bit from SETTINGS1 register, and clear the others to default state.

◆ magneticrotary4_write_register()

err_t magneticrotary4_write_register ( magneticrotary4_t * ctx,
uint16_t reg,
uint16_t data_in )

Magnetic Rotary 4 write register function.

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

Parameters
[in]ctx: Click context object. See magneticrotary4_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.