hbridge 2.1.0.0
H-Bridge Click Driver

API for configuring and manipulating H-Bridge Click driver. More...

Topics

 H-Bridge Registers Settings
 Settings for registers of H-Bridge Click driver.
 
 H-Bridge MikroBUS Map
 MikroBUS pin mapping of H-Bridge Click driver.
 

Functions

void hbridge_cfg_setup (hbridge_cfg_t *cfg)
 H-Bridge configuration object setup function.
 
err_t hbridge_init (hbridge_t *ctx, hbridge_cfg_t *cfg)
 H-Bridge initialization function.
 
void hbridge_set_in1a_pin (hbridge_t *ctx, uint8_t state)
 H-Bridge set in1a pin function.
 
void hbridge_set_in2a_pin (hbridge_t *ctx, uint8_t state)
 H-Bridge set in2a pin function.
 
void hbridge_set_in1b_pin (hbridge_t *ctx, uint8_t state)
 H-Bridge set in1b pin function.
 
void hbridge_set_in2b_pin (hbridge_t *ctx, uint8_t state)
 H-Bridge set in2b pin function.
 
void hbridge_set_step_mode (hbridge_t *ctx, uint8_t mode)
 H-Bridge set step mode function.
 
void hbridge_set_direction (hbridge_t *ctx, uint8_t dir)
 H-Bridge set direction function.
 
void hbridge_switch_direction (hbridge_t *ctx)
 H-Bridge switch direction function.
 
void hbridge_enable_device (hbridge_t *ctx)
 H-Bridge enable device function.
 
void hbridge_disable_device (hbridge_t *ctx)
 H-Bridge disable device function.
 
void hbridge_drive_motor (hbridge_t *ctx, uint32_t steps, uint8_t speed)
 H-Bridge driver motor function.
 

Detailed Description

API for configuring and manipulating H-Bridge 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

◆ hbridge_cfg_setup()

void hbridge_cfg_setup ( hbridge_cfg_t * cfg)

H-Bridge configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ hbridge_disable_device()

void hbridge_disable_device ( hbridge_t * ctx)

H-Bridge disable device function.

This function disables the device by setting all pins to high logic state.

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

◆ hbridge_drive_motor()

void hbridge_drive_motor ( hbridge_t * ctx,
uint32_t steps,
uint8_t speed )

H-Bridge driver motor function.

This function drives the motor for the specific number of steps at the selected speed.

Parameters
[in]ctx: Click context object. See hbridge_t object definition for detailed explanation.
[in]steps: Number of steps to rotate motor.
[in]speed: Motor rotation speed:
  • 0 - Very slow,
  • 1 - Slow,
  • 2 - Medium,
  • 3 - Fast,
  • 4 - Very fast,
Returns
None.
Note
None.

◆ hbridge_enable_device()

void hbridge_enable_device ( hbridge_t * ctx)

H-Bridge enable device function.

This function enables the device by setting all pins to low logic state.

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

◆ hbridge_init()

err_t hbridge_init ( hbridge_t * ctx,
hbridge_cfg_t * cfg )

H-Bridge initialization function.

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

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

◆ hbridge_set_direction()

void hbridge_set_direction ( hbridge_t * ctx,
uint8_t dir )

H-Bridge set direction function.

This function sets the motor direction to clockwise or counter-clockwise in ctx->direction.

Parameters
[in]ctx: Click context object. See hbridge_t object definition for detailed explanation.
[in]dir:
  • 0 - Clockwise,
  • 1 - Counter-Clockwise.
Returns
None.
Note
None.

◆ hbridge_set_in1a_pin()

void hbridge_set_in1a_pin ( hbridge_t * ctx,
uint8_t state )

H-Bridge set in1a pin function.

This function sets the IN1A pin logic state.

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

◆ hbridge_set_in1b_pin()

void hbridge_set_in1b_pin ( hbridge_t * ctx,
uint8_t state )

H-Bridge set in1b pin function.

This function sets the IN1B pin logic state.

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

◆ hbridge_set_in2a_pin()

void hbridge_set_in2a_pin ( hbridge_t * ctx,
uint8_t state )

H-Bridge set in2a pin function.

This function sets the IN2A pin logic state.

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

◆ hbridge_set_in2b_pin()

void hbridge_set_in2b_pin ( hbridge_t * ctx,
uint8_t state )

H-Bridge set in2b pin function.

This function sets the IN2B pin logic state.

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

◆ hbridge_set_step_mode()

void hbridge_set_step_mode ( hbridge_t * ctx,
uint8_t mode )

H-Bridge set step mode function.

This function sets the step mode resolution settings in ctx->step_mode.

Parameters
[in]ctx: Click context object. See hbridge_t object definition for detailed explanation.
[in]mode: Step mode resolution.
  • 0 - Full step,
  • 1 - Half step.
Returns
None.
Note
None.

◆ hbridge_switch_direction()

void hbridge_switch_direction ( hbridge_t * ctx)

H-Bridge switch direction function.

This function switches the motor direction in ctx->direction.

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