usbcsink2 2.1.0.0
USB-C Sink 2 Click Driver

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

Topics

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

Functions

void usbcsink2_cfg_setup (usbcsink2_cfg_t *cfg)
 USB-C Sink 2 configuration object setup function.
 
err_t usbcsink2_init (usbcsink2_t *ctx, usbcsink2_cfg_t *cfg)
 USB-C Sink 2 initialization function.
 
err_t usbcsink2_default_cfg (usbcsink2_t *ctx)
 USB-C Sink 2 default configuration function.
 
err_t usbcsink2_generic_write (usbcsink2_t *ctx, uint8_t cmd, uint8_t *data_in, uint8_t len)
 USB-C Sink 2 data writing function.
 
err_t usbcsink2_generic_read (usbcsink2_t *ctx, uint8_t cmd, uint8_t *data_out, uint8_t len)
 USB-C Sink 2 data reading function.
 
err_t usbcsink2_read_raw_adc (usbcsink2_t *ctx, uint16_t *raw_adc)
 USB-C Sink 2 read raw ADC value function.
 
err_t usbcsink2_read_voltage (usbcsink2_t *ctx, float *voltage)
 USB-C Sink 2 read voltage level function.
 
err_t usbcsink2_set_vref (usbcsink2_t *ctx, float vref)
 USB-C Sink 2 set vref function.
 
err_t usbcsink2_read_pdo (usbcsink2_t *ctx, uint8_t *pdo)
 USB-C Sink 2 PDO data reading function.
 
err_t usbcsink2_get_pdo_num (usbcsink2_t *ctx, uint8_t *pdo_num)
 USB-C Sink 2 PDO number reading function.
 
err_t usbcsink2_read_status (usbcsink2_t *ctx, uint8_t *status)
 USB-C Sink 2 status reading function.
 
err_t usbcsink2_wait_rdo_req_success (usbcsink2_t *ctx)
 USB-C Sink 2 wait RDO request function.
 
err_t usbcsink2_get_pdo_voltage (usbcsink2_t *ctx, float *voltage_mv)
 USB-C Sink 2 get the voltage function.
 
err_t usbcsink2_get_pdo_current (usbcsink2_t *ctx, float *current_ma)
 USB-C Sink 2 get the current function.
 
err_t usbcsink2_get_temperature (usbcsink2_t *ctx, uint8_t *temperature)
 USB-C Sink 2 get the temperature function.
 
err_t usbcsink2_write_rdo (usbcsink2_t *ctx, uint8_t *rdo)
 USB-C Sink 2 write the RDO function.
 
err_t usbcsink2_reset (usbcsink2_t *ctx)
 USB-C Sink 2 hard reset the RDO function.
 
uint8_t usbcsink2_get_interrupt (usbcsink2_t *ctx)
 USB-C Sink 2 get interrupt function.
 

Detailed Description

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

◆ usbcsink2_cfg_setup()

void usbcsink2_cfg_setup ( usbcsink2_cfg_t * cfg)

USB-C Sink 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ usbcsink2_default_cfg()

err_t usbcsink2_default_cfg ( usbcsink2_t * ctx)

USB-C Sink 2 default configuration function.

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

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

◆ usbcsink2_generic_read()

err_t usbcsink2_generic_read ( usbcsink2_t * ctx,
uint8_t cmd,
uint8_t * data_out,
uint8_t len )

USB-C Sink 2 data reading function.

This function reads a desired number of data bytes using desired command of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[in]cmd: Desired command.
[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.

◆ usbcsink2_generic_write()

err_t usbcsink2_generic_write ( usbcsink2_t * ctx,
uint8_t cmd,
uint8_t * data_in,
uint8_t len )

USB-C Sink 2 data writing function.

This function writes a desired number of data bytes starting using desired command of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[in]cmd: Desired command.
[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.

◆ usbcsink2_get_interrupt()

uint8_t usbcsink2_get_interrupt ( usbcsink2_t * ctx)

USB-C Sink 2 get interrupt function.

This function get states of the Interrupt ( INT ) pin of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

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

◆ usbcsink2_get_pdo_current()

err_t usbcsink2_get_pdo_current ( usbcsink2_t * ctx,
float * current_ma )

USB-C Sink 2 get the current function.

This function reads the PDO current measured of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

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

◆ usbcsink2_get_pdo_num()

err_t usbcsink2_get_pdo_num ( usbcsink2_t * ctx,
uint8_t * pdo_num )

USB-C Sink 2 PDO number reading function.

This function reads the total number of valid PDOs of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[out]pdo_num: Total number of valid PDOs.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink2_get_pdo_voltage()

err_t usbcsink2_get_pdo_voltage ( usbcsink2_t * ctx,
float * voltage_mv )

USB-C Sink 2 get the voltage function.

This function reads the PDO voltage measured of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

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

◆ usbcsink2_get_temperature()

err_t usbcsink2_get_temperature ( usbcsink2_t * ctx,
uint8_t * temperature )

USB-C Sink 2 get the temperature function.

This function reads the temperature of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[out]temperature: Temperature [degree Celsius].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink2_init()

err_t usbcsink2_init ( usbcsink2_t * ctx,
usbcsink2_cfg_t * cfg )

USB-C Sink 2 initialization function.

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

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

◆ usbcsink2_read_pdo()

err_t usbcsink2_read_pdo ( usbcsink2_t * ctx,
uint8_t * pdo )

USB-C Sink 2 PDO data reading function.

This function reads a source power delivery data of 28 bytes and used to expose PD Source (SRC) power capabilities of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[out]pdo: Source Power Data Object.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ usbcsink2_read_raw_adc()

err_t usbcsink2_read_raw_adc ( usbcsink2_t * ctx,
uint16_t * raw_adc )

USB-C Sink 2 read raw ADC value function.

This function reads raw ADC value.

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

◆ usbcsink2_read_status()

err_t usbcsink2_read_status ( usbcsink2_t * ctx,
uint8_t * status )

USB-C Sink 2 status reading function.

This function reads the status data to reports the Sink Controller’s of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

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

◆ usbcsink2_read_voltage()

err_t usbcsink2_read_voltage ( usbcsink2_t * ctx,
float * voltage )

USB-C Sink 2 read voltage level function.

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

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

◆ usbcsink2_reset()

err_t usbcsink2_reset ( usbcsink2_t * ctx)

USB-C Sink 2 hard reset the RDO function.

This function is used to reset by writing RDO register with all-zero data of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[out]rdo: Request Data Object.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The USB-C Sink 2 will be reset to its initial state and output will be turned off.

◆ usbcsink2_set_vref()

err_t usbcsink2_set_vref ( usbcsink2_t * ctx,
float vref )

USB-C Sink 2 set vref function.

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

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

◆ usbcsink2_wait_rdo_req_success()

err_t usbcsink2_wait_rdo_req_success ( usbcsink2_t * ctx)

USB-C Sink 2 wait RDO request function.

This function waith a successful RDO request of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

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

◆ usbcsink2_write_rdo()

err_t usbcsink2_write_rdo ( usbcsink2_t * ctx,
uint8_t * rdo )

USB-C Sink 2 write the RDO function.

This function PDO request negotiation procedure, 4-byte data is written to RDO (Request Data Object) of the AP33772, High-Performance USB PD Sink Controller on the USB-C Sink 2 click board™.

Parameters
[in]ctx: Click context object. See usbcsink2_t object definition for detailed explanation.
[out]rdo: Request Data Object.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.