usbcsink3 2.1.0.0
usbcsink3.h File Reference

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

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

Go to the source code of this file.

Data Structures

struct  usbcsink3_s
 USB-C Sink 3 Click context object. More...
 
struct  usbcsink3_cfg_t
 USB-C Sink 3 Click configuration object. More...
 

Macros

#define USBCSINK3_REG_INPUT_PORT   0x00
 USB-C Sink 3 description expander register.
 
#define USBCSINK3_REG_OUTPUT_PORT   0x01
 
#define USBCSINK3_REG_POLARITY_INV   0x02
 
#define USBCSINK3_REG_CONFIG   0x03
 
#define USBCSINK3_REG_SPECIAL_FUNC   0x50
 
#define USBCSINK3_CMD_SEL_NONE   0x00
 USB-C Sink 3 description digital POT command.
 
#define USBCSINK3_CMD_SEL_DATA_WRITE   0x10
 
#define USBCSINK3_CMD_SEL_SHUTDOWN   0x20
 
#define USBCSINK3_POT_SEL_DUMMY_CODE   0x00
 USB-C Sink 3 description digital POT selection.
 
#define USBCSINK3_POT_SEL_DIGI_POT_1   0x01
 
#define USBCSINK3_POT_SEL_DIGI_POT_2   0x02
 
#define USBCSINK3_POT_SEL_DIGI_POT_BOTH   0x03
 
#define USBCSINK3_NO_PIN_BIT_MASK   0x00
 USB-C Sink 3 expander pin bit mask values.
 
#define USBCSINK3_PIN_0_BIT_MASK   0x01
 
#define USBCSINK3_PIN_1_BIT_MASK   0x02
 
#define USBCSINK3_PIN_2_BIT_MASK   0x04
 
#define USBCSINK3_PIN_3_BIT_MASK   0x08
 
#define USBCSINK3_ALL_PINS_BIT_MASK   0xF0
 
#define USBCSINK3_DIRECTION_OUTPUT   0x00
 USB-C Sink 3 expander I/O pin direction values.
 
#define USBCSINK3_DIRECTION_INPUT   0x01
 
#define USBCSINK3_VSEL0_DISABLE   0x00
 RS Transceiver expander VSEL pin direction values.
 
#define USBCSINK3_VSEL0_ENABLE   0x01
 
#define USBCSINK3_VSEL0_PIN_BIT_MASK   0x0E
 
#define USBCSINK3_VSEL1_DISABLE   0x00
 
#define USBCSINK3_VSEL1_ENABLE   0x02
 
#define USBCSINK3_VSEL1_PIN_BIT_MASK   0x0D
 
#define USBCSINK3_VSEL2_DISABLE   0x00
 
#define USBCSINK3_VSEL2_ENABLE   0x04
 
#define USBCSINK3_VSEL2_PIN_BIT_MASK   0x0B
 
#define USBCSINK3_SPEC_FUNC_P3_AS_INT   0x80
 USB-C Sink 3 expander special function values.
 
#define USBCSINK3_SPEC_FUNC_PU_DISABLED   0x40
 
#define USBCSINK3_VBUS_VTG_0V   0.0f
 USB-C Sink 3 VBUS voltage values.
 
#define USBCSINK3_VBUS_VTG_5V   5.0f
 
#define USBCSINK3_VBUS_VTG_9V   9.0f
 
#define USBCSINK3_VBUS_VTG_15V   15.0f
 
#define USBCSINK3_VBUS_VTG_20V   20.3f
 
#define USBCSINK3_VBUS_VTG_4_3V   4.3f
 
#define USBCSINK3_VBUS_VTG_8_6V   8.6f
 
#define USBCSINK3_VBUS_VTG_12_9V   12.9f
 
#define USBCSINK3_VBUS_VTG_17_2V   17.2f
 
#define USBCSINK3_WIPER_POS_MAX   255
 USB-C Sink 3 wiper and resistance data values.
 
#define USBCSINK3_RES_6_8_KOHM   6.8f
 
#define USBCSINK3_RES_16_KOHM   16.0f
 
#define USBCSINK3_RES_27_KOHM   27.0f
 
#define USBCSINK3_RES_36_KOHM   36.0f
 
