brushless20 2.1.0.0
Brushless 20 Click Driver

API for configuring and manipulating Brushless 20 Click driver. More...

Topics

 Brushless 20 Registers List
 List of registers of Brushless 20 Click driver.
 
 Brushless 20 Registers Settings
 Settings for registers of Brushless 20 Click driver.
 
 Brushless 20 MikroBUS Map
 MikroBUS pin mapping of Brushless 20 Click driver.
 

Functions

void brushless20_cfg_setup (brushless20_cfg_t *cfg)
 Brushless 20 configuration object setup function.
 
err_t brushless20_init (brushless20_t *ctx, brushless20_cfg_t *cfg)
 Brushless 20 initialization function.
 
err_t brushless20_default_cfg (brushless20_t *ctx)
 Brushless 20 default configuration function.
 
err_t brushless20_write_register (brushless20_t *ctx, uint8_t reg, uint8_t data_in)
 Brushless 20 write register function.
 
err_t brushless20_read_register (brushless20_t *ctx, uint8_t reg, uint8_t *data_out)
 Brushless 20 read register function.
 
err_t brushless20_set_pins (brushless20_t *ctx, uint8_t set_mask, uint8_t clr_mask)
 Brushless 20 set pins function.
 
err_t brushless20_get_fault_pin (brushless20_t *ctx)
 Brushless 20 get fault pin function.
 
void brushless20_reset_port_expander (brushless20_t *ctx)
 Brushless 20 reset port expander function.
 
void brushless20_set_rst_pin (brushless20_t *ctx, uint8_t state)
 Brushless 20 set rst pin function.
 
void brushless20_enter_sleep_mode (brushless20_t *ctx)
 Brushless 20 enter sleep mode function.
 
void brushless20_exit_sleep_mode (brushless20_t *ctx)
 Brushless 20 exit sleep mode function.
 
uint8_t brushless20_get_int_pin (brushless20_t *ctx)
 Brushless 20 get int pin function.
 
err_t brushless20_set_trapezoidal_com_state (brushless20_t *ctx, uint8_t state)
 Brushless 20 set trapezoidal com state function.
 
err_t brushless20_toggle_pin (brushless20_t *ctx, uint8_t pin_mask, uint8_t speed)
 Brushless 20 toggle pin function.
 
err_t brushless20_perform_com_sequence (brushless20_t *ctx, uint8_t dir, uint8_t speed)
 Brushless 20 perform com sequence function.
 
err_t brushless20_drive_motor (brushless20_t *ctx, uint8_t dir, uint8_t speed, uint32_t time_ms)
 Brushless 20 drive motor function.
 

Detailed Description

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

◆ brushless20_cfg_setup()

void brushless20_cfg_setup ( brushless20_cfg_t * cfg)

Brushless 20 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ brushless20_default_cfg()

err_t brushless20_default_cfg ( brushless20_t * ctx)

Brushless 20 default configuration function.

This function executes a default configuration of Brushless 20 click board.

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

◆ brushless20_drive_motor()

err_t brushless20_drive_motor ( brushless20_t * ctx,
uint8_t dir,
uint8_t speed,
uint32_t time_ms )

Brushless 20 drive motor function.

This function drives the motor for a desired time by performing multiple commutation sequences for the selected rotation direction at a desired speed.

Parameters
[in]ctx: Click context object. See brushless20_t object definition for detailed explanation.
[in]dir: Rotation direction.
  • 0 - Clockwise,
  • 1 - Counter-Clockwise.
[in]speed: Speed (0-100).
[in]time_ms: Driving time in milliseconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
In order to improve driving time accuracy, measure and adjust the following macros for your setup. Call brushless20_perform_com_sequence for MAX and MAX-1 speed and measure the duration of each execution. BRUSHLESS20_COM_SEQ_DURATION_FOR_SPEED_MAX = duration for a single commutation sequance in milliseconds for MAX speed. BRUSHLESS20_COM_SEQ_DURATION_SPEED_STEP = duration for a single commutation sequance in milliseconds for MAX-1 speed - BRUSHLESS20_COM_SEQ_DURATION_FOR_SPEED_MAX..

