servo2 2.1.0.0
Loading...
Searching...
No Matches
Servo 2 Click Driver

API for configuring and manipulating Servo 2 Click driver. More...

Topics

 Servo 2 PWM Settings
 Settings for configuration of Servo 2 Click driver.
 Servo 2 MikroBUS Map
 MikroBUS pin mapping of Servo 2 Click driver.

Functions

void servo2_cfg_setup (servo2_cfg_t *cfg)
 Servo 2 configuration object setup function.
err_t servo2_init (servo2_t *ctx, servo2_cfg_t *cfg)
 Servo 2 initialization function.
err_t servo2_set_duty_cycle (servo2_t *ctx, float duty_cycle)
 Servo 2 sets PWM duty cycle.
err_t servo2_pwm_stop (servo2_t *ctx)
 Servo 2 stop PWM module.
err_t servo2_pwm_start (servo2_t *ctx)
 Servo 2 start PWM module.
void servo2_write_data (servo2_t *ctx, uint8_t *data_in, uint8_t len)
 Servo 2 write data function.
void servo2_set_sclk_pin (servo2_t *ctx, uint8_t state)
 Servo 2 set SCLK pin function.
void servo2_set_sin_pin (servo2_t *ctx, uint8_t state)
 Servo 2 set SIN pin function.
void servo2_set_xlat_pin (servo2_t *ctx, uint8_t state)
 Servo 2 set XLAT pin function.
void servo2_set_blank_pin (servo2_t *ctx, uint8_t state)
 Servo 2 set BLANK pin function.
uint8_t servo2_get_sout_pin (servo2_t *ctx)
 Servo 2 get SOUT pin state function.
uint8_t servo2_get_xerr_pin (servo2_t *ctx)
 Servo 2 get XERR pin state function.
err_t servo2_set_channel_pwm (servo2_t *ctx, uint8_t ch_num, uint16_t pwm_out)
 Servo 2 set channel PWM function.
err_t servo2_set_angle (servo2_t *ctx, uint8_t ch_num, uint8_t angle)
 Servo 2 set angle function.
void servo2_update_output (servo2_t *ctx)
 Servo 2 update output function.

Detailed Description

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

◆ servo2_cfg_setup()

void servo2_cfg_setup ( servo2_cfg_t * cfg)

Servo 2 configuration object setup function.

This function initializes Click configuration structure to initial values.

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

◆ servo2_get_sout_pin()

uint8_t servo2_get_sout_pin ( servo2_t * ctx)

Servo 2 get SOUT pin state function.

This function returns the logic state of the SOUT (serial output) pin.

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

◆ servo2_get_xerr_pin()

uint8_t servo2_get_xerr_pin ( servo2_t * ctx)

Servo 2 get XERR pin state function.

This function returns the logic state of the XERR (error) pin.

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

◆ servo2_init()

err_t servo2_init ( servo2_t * ctx,
servo2_cfg_t * cfg )

Servo 2 initialization function.

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

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

◆ servo2_pwm_start()

err_t servo2_pwm_start ( servo2_t * ctx)

Servo 2 start PWM module.

This function starts the PWM module output.

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

◆ servo2_pwm_stop()

err_t servo2_pwm_stop ( servo2_t * ctx)

Servo 2 stop PWM module.

This function stops the PWM module output.

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

◆ servo2_set_angle()

err_t servo2_set_angle ( servo2_t * ctx,
uint8_t ch_num,
uint8_t angle )

Servo 2 set angle function.

This function sets the servo angle for a specific channel or all channels.

Parameters
[in]ctx: Click context object. See servo2_t object definition for detailed explanation.
[in]ch_num: Channel number (0-15 or all channels).
[in]angle: Servo angle in degrees (0-180).
Returns
  • 0 - Success,
  • -1 - Error.

◆ servo2_set_blank_pin()

void servo2_set_blank_pin ( servo2_t * ctx,
uint8_t state )

Servo 2 set BLANK pin function.

This function sets the BLANK pin to the specified logic state.

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

◆ servo2_set_channel_pwm()

err_t servo2_set_channel_pwm ( servo2_t * ctx,
uint8_t ch_num,
uint16_t pwm_out )

Servo 2 set channel PWM function.

This function sets the PWM output for a specific channel or all channels.

Parameters
[in]ctx: Click context object. See servo2_t object definition for detailed explanation.
[in]ch_num: Channel number (0-15 or all channels).
[in]pwm_out: PWM output value.
Returns
  • 0 - Success,
  • -1 - Error.

◆ servo2_set_duty_cycle()

err_t servo2_set_duty_cycle ( servo2_t * ctx,
float duty_cycle )

Servo 2 sets PWM duty cycle.

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

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

◆ servo2_set_sclk_pin()

void servo2_set_sclk_pin ( servo2_t * ctx,
uint8_t state )

Servo 2 set SCLK pin function.

This function sets the SCLK (serial clock) pin to the specified logic state.

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

◆ servo2_set_sin_pin()

void servo2_set_sin_pin ( servo2_t * ctx,
uint8_t state )

Servo 2 set SIN pin function.

This function sets the SIN (serial input) pin to the specified logic state.

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

◆ servo2_set_xlat_pin()

void servo2_set_xlat_pin ( servo2_t * ctx,
uint8_t state )

Servo 2 set XLAT pin function.

This function sets the XLAT (latch) pin to the specified logic state.

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

◆ servo2_update_output()

void servo2_update_output ( servo2_t * ctx)

Servo 2 update output function.

This function updates the PWM output values for all channels by writing them to the device.

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

◆ servo2_write_data()

void servo2_write_data ( servo2_t * ctx,
uint8_t * data_in,
uint8_t len )

Servo 2 write data function.

This function writes data to the device via the serial interface, updates the internal registers, and starts the PWM for grayscale data output.

Parameters
[in]ctx: Click context object. See servo2_t object definition for detailed explanation.
[in]data_in: Pointer to the data to write.
[in]len: Number of bytes to write.
Returns
None.