stspin220 2.1.0.0
STSPIN220 Click Driver

API for configuring and manipulating STSPIN220 Click driver. More...

Topics

 STSPIN220 Settings
 Settings of STSPIN220 Click driver.
 
 STSPIN220 MikroBUS Map
 MikroBUS pin mapping of STSPIN220 Click driver.
 

Functions

void stspin220_cfg_setup (stspin220_cfg_t *cfg)
 STSPIN220 configuration object setup function.
 
err_t stspin220_init (stspin220_t *ctx, stspin220_cfg_t *cfg)
 STSPIN220 initialization function.
 
void stspin220_default_cfg (stspin220_t *ctx)
 STSPIN220 default configuration function.
 
void stspin220_drive_motor (stspin220_t *ctx, uint32_t steps, uint8_t speed)
 STSPIN220 drive motor function.
 
void stspin220_enable_device (stspin220_t *ctx)
 STSPIN220 enable device function.
 
void stspin220_disable_device (stspin220_t *ctx)
 STSPIN220 disable device function.
 
void stspin220_set_direction (stspin220_t *ctx, uint8_t dir)
 STSPIN220 set direction function.
 
void stspin220_switch_direction (stspin220_t *ctx)
 STSPIN220 switch direction function.
 
void stspin220_reset_device (stspin220_t *ctx)
 STSPIN220 reset device function.
 
void stspin220_set_rst_pin (stspin220_t *ctx, uint8_t state)
 STSPIN220 set rst pin function.
 
uint8_t stspin220_get_fault_pin (stspin220_t *ctx)
 STSPIN220 get fault pin function.
 
void stspin220_set_step_pin (stspin220_t *ctx, uint8_t state)
 STSPIN220 set step pin function.
 

Detailed Description

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

◆ stspin220_cfg_setup()

void stspin220_cfg_setup ( stspin220_cfg_t * cfg)

STSPIN220 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ stspin220_default_cfg()

void stspin220_default_cfg ( stspin220_t * ctx)

STSPIN220 default configuration function.

This function executes a default configuration of STSPIN220 click board.

Parameters
[in]ctx: Click context object. See stspin220_t object definition for detailed explanation.
Returns
None.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ stspin220_disable_device()

void stspin220_disable_device ( stspin220_t * ctx)

STSPIN220 disable device function.

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

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

◆ stspin220_drive_motor()

void stspin220_drive_motor ( stspin220_t * ctx,
uint32_t steps,
uint8_t speed )

STSPIN220 drive motor function.

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

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

◆ stspin220_enable_device()

void stspin220_enable_device ( stspin220_t * ctx)

STSPIN220 enable device function.

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

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

◆ stspin220_get_fault_pin()

uint8_t stspin220_get_fault_pin ( stspin220_t * ctx)

STSPIN220 get fault pin function.

This function returns the FAULT pin logic state.

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

◆ stspin220_init()

err_t stspin220_init ( stspin220_t * ctx,
stspin220_cfg_t * cfg )

STSPIN220 initialization function.

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

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

◆ stspin220_reset_device()

void stspin220_reset_device ( stspin220_t * ctx)

STSPIN220 reset device function.

This function resets the device by toggling the RST pin.

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

◆ stspin220_set_direction()

void stspin220_set_direction ( stspin220_t * ctx,
uint8_t dir )

STSPIN220 set direction function.

This function sets the motor direction by setting the DIR pin logic state.

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

◆ stspin220_set_rst_pin()

void stspin220_set_rst_pin ( stspin220_t * ctx,
uint8_t state )

STSPIN220 set rst pin function.

This function sets the RST pin logic state.

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

◆ stspin220_set_step_pin()

void stspin220_set_step_pin ( stspin220_t * ctx,
uint8_t state )

STSPIN220 set step pin function.

This function sets the STEP pin logic state.

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

◆ stspin220_switch_direction()

void stspin220_switch_direction ( stspin220_t * ctx)

STSPIN220 switch direction function.

This function switches the motor direction by toggling the DIR pin.

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