silentstep4 2.1.0.0
Silent Step 4 Click Driver

API for configuring and manipulating Silent Step 4 Click driver. More...

Topics

 Silent Step 4 Registers List
 List of registers of Silent Step 4 Click driver.
 

Data Structures

struct  silentstep4_s
 Silent Step 4 Click context object. More...
 
struct  silentstep4_cfg_t
 Silent Step 4 Click configuration object. More...
 

Typedefs

typedef struct silentstep4_s silentstep4_t
 Silent Step 4 Click context object.
 

Enumerations

enum  silentstep4_return_value_t { SILENTSTEP4_OK = 0 , SILENTSTEP4_ERROR = -1 }
 Silent Step 4 Click return value data. More...
 

Functions

void silentstep4_cfg_setup (silentstep4_cfg_t *cfg)
 Silent Step 4 configuration object setup function.
 
err_t silentstep4_init (silentstep4_t *ctx, silentstep4_cfg_t *cfg)
 Silent Step 4 initialization function.
 
err_t silentstep4_default_cfg (silentstep4_t *ctx)
 Silent Step 4 default configuration function.
 
err_t silentstep4_write_reg (silentstep4_t *ctx, uint8_t reg, uint32_t data_in)
 Silent Step 4 write reg function.
 
err_t silentstep4_read_reg (silentstep4_t *ctx, uint8_t reg, uint32_t *data_out)
 Silent Step 4 read reg function.
 
err_t silentstep4_pca_write_reg (silentstep4_t *ctx, uint8_t reg, uint8_t data_in)
 Silent Step 4 pca write reg function.
 
err_t silentstep4_pca_read_reg (silentstep4_t *ctx, uint8_t reg, uint8_t *data_out)
 Silent Step 4 pca read reg function.
 
err_t silentstep4_check_com (silentstep4_t *ctx)
 Silent Step 4 check com function.
 
err_t silentstep4_get_en_pin (silentstep4_t *ctx, uint8_t *state)
 Silent Step 4 get en pin function.
 
err_t silentstep4_set_en_pin (silentstep4_t *ctx, uint8_t state)
 Silent Step 4 set en pin function.
 
err_t silentstep4_get_sleep_pin (silentstep4_t *ctx, uint8_t *state)
 Silent Step 4 get sleep pin function.
 
err_t silentstep4_set_sleep_pin (silentstep4_t *ctx, uint8_t state)
 Silent Step 4 set sleep pin function.
 
err_t silentstep4_get_diag0_pin (silentstep4_t *ctx, uint8_t *state)
 Silent Step 4 get diag0 pin function.
 
err_t silentstep4_get_diag1_pin (silentstep4_t *ctx, uint8_t *state)
 Silent Step 4 get diag1 pin function.
 
err_t silentstep4_get_ov_pin (silentstep4_t *ctx, uint8_t *state)
 Silent Step 4 get ov pin function.
 
err_t silentstep4_enable_device (silentstep4_t *ctx)
 Silent Step 4 enable device function.
 
err_t silentstep4_disable_device (silentstep4_t *ctx)
 Silent Step 4 disable device function.
 
void silentstep4_set_direction (silentstep4_t *ctx, uint8_t dir)
 Silent Step 4 set direction function.
 
void silentstep4_switch_direction (silentstep4_t *ctx)
 Silent Step 4 switch direction function.
 
void silentstep4_reset_pca (silentstep4_t *ctx)
 Silent Step 4 reset device function.
 
void silentstep4_set_rst_pin (silentstep4_t *ctx, uint8_t state)
 Silent Step 4 set rst pin function.
 
uint8_t silentstep4_get_int_pin (silentstep4_t *ctx)
 Silent Step 4 get int pin function.
 
void silentstep4_set_step_pin (silentstep4_t *ctx, uint8_t state)
 Silent Step 4 set step pin function.
 
err_t silentstep4_set_toff (silentstep4_t *ctx, uint8_t toff)
 Silent Step 4 set toff function.
 
err_t silentstep4_set_step_res (silentstep4_t *ctx, uint8_t mres)
 Silent Step 4 set step res function.
 
err_t silentstep4_set_run_current (silentstep4_t *ctx, uint8_t irun)
 Silent Step 4 set run current function.
 
void silentstep4_drive_motor (silentstep4_t *ctx, uint32_t steps, uint8_t speed)
 Silent Step 4 driver motor function.
 

Variables

digital_out_t dir
 
digital_out_t rst
 
digital_out_t step
 
digital_in_t int_pin
 
i2c_master_t i2c
 
spi_master_t spi
 
uint8_t slave_address
 
pin_name_t chip_select
 
pin_name_t scl
 