#define USBCSINK3_RES_45_3_KOHM   45.3f
 
#define USBCSINK3_RES_56_KOHM   56.0f
 
#define USBCSINK3_RES_64_9_KOHM   64.9f
 
#define USBCSINK3_RES_75_KOHM   75.0f
 
#define USBCSINK3_RES_82_KOHM   82.0f
 
#define USBCSINK3_RES_91_KOHM   91.0f
 
#define USBCSINK3_RES_100_KOHM   100.0f
 
#define USBCSINK3_VBUS_R11_RES_73_2_KOHM   73.2f
 
#define USBCSINK3_VBUS_R13_RES_10_KOHM   10.0f
 
#define USBCSINK3_ADC_RESOLUTION   0x0FFF
 USB-C Sink 3 ADC setting.
 
#define USBCSINK3_VREF_3V3   3.3
 
#define USBCSINK3_VREF_5V   5.0
 
#define USBCSINK3_DEVICE_ADDRESS   0x41
 USB-C Sink 3 device address setting.
 
#define USBCSINK3_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define USBCSINK3_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define USBCSINK3_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Typedefs

typedef struct usbcsink3_s usbcsink3_t
 USB-C Sink 3 Click context object.
 

Enumerations

enum  usbcsink3_return_value_t { USBCSINK3_OK = 0 , USBCSINK3_ERROR = -1 }
 USB-C Sink 3 Click return value data. More...
 
enum  usbcsink3_vtg_sel_t {
  USBCSINK3_VTG_SEL_5V = 0 , USBCSINK3_VTG_SEL_9V , USBCSINK3_VTG_SEL_15V , USBCSINK3_VTG_SEL_20V ,
  USBCSINK3_VTG_SEL_4_3V , USBCSINK3_VTG_SEL_8_6V , USBCSINK3_VTG_SEL_12_9V , USBCSINK3_VTG_SEL_17_2V
}
 USB-C Sink 3 Click voltage selection value data. More...
 
enum  usbcsink3_pwr_sel_t {
  USBCSINK3_PWR_SEL_12W = 0 , USBCSINK3_PWR_SEL_15W , USBCSINK3_PWR_SEL_18W , USBCSINK3_PWR_SEL_20W ,
  USBCSINK3_PWR_SEL_27W , USBCSINK3_PWR_SEL_36W , USBCSINK3_PWR_SEL_45W , USBCSINK3_PWR_SEL_60W ,
  USBCSINK3_PWR_SEL_90W , USBCSINK3_PWR_SEL_100W
}
 USB-C Sink 3 Click power selection value data. More...
 

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

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

Typedef Documentation

◆ usbcsink3_t

typedef struct usbcsink3_s usbcsink3_t

USB-C Sink 3 Click context object.

Context object definition of USB-C Sink 3 Click driver.

Enumeration Type Documentation

◆ usbcsink3_pwr_sel_t

USB-C Sink 3 Click power selection value data.

Predefined enum values for driver power selection values.

Enumerator
USBCSINK3_PWR_SEL_12W 
USBCSINK3_PWR_SEL_15W 
USBCSINK3_PWR_SEL_18W 
USBCSINK3_PWR_SEL_20W 
USBCSINK3_PWR_SEL_27W 
USBCSINK3_PWR_SEL_36W 
USBCSINK3_PWR_SEL_45W 
USBCSINK3_PWR_SEL_60W 
USBCSINK3_PWR_SEL_90W 
USBCSINK3_PWR_SEL_100W 

◆ usbcsink3_return_value_t

USB-C Sink 3 Click return value data.

Predefined enum values for driver return values.

Enumerator
USBCSINK3_OK 
USBCSINK3_ERROR 

◆ usbcsink3_vtg_sel_t

USB-C Sink 3 Click voltage selection value data.

Predefined enum values for driver voltage selection values.

Enumerator
USBCSINK3_VTG_SEL_5V 
USBCSINK3_VTG_SEL_9V 
USBCSINK3_VTG_SEL_15V 
USBCSINK3_VTG_SEL_20V 
USBCSINK3_VTG_SEL_4_3V 
USBCSINK3_VTG_SEL_8_6V 
USBCSINK3_VTG_SEL_12_9V 
USBCSINK3_VTG_SEL_17_2V