usbcsink 2.0.0.0
usbcsink.h File Reference

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

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

Go to the source code of this file.

Data Structures

struct  usbcsink_t
 USB-C Sink Click context object. More...
 
struct  usbcsink_cfg_t
 USB-C Sink Click configuration object. More...
 

Macros

#define USBCSINK_REG_BCD_TYPEC_REV_LOW   0x06
 USB-C Sink description register.
 
#define USBCSINK_REG_BCD_TYPEC_REV_HIGH   0x07
 
#define USBCSINK_REG_BCD_USBPD_REV_LOW   0x08
 
#define USBCSINK_REG_BCD_USBPD_REV_HIGH   0x09
 
#define USBCSINK_REG_DEVICE_CAPAB_HIGH   0x0A
 
#define USBCSINK_REG_ALERT_STAT_1   0x0B
 
#define USBCSINK_REG_ALERT_STAT_1_MASK   0x0C
 
#define USBCSINK_REG_PORT_STAT_0   0x0D
 
#define USBCSINK_REG_PORT_STAT_1   0x0E
 
#define USBCSINK_REG_TYPEC_MON_STAT_0   0x0F
 
#define USBCSINK_REG_TYPEC_MON_STAT_1   0x10
 
#define USBCSINK_REG_CC_STAT   0x11
 
#define USBCSINK_REG_CC_HW_FAULT_STAT_0   0x12
 
#define USBCSINK_REG_CC_HW_FAULT_STAT_1   0x13
 
#define USBCSINK_REG_PD_TYPEC_STAT   0x14
 
#define USBCSINK_REG_TYPEC_STAT   0x15
 
#define USBCSINK_REG_PRT_STAT   0x16
 
#define USBCSINK_REG_PD_CMD_CTL   0x1A
 
#define USBCSINK_REG_MON_CTL_0   0x20
 
#define USBCSINK_REG_MON_CTL_2   0x22
 
#define USBCSINK_REG_RESET_CTL   0x23
 
#define USBCSINK_REG_VBUS_DISCH_TIME_CTL   0x25
 
#define USBCSINK_REG_VBUS_DISCH_CTL   0x26
 
#define USBCSINK_REG_VBUS_CTL   0x27
 
#define USBCSINK_REG_GPIO3_SW_GPIO   0x2D
 
#define USBCSINK_REG_DEV_ID   0x2F
 
#define USBCSINK_REG_RX_HEADER_LOW   0x31
 
#define USBCSINK_REG_RX_HEADER_HIGH   0x32
 
#define USBCSINK_REG_RX_DATA_OBJ1_0   0x33
 
#define USBCSINK_REG_RX_DATA_OBJ1_1   0x34
 
#define USBCSINK_REG_RX_DATA_OBJ1_2   0x35
 
#define USBCSINK_REG_RX_DATA_OBJ1_3   0x36
 
#define USBCSINK_REG_RX_DATA_OBJ2_0   0x37
 
#define USBCSINK_REG_RX_DATA_OBJ2_1   0x38
 
#define USBCSINK_REG_RX_DATA_OBJ2_2   0x39
 
#define USBCSINK_REG_RX_DATA_OBJ2_3   0x3A
 
#define USBCSINK_REG_RX_DATA_OBJ3_0   0x3B
 
#define USBCSINK_REG_RX_DATA_OBJ3_1   0x3C
 
#define USBCSINK_REG_RX_DATA_OBJ3_2   0x3D
 
#define USBCSINK_REG_RX_DATA_OBJ3_3   0x3E
 
#define USBCSINK_REG_RX_DATA_OBJ4_0   0x3F
 
#define USBCSINK_REG_RX_DATA_OBJ4_1   0x40
 
#define USBCSINK_REG_RX_DATA_OBJ4_2   0x41
 
#define USBCSINK_REG_RX_DATA_OBJ4_3   0x42
 
#define USBCSINK_REG_RX_DATA_OBJ5_0   0x43
 
#define USBCSINK_REG_RX_DATA_OBJ5_1   0x44
 
#define USBCSINK_REG_RX_DATA_OBJ5_2   0x45
 
#define USBCSINK_REG_RX_DATA_OBJ5_3   0x46
 
#define USBCSINK_REG_RX_DATA_OBJ6_0   0x47
 
#define USBCSINK_REG_RX_DATA_OBJ6_1   0x48
 
#define USBCSINK_REG_RX_DATA_OBJ6_2   0x49
 
#define USBCSINK_REG_RX_DATA_OBJ6_3   0x4A
 
#define USBCSINK_REG_RX_DATA_OBJ7_0   0x4B
 