pin_name_t sda
 
pin_name_t miso
 
pin_name_t mosi
 
pin_name_t sck
 
pin_name_t cs
 
pin_name_t dir
 
pin_name_t rst
 
pin_name_t step
 
pin_name_t int_pin
 
uint32_t i2c_speed
 
uint8_t i2c_address
 
uint32_t spi_speed
 
spi_master_mode_t spi_mode
 
spi_master_chip_select_polarity_t cs_polarity
 

Detailed Description

API for configuring and manipulating Silent Step 4 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Typedef Documentation

◆ silentstep4_t

typedef struct silentstep4_s silentstep4_t

Silent Step 4 Click context object.

Context object definition of Silent Step 4 Click driver.

Enumeration Type Documentation

◆ silentstep4_return_value_t

Silent Step 4 Click return value data.

Predefined enum values for driver return values.

Enumerator
SILENTSTEP4_OK 
SILENTSTEP4_ERROR 

Function Documentation

◆ silentstep4_cfg_setup()

void silentstep4_cfg_setup ( silentstep4_cfg_t * cfg)

Silent Step 4 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ silentstep4_check_com()

err_t silentstep4_check_com ( silentstep4_t * ctx)

Silent Step 4 check com function.

This function checks the SPI communication by reading and verifying the device version.

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

◆ silentstep4_default_cfg()

err_t silentstep4_default_cfg ( silentstep4_t * ctx)

Silent Step 4 default configuration function.

This function executes a default configuration of Silent Step 4 click board.

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

◆ silentstep4_disable_device()

err_t silentstep4_disable_device ( silentstep4_t * ctx)

Silent Step 4 disable device function.

This function disables the device by setting the ENABLE pin to high logic state.

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

◆ silentstep4_drive_motor()

void silentstep4_drive_motor ( silentstep4_t * ctx,
uint32_t steps,
uint8_t speed )

Silent Step 4 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 silentstep4_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.

◆ silentstep4_enable_device()

err_t silentstep4_enable_device ( silentstep4_t * ctx)

Silent Step 4 enable device function.

This function enables the device by setting the ENABLE pin to low logic state.

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

◆ silentstep4_get_diag0_pin()

err_t silentstep4_get_diag0_pin ( silentstep4_t * ctx,
uint8_t * state )

Silent Step 4 get diag0 pin function.

This function reads the diag0 pin logic state.

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

◆ silentstep4_get_diag1_pin()

err_t silentstep4_get_diag1_pin ( silentstep4_t * ctx,
uint8_t * state )

Silent Step 4 get diag1 pin function.

This function reads the diag1 pin logic state.

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

◆ silentstep4_get_en_pin()

err_t silentstep4_get_en_pin ( silentstep4_t * ctx,
uint8_t * state )

Silent Step 4 get en pin function.

This function reads the enable pin logic state.

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

◆ silentstep4_get_int_pin()

uint8_t silentstep4_get_int_pin ( silentstep4_t * ctx)

Silent Step 4 get int pin function.

This function returns the INT pin logic state.

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

◆ silentstep4_get_ov_pin()

err_t silentstep4_get_ov_pin ( silentstep4_t * ctx,
uint8_t * state )

Silent Step 4 get ov pin function.

This function reads the ov pin logic state.

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

◆ silentstep4_get_sleep_pin()

err_t silentstep4_get_sleep_pin ( silentstep4_t * ctx,
uint8_t * state )

Silent Step 4 get sleep pin function.

This function reads the sleep pin logic state.

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

◆ silentstep4_init()

err_t silentstep4_init ( silentstep4_t * ctx,
silentstep4_cfg_t * cfg )

Silent Step 4 initialization function.

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

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

◆ silentstep4_pca_read_reg()

err_t silentstep4_pca_read_reg ( silentstep4_t * ctx,
uint8_t reg,
uint8_t * data_out )

Silent Step 4 pca read reg function.

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

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

◆ silentstep4_pca_write_reg()

err_t silentstep4_pca_write_reg ( silentstep4_t * ctx,
uint8_t reg,
uint8_t data_in )

Silent Step 4 pca write reg 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 silentstep4_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.

◆ silentstep4_read_reg()

err_t silentstep4_read_reg ( silentstep4_t * ctx,
uint8_t reg,
uint32_t * data_out )

Silent Step 4 read reg function.

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

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

◆ silentstep4_reset_pca()

void silentstep4_reset_pca ( silentstep4_t * ctx)

Silent Step 4 reset device function.

This function resets the PCA9538A device by toggling the RST pin.

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

◆ silentstep4_set_direction()

void silentstep4_set_direction ( silentstep4_t * ctx,
uint8_t dir )

