dcmotor26 2.1.0.0
DC Motor 26 Click Driver

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

Topics

 DC Motor 26 Registers List
 List of registers of DC Motor 26 Click driver.
 
 DC Motor 26 Registers Settings
 Settings for registers of DC Motor 26 Click driver.
 
 DC Motor 26 MikroBUS Map
 MikroBUS pin mapping of DC Motor 26 Click driver.
 

Functions

void dcmotor26_cfg_setup (dcmotor26_cfg_t *cfg)
 DC Motor 26 configuration object setup function.
 
err_t dcmotor26_init (dcmotor26_t *ctx, dcmotor26_cfg_t *cfg)
 DC Motor 26 initialization function.
 
err_t dcmotor26_default_cfg (dcmotor26_t *ctx)
 DC Motor 26 default configuration function.
 
err_t dcmotor26_write_register (dcmotor26_t *ctx, uint8_t reg, uint32_t data_in)
 DC Motor 26 write register function.
 
err_t dcmotor26_read_register (dcmotor26_t *ctx, uint8_t reg, uint32_t *data_out)
 DC Motor 26 read register function.
 
err_t dcmotor26_pca9538a_write_register (dcmotor26_t *ctx, uint8_t reg, uint8_t data_in)
 DC Motor 26 pca9538a write register function.
 
err_t dcmotor26_pca9538a_read_register (dcmotor26_t *ctx, uint8_t reg, uint8_t *data_out)
 DC Motor 26 pca9538a read register function.
 
void dcmotor26_enter_sleep_mode (dcmotor26_t *ctx)
 DC Motor 26 enter sleep mode function.
 
void dcmotor26_wake_up_device (dcmotor26_t *ctx)
 DC Motor 26 wake up device function.
 
uint8_t dcmotor26_get_int_pin (dcmotor26_t *ctx)
 DC Motor 26 get int pin function.
 
void dcmotor26_set_clk_pin (dcmotor26_t *ctx, uint8_t state)
 DC Motor 26 set clk pin function.
 
err_t dcmotor26_set_en1_pin (dcmotor26_t *ctx, uint8_t state)
 DC Motor 26 set en1 pin function.
 
err_t dcmotor26_get_en1_pin (dcmotor26_t *ctx, uint8_t *state)
 DC Motor 26 get en1 pin function.
 
err_t dcmotor26_set_en2_pin (dcmotor26_t *ctx, uint8_t state)
 DC Motor 26 set en2 pin function.
 
err_t dcmotor26_get_en2_pin (dcmotor26_t *ctx, uint8_t *state)
 DC Motor 26 get en2 pin function.
 
err_t dcmotor26_set_cm_sel_pin (dcmotor26_t *ctx, uint8_t state)
 DC Motor 26 set cm sel pin function.
 
err_t dcmotor26_get_cm_sel_pin (dcmotor26_t *ctx, uint8_t *state)
 DC Motor 26 get cm sel pin function.
 
err_t dcmotor26_get_diag1_pin (dcmotor26_t *ctx, uint8_t *state)
 DC Motor 26 get diag1 pin function.
 
err_t dcmotor26_get_diag2_pin (dcmotor26_t *ctx, uint8_t *state)
 DC Motor 26 get diag2 pin function.
 
err_t dcmotor26_get_sleep_pin (dcmotor26_t *ctx, uint8_t *state)
 DC Motor 26 get sleep pin function.
 
err_t dcmotor26_read_an_pin_value (dcmotor26_t *ctx, uint16_t *data_out)
 DC Motor 26 read AN pin value function.
 
err_t dcmotor26_read_an_pin_voltage (dcmotor26_t *ctx, float *data_out)
 DC Motor 26 read AN pin voltage level function.
 
err_t dcmotor26_get_motor_current (dcmotor26_t *ctx, float *current)
 DC Motor 26 get motor current function.
 
err_t dcmotor26_set_ch1_operation_mode (dcmotor26_t *ctx, uint8_t mode)
 DC Motor 26 set ch1 operation mode function.
 
err_t dcmotor26_set_ch2_operation_mode (dcmotor26_t *ctx, uint8_t mode)
 DC Motor 26 set ch2 operation mode function.
 
err_t dcmotor26_set_ch1_drive_frequency (dcmotor26_t *ctx, uint16_t drv_freq)
 DC Motor 26 set ch1 drive frequency function.
 
