usbcsink3 2.1.0.0
USB-C Sink 3 Click Driver

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

Topics

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

Functions

void usbcsink3_cfg_setup (usbcsink3_cfg_t *cfg)
 USB-C Sink 3 configuration object setup function.
 
err_t usbcsink3_init (usbcsink3_t *ctx, usbcsink3_cfg_t *cfg)
 USB-C Sink 3 initialization function.
 
err_t usbcsink3_default_cfg (usbcsink3_t *ctx)
 USB-C Sink 3 default configuration function.
 
err_t usbcsink3_i2c_write (usbcsink3_t *ctx, uint8_t reg, uint8_t data_in)
 USB-C Sink 3 I2C writing function.
 
err_t usbcsink3_i2c_read (usbcsink3_t *ctx, uint8_t reg, uint8_t *data_out)
 USB-C Sink 3 I2C reading function.
 
err_t usbcsink3_spi_write (usbcsink3_t *ctx, uint8_t reg, uint8_t data_in)
 USB-C Sink 3 SPI writing function.
 
err_t usbcsink3_read_raw_adc (usbcsink3_t *ctx, uint16_t *raw_adc)
 USB-C Sink 3 read raw ADC value function.
 
err_t usbcsink3_read_voltage (usbcsink3_t *ctx, float *voltage)
 USB-C Sink 3 read voltage level function.
 
err_t usbcsink3_set_vref (usbcsink3_t *ctx, float vref)
 USB-C Sink 3 set vref function.
 
err_t usbcsink3_get_vbus (usbcsink3_t *ctx, float *vbus)
 USB-C Sink 3 get VBUS function.
 
err_t usbcsink3_set_wiper (usbcsink3_t *ctx, uint8_t wiper_pos)
 USB-C Sink 3 set the wiper position function.
 
err_t usbcsink3_set_resistence (usbcsink3_t *ctx, float resistence)
 USB-C Sink 3 set the resistance function.
 
err_t usbcsink3_set_voltage (usbcsink3_t *ctx, usbcsink3_vtg_sel_t voltage)
 USB-C Sink 3 set the voltage function.
 
err_t usbcsink3_set_power (usbcsink3_t *ctx, usbcsink3_pwr_sel_t power)
 USB-C Sink 3 set the power function.
 

Detailed Description

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

◆ usbcsink3_cfg_setup()

void usbcsink3_cfg_setup ( usbcsink3_cfg_t * cfg)

USB-C Sink 3 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ usbcsink3_default_cfg()

err_t usbcsink3_default_cfg ( usbcsink3_t * ctx)

USB-C Sink 3 default configuration function.

This function executes a default configuration of USB-C Sink 3 click board.

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

◆ usbcsink3_get_vbus()

err_t usbcsink3_get_vbus ( usbcsink3_t * ctx,
float * vbus )

USB-C Sink 3 get VBUS function.

This function reads raw ADC value and converts it to proportional voltage level and calculate the output voltage using the voltage divider calculation.

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

◆ usbcsink3_i2c_read()

err_t usbcsink3_i2c_read ( usbcsink3_t * ctx,
uint8_t reg,
uint8_t * data_out )

USB-C Sink 3 I2C reading function.

This function reads a data byte from the selected register of the TCA9536, Remote 4-Bit I2C and SMBus I/O Expander with Configuration Registers on the USB-C Sink 3 Click board™.

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

◆ usbcsink3_i2c_write()

err_t usbcsink3_i2c_write ( usbcsink3_t * ctx,
uint8_t reg,
uint8_t data_in )

USB-C Sink 3 I2C writing function.

This function writes a data byte to the selected register of the TCA9536, Remote 4-Bit I2C and SMBus I/O Expander with Configuration Registers on the USB-C Sink 3 Click board™.

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

◆ usbcsink3_init()

err_t usbcsink3_init ( usbcsink3_t * ctx,
usbcsink3_cfg_t * cfg )

USB-C Sink 3 initialization function.

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

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

◆ usbcsink3_read_raw_adc()

err_t usbcsink3_read_raw_adc ( usbcsink3_t * ctx,
uint16_t * raw_adc )

USB-C Sink 3 read raw ADC value function.

This function ads raw ADC value.

Parameters
[in]ctx: Click context object. See usbcsink3_t object definition for detailed explanation.
[out]raw_adc: Output ADC result.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink3_read_voltage()

err_t usbcsink3_read_voltage ( usbcsink3_t * ctx,
float * voltage )

USB-C Sink 3 read voltage level function.

This function reads raw ADC value and converts it to proportional voltage level.

Parameters
[in]ctx: Click context object. See usbcsink3_t object definition for detailed explanation.
[out]voltage: Output voltage level [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered reference voltage.

◆ usbcsink3_set_power()

err_t usbcsink3_set_power ( usbcsink3_t * ctx,
usbcsink3_pwr_sel_t power )

USB-C Sink 3 set the power function.

This function sets the output power by sets desired resistance value of the MCP41100T, Single/Dual Digital Potentiometer with SPI Interface on the USB-C Sink 3 Click board™.

Parameters
[in]ctx: Click context object. See usbcsink3_t object definition for detailed explanation.
[in]power: Power from 12.0 to 100.0 [W]. See usbcsink3_pwr_sel_t definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink3_set_resistence()

err_t usbcsink3_set_resistence ( usbcsink3_t * ctx,
float resistence )

USB-C Sink 3 set the resistance function.

This function sets the resistance of the MCP41100T, Single/Dual Digital Potentiometer with SPI Interface on the USB-C Sink 3 Click board™.

Parameters
[in]ctx: Click context object. See usbcsink3_t object definition for detailed explanation.
[in]resistence: Resistance from 6.8 to 91.0 [kOhm].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink3_set_voltage()

err_t usbcsink3_set_voltage ( usbcsink3_t * ctx,
usbcsink3_vtg_sel_t voltage )

USB-C Sink 3 set the voltage function.

This function sets the output voltage of the TCA9536, Remote 4-Bit I2C and SMBus I/O Expander with Configuration Registers on the USB-C Sink 3 Click board™.

Parameters
[in]ctx: Click context object. See usbcsink3_t object definition for detailed explanation.
[in]voltage: Voltage from 5.0 to 17.2 [V]. See usbcsink3_vtg_sel_t definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink3_set_vref()

err_t usbcsink3_set_vref ( usbcsink3_t * ctx,
float vref )

USB-C Sink 3 set vref function.

This function sets the voltage reference for the USB-C Sink 3 click driver.

Parameters
[in]ctx: Click context object. See usbcsink3_t object definition for detailed explanation.
[in]vref: Reference voltage [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The default voltage reference set with usbcsink3_init is 3.3V.

◆ usbcsink3_set_wiper()

err_t usbcsink3_set_wiper ( usbcsink3_t * ctx,
uint8_t wiper_pos )

USB-C Sink 3 set the wiper position function.

This function sets the position of the wiper of the MCP41100T, Single/Dual Digital Potentiometer with SPI Interface on the USB-C Sink 3 Click board™.

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

◆ usbcsink3_spi_write()

err_t usbcsink3_spi_write ( usbcsink3_t * ctx,
uint8_t reg,
uint8_t data_in )

USB-C Sink 3 SPI writing function.

This function writes a data byte to the selected register of the MCP41100T, Single/Dual Digital Potentiometer with SPI Interface on the USB-C Sink 3 Click board™.

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