Silent Step 4 set direction function.

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

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

◆ silentstep4_set_en_pin()

err_t silentstep4_set_en_pin ( silentstep4_t * ctx,
uint8_t state )

Silent Step 4 set en pin function.

This function sets the enable pin logic state.

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

◆ silentstep4_set_rst_pin()

void silentstep4_set_rst_pin ( silentstep4_t * ctx,
uint8_t state )

Silent Step 4 set rst pin function.

This function sets the RST pin logic state.

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

◆ silentstep4_set_run_current()

err_t silentstep4_set_run_current ( silentstep4_t * ctx,
uint8_t irun )

Silent Step 4 set run current function.

This function sets the motor run current bits in IHOLD_IRUN register.

Parameters
[in]ctx: Click context object. See silentstep4_t object definition for detailed explanation.
[in]irun: IRUN bits setting [0-31].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ silentstep4_set_sleep_pin()

err_t silentstep4_set_sleep_pin ( silentstep4_t * ctx,
uint8_t state )

Silent Step 4 set sleep pin function.

This function sets the sleep pin logic state.

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

◆ silentstep4_set_step_pin()

void silentstep4_set_step_pin ( silentstep4_t * ctx,
uint8_t state )

Silent Step 4 set step pin function.

This function sets the STEP pin logic state.

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

◆ silentstep4_set_step_res()

err_t silentstep4_set_step_res ( silentstep4_t * ctx,
uint8_t mres )

Silent Step 4 set step res function.

This function sets the microstep resolution bits in CHOPCONF register.

Parameters
[in]ctx: Click context object. See silentstep4_t object definition for detailed explanation.
[in]mres: MRES bits setting:
  • 0 - 1/256 microsteps,
  • 1 - 1/128 microsteps,
  • 2 - 1/64 microsteps,
  • 3 - 1/32 microsteps,
  • 4 - 1/16 microsteps,
  • 5 - 1/8 microsteps,
  • 6 - quarter step,
  • 7 - half step,
  • 8 - full step.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ silentstep4_set_toff()

err_t silentstep4_set_toff ( silentstep4_t * ctx,
uint8_t toff )

Silent Step 4 set toff function.

This function sets the off time and driver enable bits in CHOPCONF register.

Parameters
[in]ctx: Click context object. See silentstep4_t object definition for detailed explanation.
[in]toff: TOFF bits setting [0-15].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ silentstep4_switch_direction()

void silentstep4_switch_direction ( silentstep4_t * ctx)

Silent Step 4 switch direction function.

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

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

◆ silentstep4_write_reg()

err_t silentstep4_write_reg ( silentstep4_t * ctx,
uint8_t reg,
uint32_t data_in )

Silent Step 4 write reg function.

This function writes a desired 32-bit data to the selected register by using SPI serial interface.

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

Variable Documentation

◆ chip_select

pin_name_t chip_select

Chip select pin descriptor (used for SPI driver).

◆ cs

pin_name_t cs

Chip select pin descriptor for SPI driver.

◆ cs_polarity

spi_master_chip_select_polarity_t cs_polarity

Chip select pin polarity.

◆ dir [1/2]

digital_out_t dir

Direction control pin.

◆ dir [2/2]

pin_name_t dir

Direction control pin.

◆ i2c

i2c_master_t i2c

I2C driver object.

◆ i2c_address

uint8_t i2c_address

I2C slave address.

◆ i2c_speed

uint32_t i2c_speed

I2C serial speed.

◆ int_pin [1/2]

digital_in_t int_pin

PCA9538A interrupt pin.

◆ int_pin [2/2]

pin_name_t int_pin

PCA9538A interrupt pin.

◆ miso

pin_name_t miso

Master input - slave output pin descriptor for SPI driver.

◆ mosi

pin_name_t mosi

Master output - slave input pin descriptor for SPI driver.

◆ rst [1/2]

digital_out_t rst

PCA9538A reset pin.

◆ rst [2/2]

pin_name_t rst

PCA9538A reset pin.

◆ sck

pin_name_t sck

Clock pin descriptor for SPI driver.

◆ scl

pin_name_t scl

Clock pin descriptor for I2C driver.

◆ sda

pin_name_t sda

Bidirectional data pin descriptor for I2C driver.

◆ slave_address

uint8_t slave_address

Device slave address (used for I2C driver).

◆ spi

spi_master_t spi

SPI driver object.

◆ spi_mode

spi_master_mode_t spi_mode

SPI master mode.

◆ spi_speed

uint32_t spi_speed

SPI serial speed.

◆ step [1/2]

digital_out_t step

Step signal pin.

◆ step [2/2]

pin_name_t step

Step signal pin.