err_t dcmotor26_set_ch2_drive_frequency (dcmotor26_t *ctx, uint16_t drv_freq)
 DC Motor 26 set ch2 drive frequency function.
 
err_t dcmotor26_set_ch1_duty_period (dcmotor26_t *ctx, uint16_t duty_period)
 DC Motor 26 set ch1 duty period function.
 
err_t dcmotor26_set_ch2_duty_period (dcmotor26_t *ctx, uint16_t duty_period)
 DC Motor 26 set ch1 duty period function.
 

Detailed Description

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

◆ dcmotor26_cfg_setup()

void dcmotor26_cfg_setup ( dcmotor26_cfg_t * cfg)

DC Motor 26 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ dcmotor26_default_cfg()

err_t dcmotor26_default_cfg ( dcmotor26_t * ctx)

DC Motor 26 default configuration function.

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

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

◆ dcmotor26_enter_sleep_mode()

void dcmotor26_enter_sleep_mode ( dcmotor26_t * ctx)

DC Motor 26 enter sleep mode function.

This function sets the device to sleep mode by setting the SLP pin to low logic state.

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

◆ dcmotor26_get_cm_sel_pin()

err_t dcmotor26_get_cm_sel_pin ( dcmotor26_t * ctx,
uint8_t * state )

DC Motor 26 get cm sel pin function.

This function reads the cm sel pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]state:
  • 0 - Low logic state,
  • 1 - High logic state.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_get_diag1_pin()

err_t dcmotor26_get_diag1_pin ( dcmotor26_t * ctx,
uint8_t * state )

DC Motor 26 get diag1 pin function.

This function reads the diag1 pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]state:
  • 0 - Low logic state,
  • 1 - High logic state.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_get_diag2_pin()

err_t dcmotor26_get_diag2_pin ( dcmotor26_t * ctx,
uint8_t * state )

DC Motor 26 get diag2 pin function.

This function reads the diag2 pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]state:
  • 0 - Low logic state,
  • 1 - High logic state.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_get_en1_pin()

err_t dcmotor26_get_en1_pin ( dcmotor26_t * ctx,
uint8_t * state )

DC Motor 26 get en1 pin function.

This function reads the en1 pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]state:
  • 0 - Low logic state,
  • 1 - High logic state.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_get_en2_pin()

err_t dcmotor26_get_en2_pin ( dcmotor26_t * ctx,
uint8_t * state )

DC Motor 26 get en2 pin function.

This function reads the en2 pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]state:
  • 0 - Low logic state,
  • 1 - High logic state.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_get_int_pin()

uint8_t dcmotor26_get_int_pin ( dcmotor26_t * ctx)

DC Motor 26 get int pin function.

This function returns the PCA9538A INT pin logic state.

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

◆ dcmotor26_get_motor_current()

err_t dcmotor26_get_motor_current ( dcmotor26_t * ctx,
float * current )

DC Motor 26 get motor current function.

This function reads the motor current consumption.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]current: Current value [A].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Make sure the CM sel pin state is set properly.

◆ dcmotor26_get_sleep_pin()

err_t dcmotor26_get_sleep_pin ( dcmotor26_t * ctx,
uint8_t * state )

DC Motor 26 get sleep pin function.

This function reads the sleep pin logic state.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]state:
  • 0 - Low logic state,
  • 1 - High logic state.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_init()

err_t dcmotor26_init ( dcmotor26_t * ctx,
dcmotor26_cfg_t * cfg )

DC Motor 26 initialization function.

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

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

◆ dcmotor26_pca9538a_read_register()

err_t dcmotor26_pca9538a_read_register ( dcmotor26_t * ctx,
uint8_t reg,
uint8_t * data_out )

DC Motor 26 pca9538a read register function.

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

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

◆ dcmotor26_pca9538a_write_register()

err_t dcmotor26_pca9538a_write_register ( dcmotor26_t * ctx,
uint8_t reg,
uint8_t data_in )

DC Motor 26 pca9538a write register function.

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

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

◆ dcmotor26_read_an_pin_value()

err_t dcmotor26_read_an_pin_value ( dcmotor26_t * ctx,
uint16_t * data_out )

DC Motor 26 read AN pin value function.

This function reads results of AD conversion of the AN pin.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]data_out: Output ADC result.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_read_an_pin_voltage()

err_t dcmotor26_read_an_pin_voltage ( dcmotor26_t * ctx,
float * data_out )

DC Motor 26 read AN pin voltage level function.

