dcmotor22 2.0.0.0
DC Motor 22 Click Driver

API for configuring and manipulating DC Motor 22 Click driver. More...

Topics

 DC Motor 22 Device Settings
 Settings for registers of DC Motor 22 Click driver.
 
 DC Motor 22 MikroBUS Map
 MikroBUS pin mapping of DC Motor 22 Click driver.
 

Functions

void dcmotor22_cfg_setup (dcmotor22_cfg_t *cfg)
 DC Motor 22 configuration object setup function.
 
err_t dcmotor22_init (dcmotor22_t *ctx, dcmotor22_cfg_t *cfg)
 DC Motor 22 initialization function.
 
err_t dcmotor22_default_cfg (dcmotor22_t *ctx)
 DC Motor 22 default configuration function.
 
err_t dcmotor22_write_register (dcmotor22_t *ctx, uint8_t reg, uint32_t data_in)
 DC Motor 22 write register function.
 
err_t dcmotor22_read_register (dcmotor22_t *ctx, uint8_t reg, uint32_t *data_out)
 DC Motor 22 read register function.
 
err_t dcmotor22_adc_write_setup_byte (dcmotor22_t *ctx, uint8_t setup_byte)
 DC Motor 22 ADC write setup byte function.
 
err_t dcmotor22_adc_write_config_byte (dcmotor22_t *ctx, uint8_t config_byte)
 DC Motor 22 ADC write config byte function.
 
err_t dcmotor22_adc_set_channel (dcmotor22_t *ctx, uint8_t channel)
 DC Motor 22 ADC set channel function.
 
err_t dcmotor22_adc_get_voltage (dcmotor22_t *ctx, float *voltage)
 DC Motor 22 ADC get voltage function.
 
err_t dcmotor22_get_motor_current (dcmotor22_t *ctx, uint8_t motor_sel, float *current)
 DC Motor 22 get motor current function.
 
err_t dcmotor22_set_motor_pwm (dcmotor22_t *ctx, uint8_t motor_sel, int16_t pwm_duty)
 DC Motor 22 set motor pwm function.
 
void dcmotor22_enable_device (dcmotor22_t *ctx)
 DC Motor 22 enable device function.
 
void dcmotor22_disable_device (dcmotor22_t *ctx)
 DC Motor 22 disable device function.
 
void dcmotor22_reset_device (dcmotor22_t *ctx)
 DC Motor 22 reset device function.
 
void dcmotor22_set_device_address (dcmotor22_t *ctx, uint8_t addr)
 DC Motor 22 set device address function.
 
uint8_t dcmotor22_get_int_pin (dcmotor22_t *ctx)
 DC Motor 22 get int pin function.
 

Detailed Description

API for configuring and manipulating DC Motor 22 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

◆ dcmotor22_adc_get_voltage()

err_t dcmotor22_adc_get_voltage ( dcmotor22_t * ctx,
float * voltage )

DC Motor 22 ADC get voltage function.

This function reads the voltage from the previously selected channel by using I2C serial interface.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[out]voltage: Voltage value [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor22_adc_set_channel()

err_t dcmotor22_adc_set_channel ( dcmotor22_t * ctx,
uint8_t channel )

DC Motor 22 ADC set channel function.

This function sets the selected channel active by modifying the config byte.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[in]channel: Channel number (0-1).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor22_adc_write_config_byte()

err_t dcmotor22_adc_write_config_byte ( dcmotor22_t * ctx,
uint8_t config_byte )

DC Motor 22 ADC write config byte function.

This function writes a config byte to the ADC chip by using I2C serial interface.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[in]config_byte: Config byte to be written ( the value will be stored in ctx->config_byte ).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor22_adc_write_setup_byte()

err_t dcmotor22_adc_write_setup_byte ( dcmotor22_t * ctx,
uint8_t setup_byte )

DC Motor 22 ADC write setup byte function.

This function writes a setup byte to the ADC chip by using I2C serial interface.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[in]setup_byte: Setup byte to be written ( the value will be stored in ctx->setup_byte ).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor22_cfg_setup()

void dcmotor22_cfg_setup ( dcmotor22_cfg_t * cfg)

DC Motor 22 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ dcmotor22_default_cfg()

err_t dcmotor22_default_cfg ( dcmotor22_t * ctx)

DC Motor 22 default configuration function.

This function executes a default configuration of DC Motor 22 click board.

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

◆ dcmotor22_disable_device()

void dcmotor22_disable_device ( dcmotor22_t * ctx)

DC Motor 22 disable device function.

This function disables the device by setting the EN pin to LOW logic state.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ dcmotor22_enable_device()

void dcmotor22_enable_device ( dcmotor22_t * ctx)

DC Motor 22 enable device function.

This function enables the device by setting the EN pin to HIGH logic state.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ dcmotor22_get_int_pin()

uint8_t dcmotor22_get_int_pin ( dcmotor22_t * ctx)

DC Motor 22 get int pin function.

This function returns the INT pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ dcmotor22_get_motor_current()

err_t dcmotor22_get_motor_current ( dcmotor22_t * ctx,
uint8_t motor_sel,
float * current )

DC Motor 22 get motor current function.

This function reads the current consumption of the selected motor.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[in]motor_sel: Motor selection
  • 0 - Motor A,
  • 1 - Motor B.
[out]current: Current value [A].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor22_init()

err_t dcmotor22_init ( dcmotor22_t * ctx,
dcmotor22_cfg_t * cfg )

DC Motor 22 initialization function.

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

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

◆ dcmotor22_read_register()

err_t dcmotor22_read_register ( dcmotor22_t * ctx,
uint8_t reg,
uint32_t * data_out )

DC Motor 22 read register function.

This function reads 32-bit data from the selected register by using UART serial interface.

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

◆ dcmotor22_reset_device()

void dcmotor22_reset_device ( dcmotor22_t * ctx)

DC Motor 22 reset device function.

This function resets the device by toggling the EN pin state.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ dcmotor22_set_device_address()

void dcmotor22_set_device_address ( dcmotor22_t * ctx,
uint8_t addr )

DC Motor 22 set device address function.

This function sets the device address.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[in]addr: Device address in range 0 to 3.
Returns
None.
Note
None.

◆ dcmotor22_set_motor_pwm()

err_t dcmotor22_set_motor_pwm ( dcmotor22_t * ctx,
uint8_t motor_sel,
int16_t pwm_duty )

DC Motor 22 set motor pwm function.

This function sets the PWM duty cycle of the selected motor.

Parameters
[in]ctx: Click context object. See dcmotor22_t object definition for detailed explanation.
[in]motor_sel: Motor selection
  • 0 - Motor A,
  • 1 - Motor B.
[in]pwm_duty: PWM duty in range -255 to +255 [-100% to 100%].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor22_write_register()

err_t dcmotor22_write_register ( dcmotor22_t * ctx,
uint8_t reg,
uint32_t data_in )

DC Motor 22 write register function.

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

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