◆ brushless20_enter_sleep_mode()

void brushless20_enter_sleep_mode ( brushless20_t * ctx)

Brushless 20 enter sleep mode function.

This function enters sleep mode by setting the SLP pin to low logic state.

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

◆ brushless20_exit_sleep_mode()

void brushless20_exit_sleep_mode ( brushless20_t * ctx)

Brushless 20 exit sleep mode function.

This function exits sleep mode by setting the SLP pin to high logic state.

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

◆ brushless20_get_fault_pin()

err_t brushless20_get_fault_pin ( brushless20_t * ctx)

Brushless 20 get fault pin function.

This function returns the fault pin logic state.

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

◆ brushless20_get_int_pin()

uint8_t brushless20_get_int_pin ( brushless20_t * ctx)

Brushless 20 get int pin function.

This function returns the INT pin logic state.

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

◆ brushless20_init()

err_t brushless20_init ( brushless20_t * ctx,
brushless20_cfg_t * cfg )

Brushless 20 initialization function.

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

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

◆ brushless20_perform_com_sequence()

err_t brushless20_perform_com_sequence ( brushless20_t * ctx,
uint8_t dir,
uint8_t speed )

Brushless 20 perform com sequence function.

This function performs a single commutation sequence for the selected rotation direction at a desired speed.

Parameters
[in]ctx: Click context object. See brushless20_t object definition for detailed explanation.
[in]dir: Rotation direction.
  • 0 - Clockwise,
  • 1 - Counter-Clockwise.
[in]speed: Speed (0-100).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ brushless20_read_register()

err_t brushless20_read_register ( brushless20_t * ctx,
uint8_t reg,
uint8_t * data_out )

Brushless 20 read register function.

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

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

◆ brushless20_reset_port_expander()

void brushless20_reset_port_expander ( brushless20_t * ctx)

Brushless 20 reset port expander function.

This function resets the port expander by toggling the RST pin.

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

◆ brushless20_set_pins()

err_t brushless20_set_pins ( brushless20_t * ctx,
uint8_t set_mask,
uint8_t clr_mask )

Brushless 20 set pins function.

This function sets and clears the value of the selected pins of PCA9538A port expander.

Parameters
[in]ctx: Click context object. See brushless20_t object definition for detailed explanation.
[in]clr_mask: Pin clear mask.
[in]set_mask: Pin set mask.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ brushless20_set_rst_pin()

void brushless20_set_rst_pin ( brushless20_t * ctx,
uint8_t state )

Brushless 20 set rst pin function.

This function sets the RST pin logic state.

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

◆ brushless20_set_trapezoidal_com_state()

err_t brushless20_set_trapezoidal_com_state ( brushless20_t * ctx,
uint8_t state )

Brushless 20 set trapezoidal com state function.

This function sets the IN1-3, and EN1-3 pins state for the selected trapezoidal commutation state.

Parameters
[in]ctx: Click context object. See brushless20_t object definition for detailed explanation.
[in]state: Trapezoidal commutation state (0-7) - BRUSHLESS20_TR_COM_STATE_x macros.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ brushless20_toggle_pin()

err_t brushless20_toggle_pin ( brushless20_t * ctx,
uint8_t pin_mask,
uint8_t speed )

Brushless 20 toggle pin function.

This function toggles the selected pin of PCA9538A port expander BRUSHLESS20_NUM_PIN_TOGGLE times with a delay of (speed + 1) * 100us between each toggle.

Parameters
[in]ctx: Click context object. See brushless20_t object definition for detailed explanation.
[in]pin_mask: Pin to toggle mask.
[in]speed: Speed (0-100).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ brushless20_write_register()

err_t brushless20_write_register ( brushless20_t * ctx,
uint8_t reg,
uint8_t data_in )

Brushless 20 write register 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 brushless20_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.