usbcsink2 2.1.0.0
usbcsink2.h File Reference

This file contains API for USB-C Sink 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_analog_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  usbcsink2_t
 USB-C Sink 2 Click context object. More...
 
struct  usbcsink2_cfg_t
 USB-C Sink 2 Click configuration object. More...
 

Macros

#define USBCSINK2_CMD_SRCPDO   0x00
 USB-C Sink 2 description register.
 
#define USBCSINK2_CMD_PDONUM   0x1C
 
#define USBCSINK2_CMD_STATUS   0x1D
 
#define USBCSINK2_CMD_MASK   0x1E
 
#define USBCSINK2_CMD_VOLTAGE   0x20
 
#define USBCSINK2_CMD_CURRENT   0x21
 
#define USBCSINK2_CMD_TEMP   0x22
 
#define USBCSINK2_CMD_OCPTHR   0x23
 
#define USBCSINK2_CMD_OTPTHR   0x24
 
#define USBCSINK2_CMD_DRTHR   0x25
 
#define USBCSINK2_CMD_TR25   0x28
 
#define USBCSINK2_CMD_TR50   0x2A
 
#define USBCSINK2_CMD_TR75   0x2C
 
#define USBCSINK2_CMD_TR100   0x2E
 
#define USBCSINK2_CMD_RDO   0x30
 
#define USBCSINK2_SRCPDO_LENGTH   28
 USB-C Sink 2 PDO and RDO length data values.
 
#define USBCSINK2_RDO_LENGTH   4
 
#define USBCSINK2_RDO_REQ_SUCCESS   0x03
 USB-C Sink 2 status successful RDO request data value.
 
#define USBCSINK2_SENS_VTG_MV   80.0f
 USB-C Sink 2 voltage and current measured calculation data values.
 
#define USBCSINK2_SENS_CURRENT_MA   24.0f
 
#define USBCSINK2_ADC_RESOLUTION   0x0FFF
 USB-C Sink 2 ADC setting.
 
#define USBCSINK2_VREF_3V3   3.3
 
#define USBCSINK2_VREF_5V   5.0
 
#define USBCSINK2_SET_DEV_ADDR   0x51
 USB-C Sink 2 device address setting.
 
#define USBCSINK2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  usbcsink2_return_value_t { USBCSINK2_OK = 0 , USBCSINK2_ERROR = -1 }
 USB-C Sink 2 Click return value data. More...
 

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

This file contains API for USB-C Sink 2 Click Driver.

Enumeration Type Documentation

◆ usbcsink2_return_value_t

USB-C Sink 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
USBCSINK2_OK 
USBCSINK2_ERROR