magneticrotary2 2.0.0.0
Magnetic Rotary 2 Click Driver

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

Topics

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

Functions

void magneticrotary2_cfg_setup (magneticrotary2_cfg_t *cfg)
 Magnetic Rotary 2 configuration object setup function.
 
void magneticrotary2_msel_pin_selection (magneticrotary2_cfg_t *cfg, magneticrotary2_msel_t msel)
 Magnetic Rotary 2 MSEL pin selection function.
 
err_t magneticrotary2_init (magneticrotary2_t *ctx, magneticrotary2_cfg_t *cfg)
 Magnetic Rotary 2 initialization function.
 
err_t magneticrotary2_default_cfg (magneticrotary2_t *ctx)
 Magnetic Rotary 2 default configuration function.
 
err_t magneticrotary2_write_register (magneticrotary2_t *ctx, uint8_t reg, uint8_t data_in)
 Magnetic Rotary 2 write register function.
 
err_t magneticrotary2_read_register (magneticrotary2_t *ctx, uint8_t reg, uint8_t *data_out)
 Magnetic Rotary 2 read register function.
 
err_t magneticrotary2_unlock_eeprom (magneticrotary2_t *ctx)
 Magnetic Rotary 2 unlock eeprom function.
 
err_t magneticrotary2_lock_eeprom (magneticrotary2_t *ctx)
 Magnetic Rotary 2 lock eeprom function.
 
err_t magneticrotary2_program_eeprom (magneticrotary2_t *ctx)
 Magnetic Rotary 2 program eeprom function.
 
err_t magneticrotary2_get_raw_data (magneticrotary2_t *ctx, uint32_t *data_out)
 Magnetic Rotary 2 get raw data function.
 
err_t magneticrotary2_get_angle (magneticrotary2_t *ctx, float *angle)
 Magnetic Rotary 2 get angle function.
 

Detailed Description

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

◆ magneticrotary2_cfg_setup()

void magneticrotary2_cfg_setup ( magneticrotary2_cfg_t * cfg)

Magnetic Rotary 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ magneticrotary2_default_cfg()

err_t magneticrotary2_default_cfg ( magneticrotary2_t * ctx)

Magnetic Rotary 2 default configuration function.

This function executes a default configuration of Magnetic Rotary 2 click board.

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

◆ magneticrotary2_get_angle()

err_t magneticrotary2_get_angle ( magneticrotary2_t * ctx,
float * angle )

Magnetic Rotary 2 get angle function.

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

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

◆ magneticrotary2_get_raw_data()

err_t magneticrotary2_get_raw_data ( magneticrotary2_t * ctx,
uint32_t * data_out )

Magnetic Rotary 2 get raw data function.

This function reads the absolute position raw data.

Parameters
[in]ctx: Click context object. See magneticrotary2_t object definition for detailed explanation.
[out]data_out: Absolute position raw data [18 bits by default].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ magneticrotary2_init()

err_t magneticrotary2_init ( magneticrotary2_t * ctx,
magneticrotary2_cfg_t * cfg )

Magnetic Rotary 2 initialization function.

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

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

◆ magneticrotary2_lock_eeprom()

err_t magneticrotary2_lock_eeprom ( magneticrotary2_t * ctx)

Magnetic Rotary 2 lock eeprom function.

This function locks eeprom by writing 0xFF to the unlock eeprom address.

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

◆ magneticrotary2_msel_pin_selection()

void magneticrotary2_msel_pin_selection ( magneticrotary2_cfg_t * cfg,
magneticrotary2_msel_t msel )

Magnetic Rotary 2 MSEL pin selection function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See magneticrotary2_cfg_t object definition for detailed explanation.
[in]msel: MSEL selection. See magneticrotary2_msel_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ magneticrotary2_program_eeprom()

err_t magneticrotary2_program_eeprom ( magneticrotary2_t * ctx)

Magnetic Rotary 2 program eeprom function.

This function programs eeprom by sending the program eeprom command.

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

◆ magneticrotary2_read_register()

err_t magneticrotary2_read_register ( magneticrotary2_t * ctx,
uint8_t reg,
uint8_t * data_out )

Magnetic Rotary 2 read register function.

This function reads a data byte from the selected register by using SPI serial interface. In the case of SPI4 and absolute position register, it will read 3 bytes of data without parity and error flag bits.

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

◆ magneticrotary2_unlock_eeprom()

err_t magneticrotary2_unlock_eeprom ( magneticrotary2_t * ctx)

Magnetic Rotary 2 unlock eeprom function.

This function unlocks eeprom by sending the unlock eeprom command.

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

◆ magneticrotary2_write_register()

err_t magneticrotary2_write_register ( magneticrotary2_t * ctx,
uint8_t reg,
uint8_t data_in )

Magnetic Rotary 2 write register function.

This function writes a data byte to the selected register by using SPI serial interface. It will also verify if the data is written correctly by reading back the same register.

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