usbcsink 2.0.0.0
USB-C Sink Click Driver

API for configuring and manipulating USB-C Sink Click driver. More...

Topics

 USB-C Sink Registers List
 List of registers of USB-C Sink Click driver.
 
 USB-C Sink Registers Settings
 Settings for registers of USB-C Sink Click driver.
 
 USB-C Sink MikroBUS Map
 MikroBUS pin mapping of USB-C Sink Click driver.
 

Functions

void usbcsink_cfg_setup (usbcsink_cfg_t *cfg)
 USB-C Sink configuration object setup function.
 
err_t usbcsink_init (usbcsink_t *ctx, usbcsink_cfg_t *cfg)
 USB-C Sink initialization function.
 
err_t usbcsink_generic_write (usbcsink_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 USB-C Sink I2C writing function.
 
err_t usbcsink_generic_read (usbcsink_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 USB-C Sink I2C reading function.
 
void usbcsink_hw_reset (usbcsink_t *ctx)
 HW reset function.
 
uint8_t usbcsink_get_pdo2 (usbcsink_t *ctx)
 Get PO2 pin state function.
 
uint8_t usbcsink_get_pdo3 (usbcsink_t *ctx)
 Get PO3 pin state function.
 
uint8_t usbcsink_get_interrupt (usbcsink_t *ctx)
 Get INT pin state function.
 
void usbcsink_write_byte (usbcsink_t *ctx, uint8_t reg, uint8_t tx_data)
 Write byte function.
 
uint8_t usbcsink_read_byte (usbcsink_t *ctx, uint8_t reg)
 Read byte function.
 
uint8_t usbcsink_dev_chk (usbcsink_t *ctx)
 Check device communication function.
 
err_t usbcsink_cust_wr_sec (usbcsink_t *ctx, uint8_t sec_num, uint8_t *sec_data)
 Write sector function.
 
err_t usbcsink_cust_ent_wr_mode (usbcsink_t *ctx, uint8_t er_sec)
 Enter the write mode function.
 
err_t usbcsink_cust_ext_test_mode (usbcsink_t *ctx)
 Exit write mode function.
 
void usbcsink_load_data (usbcsink_t *ctx)
 Load data function.
 
void usbcsink_upload_new_data (usbcsink_t *ctx, uint8_t def_vals)
 Upload data function.
 
void usbcsink_set_voltage (uint8_t pdo_numb, float volt)
 Set the voltage function.
 
float usbcsink_get_voltage (uint8_t pdo_numb)
 Get the voltage function.
 
void usbcsink_set_current (uint8_t pdo_numb, float curr)
 Set the current function.
 
float usbcsink_get_current (uint8_t pdo_numb)
 Get the current function.
 
void usbcsink_set_lo_volt_limit (uint8_t pdo_numb, uint8_t value)
 Set the lower voltage limit function.
 
uint8_t usbcsink_get_lo_volt_limit (uint8_t pdo_numb)
 Get the lower voltage limit function.
 
void usbcsink_set_up_volt_limit (uint8_t pdo_numb, uint8_t value)
 Set the upper voltage limit function.
 
uint8_t usbcsink_get_up_volt_limit (uint8_t pdo_numb)
 Get the over voltage limit function.
 
void usbcsink_set_flx_curr (float value)
 Set the flexible current function.
 
float usbcsink_get_flx_curr (void)
 Get the flexible current function.
 
void usbcsink_set_pdo_num (uint8_t pdo_numb)
 Set the number of sink function.
 
uint8_t usbcsink_get_pdo_num (void)
 Get the number of sink function.
 
void usbcsink_set_ext_pow (uint8_t value)
 Set the external source of power function.
 
uint8_t usbcsink_get_ext_pow (void)
 Get the external source of power function.
 
void usbcsink_set_usb_com_capa (uint8_t value)
 Set the USB capable function.
 
uint8_t usbcsink_get_usb_com_cap (void)
 Get the USB capable function.
 
void usbcsink_set_cfg_ok_gpio (uint8_t value)
 Set the config OK GPIO function.
 
uint8_t usbcsink_get_cfg_ok_gpio (void)
 Get the config OK GPIO function.
 
void usbcsink_set_gpio_ctl (uint8_t value)
 Set the config CTRL GPIO function.
 
uint8_t usbcsink_get_gpio_ctl (void)
 Get the config CTRL GPIO function.
 
void usbcsink_set_pow_above_5v_only (uint8_t value)
 Set the power only above 5V function.
 
uint8_t usbcsink_get_pow_above_5v_only (void)
 Get the power only above 5V function.
 
void usbcsink_set_req_src_current (uint8_t value)
 Set the request operating current function.
 
uint8_t usbcsink_get_req_src_curr (void)
 Get the request operating current function.
 

Detailed Description

API for configuring and manipulating USB-C Sink 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

◆ usbcsink_cfg_setup()

void usbcsink_cfg_setup ( usbcsink_cfg_t * cfg)

USB-C Sink configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ usbcsink_cust_ent_wr_mode()

err_t usbcsink_cust_ent_wr_mode ( usbcsink_t * ctx,
uint8_t er_sec )

Enter the write mode function.

The function enter the write mode of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
[in]er_sec: Sector number.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ usbcsink_cust_ext_test_mode()

err_t usbcsink_cust_ext_test_mode ( usbcsink_t * ctx)

Exit write mode function.

The function the exit of writing mode of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

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

◆ usbcsink_cust_wr_sec()

err_t usbcsink_cust_wr_sec ( usbcsink_t * ctx,
uint8_t sec_num,
uint8_t * sec_data )

Write sector function.

The function write sector is used to write multiple data bytes to a group of sector registers of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object.
[in]sec_num: Sector number.
[in]sec_data: Sector data to be written. See usbcsink_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ usbcsink_dev_chk()

uint8_t usbcsink_dev_chk ( usbcsink_t * ctx)

Check device communication function.

The function check device communication of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
Returns
It will return 0x01 on success or 0x00 on failure.

◆ usbcsink_generic_read()

err_t usbcsink_generic_read ( usbcsink_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

USB-C Sink I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink_generic_write()

err_t usbcsink_generic_write ( usbcsink_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

USB-C Sink I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink_get_cfg_ok_gpio()

uint8_t usbcsink_get_cfg_ok_gpio ( void )

Get the config OK GPIO function.

The function get the config OK GPIO of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
  • 0 - Source attached.
  • 1 - No source attached.

◆ usbcsink_get_current()

float usbcsink_get_current ( uint8_t pdo_numb)

Get the current function.

The function get the current to be requested for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
Returns
Float voltage value.
Note
Valid current values are: 0.00, 0.50, 0.75, 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75, 3.00, 3.50, 4.00, 4.50, 5.00.

◆ usbcsink_get_ext_pow()

uint8_t usbcsink_get_ext_pow ( void )

Get the external source of power function.

The function get the external source of power of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
  • 0 - No external source of power.
  • 1 - An external power source is available and is sufficient to adequately power the system while charging external devices.

◆ usbcsink_get_flx_curr()

float usbcsink_get_flx_curr ( void )

Get the flexible current function.

The function set the flexible current value common to all PDOs of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
Float flexible current value.

◆ usbcsink_get_gpio_ctl()

uint8_t usbcsink_get_gpio_ctl ( void )

Get the config CTRL GPIO function.

The function get the config CTRL GPIO of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
  • 0 - Source attached.
  • 1 - No source attached.

◆ usbcsink_get_interrupt()

uint8_t usbcsink_get_interrupt ( usbcsink_t * ctx)

Get INT pin state function.

The function get INT pin state reset the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
Returns
State of the INT pin.

◆ usbcsink_get_lo_volt_limit()

uint8_t usbcsink_get_lo_volt_limit ( uint8_t pdo_numb)

Get the lower voltage limit function.

The function get the under votlage lock out parameter for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
Returns
8-bit voltage value.

◆ usbcsink_get_pdo2()

uint8_t usbcsink_get_pdo2 ( usbcsink_t * ctx)

Get PO2 pin state function.

The function get PO2 ( AN ) pin state reset the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
Returns
State of the PO2 ( AN ) pin.

◆ usbcsink_get_pdo3()

uint8_t usbcsink_get_pdo3 ( usbcsink_t * ctx)

Get PO3 pin state function.

The function get PO3 ( CS ) pin state reset the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
Returns
State of the PO3 ( CS ) pin.

◆ usbcsink_get_pdo_num()

uint8_t usbcsink_get_pdo_num ( void )

Get the number of sink function.

The function set the number of sink PDOs of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
Number of the sink PDOs[ 1 - 3 ] ( profile ).

◆ usbcsink_get_pow_above_5v_only()

uint8_t usbcsink_get_pow_above_5v_only ( void )

Get the power only above 5V function.

The function get the power only above 5V parameter configuration of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - Enabled when source is attached.
  • 1 - Enabled only when source attached.

◆ usbcsink_get_req_src_curr()

uint8_t usbcsink_get_req_src_curr ( void )

Get the request operating current function.

The function get the request operating current selects which operation current from the sink or the source is to be requested in the RDO message of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
  • 0 - Request I SNK sink as operating current in RDO message.
  • 1 - Request I SRC sink as operating current in RDO message.

◆ usbcsink_get_up_volt_limit()

uint8_t usbcsink_get_up_volt_limit ( uint8_t pdo_numb)

Get the over voltage limit function.

The function get the over votlage lock out parameter for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
Returns
8-bit over votlage lock out parameter.

◆ usbcsink_get_usb_com_cap()

uint8_t usbcsink_get_usb_com_cap ( void )

Get the USB capable function.

The function get the USB capable parameter value of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Returns
  • 0 - Sink does not support data communication.
  • 1 - Sink does support data communication.

◆ usbcsink_get_voltage()

float usbcsink_get_voltage ( uint8_t pdo_numb)

Get the voltage function.

The function get the voltage to be requested for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
Returns
Float voltage value.

◆ usbcsink_hw_reset()

void usbcsink_hw_reset ( usbcsink_t * ctx)

HW reset function.

The function hw reset, reset the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[out]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
Returns
Nothing.

◆ usbcsink_init()

err_t usbcsink_init ( usbcsink_t * ctx,
usbcsink_cfg_t * cfg )

USB-C Sink initialization function.

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

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

◆ usbcsink_load_data()

void usbcsink_load_data ( usbcsink_t * ctx)

Load data function.

The function load data is used to read the non-volatile memory of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

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

◆ usbcsink_read_byte()

uint8_t usbcsink_read_byte ( usbcsink_t * ctx,
uint8_t reg )

Read byte function.

The function read a the byte of data from the targeted 8-bit register address of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
[in]reg: 8-bit register address.
Returns
8-bit read data.

◆ usbcsink_set_cfg_ok_gpio()

void usbcsink_set_cfg_ok_gpio ( uint8_t value)

Set the config OK GPIO function.

The function set the config OK GPIO of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - Source attached.
  • 1 - No source attached
Returns
Nothing.

◆ usbcsink_set_current()

void usbcsink_set_current ( uint8_t pdo_numb,
float curr )

Set the current function.

The function set the current to be requested for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
[in]curr: Float current value.
Returns
Nothing.

◆ usbcsink_set_ext_pow()

void usbcsink_set_ext_pow ( uint8_t value)

Set the external source of power function.

The function set the external source of power of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - No external source of power.
  • 1 - An external power source is available and is sufficient to adequately power the system while charging external devices.
Returns
Nothing.

◆ usbcsink_set_flx_curr()

void usbcsink_set_flx_curr ( float value)

Set the flexible current function.

The function set the flexible current value common to all PDOs of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value: Float flexible current data.
Returns
Nothing.

◆ usbcsink_set_gpio_ctl()

void usbcsink_set_gpio_ctl ( uint8_t value)

Set the config CTRL GPIO function.

The function set the config CTRL GPIO of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - Source attached.
  • 1 - No source attached
Returns
Nothing.

◆ usbcsink_set_lo_volt_limit()

void usbcsink_set_lo_volt_limit ( uint8_t pdo_numb,
uint8_t value )

Set the lower voltage limit function.

The function set the under votlage lock out parameter for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
[in]value: 8-bit under votlage lock out parameter.
Returns
Nothing.
Note
Valid high voltage limits are 5-20% in 1% increments. PDO1 has a fixed lower limit to 3.3V.

◆ usbcsink_set_pdo_num()

void usbcsink_set_pdo_num ( uint8_t pdo_numb)

Set the number of sink function.

The function set the the number of sink PDOs of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
Returns
Nothing.

◆ usbcsink_set_pow_above_5v_only()

void usbcsink_set_pow_above_5v_only ( uint8_t value)

Set the power only above 5V function.

The function set the power only above 5V parameter configuration of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - Source attached.
  • 1 - No source attached
Returns
Nothing.

◆ usbcsink_set_req_src_current()

void usbcsink_set_req_src_current ( uint8_t value)

Set the request operating current function.

The function set the request operating current selects which operation current from the sink or the source is to be requested in the RDO message of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - Request I SNK sink as operating current in RDO message.
  • 1 - Request I SRC sink as operating current in RDO message.
Returns
Nothing.

◆ usbcsink_set_up_volt_limit()

void usbcsink_set_up_volt_limit ( uint8_t pdo_numb,
uint8_t value )

Set the upper voltage limit function.

The function set the over votlage lock out parameter for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
[in]value: 8-bit over votlage lock out parameter.
Returns
Nothing.
Note
Valid high voltage limits are 5-20% in 1% increments.

◆ usbcsink_set_usb_com_capa()

void usbcsink_set_usb_com_capa ( uint8_t value)

Set the USB capable function.

The function set the USB capable parameter value of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]value:
  • 0 - Sink does not support data communication.
  • 1 - Sink does support data communication.
Returns
Nothing.

◆ usbcsink_set_voltage()

void usbcsink_set_voltage ( uint8_t pdo_numb,
float volt )

Set the voltage function.

The function sets the voltage to be requested for each of the three power data objects ( PDO ) of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]pdo_numb: Number of the sink PDOs[ 1 - 3 ] ( profile ).
[in]volt: Float voltage value.
Returns
Nothing.

◆ usbcsink_upload_new_data()

void usbcsink_upload_new_data ( usbcsink_t * ctx,
uint8_t def_vals )

Upload data function.

The function upload data is used to write new data to the non-volatile memory of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object.
[in]def_vals: Default values. See usbcsink_t object definition for detailed explanation.
Returns
Nothing.

◆ usbcsink_write_byte()

void usbcsink_write_byte ( usbcsink_t * ctx,
uint8_t reg,
uint8_t tx_data )

Write byte function.

The function write byte the byte of data to the targeted 8-bit register address of the STUSB4500 Standalone USB PD sink controller on USB-C Sink Click board.

Parameters
[in]ctx: Click context object. See usbcsink_t object definition for detailed explanation.
[in]reg: 8-bit register address.
[in]tx_data: Data to be written.
Returns
Nothing.