This function reads results of AD conversion of the AN pin and converts them to proportional voltage level.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[out]data_out: Output voltage level of the analog pin [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered configuration of the ADC (resolution, reference voltage).

◆ dcmotor26_read_register()

err_t dcmotor26_read_register ( dcmotor26_t * ctx,
uint8_t reg,
uint32_t * data_out )

DC Motor 26 read register function.

This function reads a 24-bit data from the selected register by using SPI serial interface.

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

◆ dcmotor26_set_ch1_drive_frequency()

err_t dcmotor26_set_ch1_drive_frequency ( dcmotor26_t * ctx,
uint16_t drv_freq )

DC Motor 26 set ch1 drive frequency function.

This function sets the raw drive frequency of the channel 1.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[in]drv_freq: Raw drive frequency (0-2047).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_set_ch1_duty_period()

err_t dcmotor26_set_ch1_duty_period ( dcmotor26_t * ctx,
uint16_t duty_period )

DC Motor 26 set ch1 duty period function.

This function sets the duty period of the channel 1.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[in]duty_period: Duty period (0-2047).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_set_ch1_operation_mode()

err_t dcmotor26_set_ch1_operation_mode ( dcmotor26_t * ctx,
uint8_t mode )

DC Motor 26 set ch1 operation mode function.

This function sets the operation mode of the channel 1.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[in]mode:
  • 0 - OFF,
  • 1 - FORWARD,
  • 2 - REVERSE,
  • 3 - BRAKE.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dcmotor26_set_ch2_drive_frequency()

err_t dcmotor26_set_ch2_drive_frequency ( dcmotor26_t * ctx,
uint16_t drv_freq )

DC Motor 26 set ch2 drive frequency function.

This function sets the raw drive frequency of the channel 2.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[in]drv_freq: Raw drive frequency (0-2047).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Ineffective for Combined-Channel Mode (LARGE Mode) (OSEL1 = L and OSEL2 = L).

◆ dcmotor26_set_ch2_duty_period()

err_t dcmotor26_set_ch2_duty_period ( dcmotor26_t * ctx,
uint16_t duty_period )

DC Motor 26 set ch1 duty period function.

This function sets the duty period of the channel 1.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[in]duty_period: Duty period (0-2047).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Ineffective for Combined-Channel Mode (LARGE Mode) (OSEL1 = L and OSEL2 = L).

◆ dcmotor26_set_ch2_operation_mode()

err_t dcmotor26_set_ch2_operation_mode ( dcmotor26_t * ctx,
uint8_t mode )

DC Motor 26 set ch2 operation mode function.

This function sets the operation mode of the channel 2.

Parameters
[in]ctx: Click context object. See dcmotor26_t object definition for detailed explanation.
[in]mode:
  • 0 - OFF,
  • 1 - FORWARD,
  • 2 - REVERSE,
  • 3 - BRAKE.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Ineffective for Combined-Channel Mode (LARGE Mode) (OSEL1 = L and OSEL2 = L).

◆ dcmotor26_set_clk_pin()

void dcmotor26_set_clk_pin ( dcmotor26_t * ctx,
uint8_t state )

DC Motor 26 set clk pin function.

This function sets the CLK pin logic state.

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

◆ dcmotor26_set_cm_sel_pin()

err_t dcmotor26_set_cm_sel_pin ( dcmotor26_t * ctx,
uint8_t state )

DC Motor 26 set cm sel pin function.

This function sets the cm sel pin logic state.

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

◆ dcmotor26_set_en1_pin()

err_t dcmotor26_set_en1_pin ( dcmotor26_t * ctx,
uint8_t state )

DC Motor 26 set en1 pin function.

This function sets the en1 pin logic state.

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

◆ dcmotor26_set_en2_pin()

err_t dcmotor26_set_en2_pin ( dcmotor26_t * ctx,
uint8_t state )

DC Motor 26 set en2 pin function.

This function sets the en2 pin logic state.

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

◆ dcmotor26_wake_up_device()

void dcmotor26_wake_up_device ( dcmotor26_t * ctx)

DC Motor 26 wake up device function.

This function wakes up the device from sleep by setting the SLP pin to high logic state.

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

◆ dcmotor26_write_register()

err_t dcmotor26_write_register ( dcmotor26_t * ctx,
uint8_t reg,
uint32_t data_in )

DC Motor 26 write register function.

This function writes a 24-bit data to the selected register by using SPI serial interface and checks if it is written correctly.

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