dcmotor18 2.0.0.0
DC Motor 18 Click Driver

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

Topics

 DC Motor 18 PWM Settings
 Settings for configuration of DC Motor 18 Click driver.
 
 DC Motor 18 MikroBUS Map
 MikroBUS pin mapping of DC Motor 18 Click driver.
 
 Dcmotor18_cfg
 

Functions

void dcmotor18_cfg_setup (dcmotor18_cfg_t *cfg)
 DC Motor 18 configuration object setup function.
 
err_t dcmotor18_init (dcmotor18_t *ctx, dcmotor18_cfg_t *cfg)
 DC Motor 18 initialization function.
 
err_t dcmotor18_default_cfg (dcmotor18_t *ctx)
 DC Motor 18 default configuration function.
 
err_t dcmotor18_set_duty_cycle (dcmotor18_t *ctx, float duty_cycle)
 Sets PWM duty cycle.
 
err_t dcmotor18_pwm_stop (dcmotor18_t *ctx)
 DC Motor 18 stop PWM module.
 
err_t dcmotor18_pwm_start (dcmotor18_t *ctx)
 DC Motor 18 start PWM module.
 
err_t dcmotor18_read_an_pin_value (dcmotor18_t *ctx, uint16_t *data_out)
 DC Motor 18 read AN pin value function.
 
err_t dcmotor18_read_an_pin_voltage (dcmotor18_t *ctx, float *data_out)
 DC Motor 18 read AN pin voltage level function.
 
err_t dcmotor18_read_an_pin_current (dcmotor18_t *ctx, float *data_out)
 Read AN pin current.
 
void dcmotor18_set_direction (dcmotor18_t *ctx, uint8_t state)
 Set diretion of motor rotation.
 
void dcmotor18_set_enable (dcmotor18_t *ctx, uint8_t state)
 Set enable pin state.
 
uint8_t dcmotor18_get_interrupt (dcmotor18_t *ctx)
 Get interrupt pin state.
 
err_t dcmotor18_set_speed_percentage (dcmotor18_t *ctx, float speed_percentage)
 Set speed output percentage.
 

Detailed Description

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

◆ dcmotor18_cfg_setup()

void dcmotor18_cfg_setup ( dcmotor18_cfg_t * cfg)

DC Motor 18 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ dcmotor18_default_cfg()

err_t dcmotor18_default_cfg ( dcmotor18_t * ctx)

DC Motor 18 default configuration function.

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

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

◆ dcmotor18_get_interrupt()

uint8_t dcmotor18_get_interrupt ( dcmotor18_t * ctx)

Get interrupt pin state.

This function reads the int_pin pin state.

Parameters
[out]ctx: Click context object. See dcmotor18_t object definition for detailed explanation.
Returns
Interrupt pin state.

◆ dcmotor18_init()

err_t dcmotor18_init ( dcmotor18_t * ctx,
dcmotor18_cfg_t * cfg )

DC Motor 18 initialization function.

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

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

◆ dcmotor18_pwm_start()

err_t dcmotor18_pwm_start ( dcmotor18_t * ctx)

DC Motor 18 start PWM module.

This function starts the PWM module output.

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

◆ dcmotor18_pwm_stop()

err_t dcmotor18_pwm_stop ( dcmotor18_t * ctx)

DC Motor 18 stop PWM module.

This function stops the PWM module output.

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

◆ dcmotor18_read_an_pin_current()

err_t dcmotor18_read_an_pin_current ( dcmotor18_t * ctx,
float * data_out )

Read AN pin current.

This function reads voltage of AN pin and calculates current.

Parameters
[in]ctx: Click context object. See dcmotor18_t object definition for detailed explanation.
[out]data_out: Output current of the analog pin [mA].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ dcmotor18_read_an_pin_value()

err_t dcmotor18_read_an_pin_value ( dcmotor18_t * ctx,
uint16_t * data_out )

DC Motor 18 read AN pin value function.

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

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

◆ dcmotor18_read_an_pin_voltage()

err_t dcmotor18_read_an_pin_voltage ( dcmotor18_t * ctx,
float * data_out )

DC Motor 18 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 dcmotor18_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).

◆ dcmotor18_set_direction()

void dcmotor18_set_direction ( dcmotor18_t * ctx,
uint8_t state )

Set diretion of motor rotation.

This function sets the pw2 pin state.

Parameters
[out]ctx: Click context object. See dcmotor18_t object definition for detailed explanation.
[in]state: State of the pin.
Returns
Nothing.

◆ dcmotor18_set_duty_cycle()

err_t dcmotor18_set_duty_cycle ( dcmotor18_t * ctx,
float duty_cycle )

Sets PWM duty cycle.

This function sets the PWM duty cycle in percentages ( Range[ 0..1 ] ).

Parameters
[out]ctx: Click context object. See dcmotor18_t object definition for detailed explanation.
[in]duty_ratio: PWM duty_ratio.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ dcmotor18_set_enable()

void dcmotor18_set_enable ( dcmotor18_t * ctx,
uint8_t state )

Set enable pin state.

This function sets the en pin state.

Parameters
[out]ctx: Click context object. See dcmotor18_t object definition for detailed explanation.
[in]state: State of the pin.
Returns
Nothing.

◆ dcmotor18_set_speed_percentage()

err_t dcmotor18_set_speed_percentage ( dcmotor18_t * ctx,
float speed_percentage )

Set speed output percentage.

This function sets the PWM duty cycle in percentages ( Range[ 0..1 ] ).

Parameters
[out]ctx: Click context object. See dcmotor18_t object definition for detailed explanation.
[in]speed_percentage: PWM duty_ratio.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.