#define USBCSINK_REG_RX_DATA_OBJ7_1   0x4C
 
#define USBCSINK_REG_RX_DATA_OBJ7_2   0x4D
 
#define USBCSINK_REG_RX_DATA_OBJ7_3   0x4E
 
#define USBCSINK_REG_TX_HEADER_LOW   0x51
 
#define USBCSINK_REG_TX_HEADER_HIGH   0x52
 
#define USBCSINK_REG_DPM_PDO_NUMB   0x70
 
#define USBCSINK_REG_DPM_SNK_PDO1_0   0x85
 
#define USBCSINK_REG_DPM_SNK_PDO1_1   0x86
 
#define USBCSINK_REG_DPM_SNK_PDO1_2   0x87
 
#define USBCSINK_REG_DPM_SNK_PDO1_3   0x88
 
#define USBCSINK_REG_DPM_SNK_PDO2_0   0x89
 
#define USBCSINK_REG_DPM_SNK_PDO2_1   0x8A
 
#define USBCSINK_REG_DPM_SNK_PDO2_2   0x8B
 
#define USBCSINK_REG_DPM_SNK_PDO2_3   0x8C
 
#define USBCSINK_REG_DPM_SNK_PDO3_0   0x8D
 
#define USBCSINK_REG_DPM_SNK_PDO3_1   0x8E
 
#define USBCSINK_REG_DPM_SNK_PDO3_2   0x8F
 
#define USBCSINK_REG_DPM_SNK_PDO3_3   0x90
 
#define USBCSINK_REG_DPM_REQ_RDO3_0   0x91
 
#define USBCSINK_REG_DPM_REQ_RDO3_1   0x92
 
#define USBCSINK_REG_DPM_REQ_RDO3_2   0x93
 
#define USBCSINK_REG_DPM_REQ_RDO3_3   0x94
 
#define USBCSINK_REG_DEF   0xFF
 
#define USBCSINK_REG_FTP_CUST_PWD_REG   0x95
 
#define USBCSINK_REG_FTP_CTL_0   0x96
 
#define USBCSINK_REG_FTP_CTL_1   0x97
 
#define USBCSINK_REG_RW_BUF   0x53
 
#define USBCSINK_FTP_CUST_PWR   0x80
 
#define USBCSINK_FTP_CUST_RST_N   0x40
 
#define USBCSINK_FTP_CUST_REQ   0x10
 
#define USBCSINK_FTP_CUST_SECT   0x07
 
#define USBCSINK_FTP_CUST_SER   0xF8
 
#define USBCSINK_FTP_CUST_OPCODE   0x07
 
#define USBCSINK_SEC_0   0x01
 
#define USBCSINK_SEC_1   0x02
 
#define USBCSINK_SEC_2   0x04
 
#define USBCSINK_SEC_3   0x08
 
#define USBCSINK_SEC_4   0x10
 
#define USBCSINK_FTP_CUST_PWD   0x47
 USB-C Sink description setting.
 
#define USBCSINK_SW_RESET_ON   0x01
 USB-C Sink software reset.
 
#define USBCSINK_SW_RESET_OFF   0x00
 
#define USBCSINK_READ   0x00
 USB-C Sink sector commands.
 
#define USBCSINK_WRITE_PL   0x01
 
#define USBCSINK_WRITE_SER   0x02
 
#define USBCSINK_ERASE_SEC   0x05
 
#define USBCSINK_PROG_SEC   0x06
 
#define USBCSINK_SOFT_PROG_SEC   0x07
 
#define USBCSINK_SET_PDO_1   0x01
 USB-C Sink PDO select.
 
#define USBCSINK_SET_PDO_2   0x02
 
#define USBCSINK_SET_PDO_3   0x03
 
#define USBCSINK_UPLOAD_NEW_DATA_VAL   0x00
 
#define USBCSINK_UPLOAD_DEFAULT   0x01
 
#define USBCSINK_SLAVE_ADR_0   0x28
 USB-C Sink device address setting.
 
#define USBCSINK_SLAVE_ADR_1   0x29
 
#define USBCSINK_SLAVE_ADR_2   0x2A
 
#define USBCSINK_SLAVE_ADR_3   0x2B
 
#define USBCSINK_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  usbcsink_return_value_t { USBCSINK_OK = 0 , USBCSINK_ERROR = -1 }
 USB-C Sink Click return value data. More...
 

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

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

Enumeration Type Documentation

◆ usbcsink_return_value_t

USB-C Sink Click return value data.

Predefined enum values for driver return values.

Enumerator
USBCSINK_OK 
USBCSINK_ERROR