usbcsource 2.0.0.0
usbcsource.h File Reference

This file contains API for USB-C Source 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  usbcsource_t
 USB-C Source Click context object. More...
 
struct  usbcsource_cfg_t
 USB-C Source Click configuration object. More...
 
struct  alert_status_t
 USB-C Source Click alert status object. More...
 
struct  port_status_t
 USB-C Source Click port status object. More...
 
struct  monitor_status_t
 USB-C Source Click monitor status object. More...
 
struct  connection_status_t
 USB-C Source Click connection status object. More...
 
struct  fault_status_t
 USB-C Source Click fault status object. More...
 
struct  pdo_config_t
 USB-C Source Click PDO config object. More...
 

Macros

#define USBCSOURCE_REG_ALERT_STATUS_REG   0x0B
 USB-C Source description register.
 
#define USBCSOURCE_REG_ALERT_STATUS_MASK_CTRL   0x0C
 
#define USBCSOURCE_REG_CC_CONNECTION_STATUS_TRANS   0x0D
 
#define USBCSOURCE_REG_CC_CONNECTION_STATUS_1   0x0E
 
#define USBCSOURCE_REG_MONITORING_STATUS_TRANS   0x0F
 
#define USBCSOURCE_REG_MONITORING_STATUS   0x10
 
#define USBCSOURCE_REG_CC_CONNECTION_STATUS_2   0x11
 
#define USBCSOURCE_REG_HW_FAULT_STATUS_TRANS   0x12
 
#define USBCSOURCE_REG_HW_FAULT_STATUS   0x13
 
#define USBCSOURCE_REG_CC_CAPABILITY_CTRL   0x18
 
#define USBCSOURCE_REG_RESET_CTRL   0x23
 
#define USBCSOURCE_REG_VBUS_DISCHARGE_TIME_CTRL   0x25
 
#define USBCSOURCE_REG_VBUS_DISCHARGE_STATUS   0x26
 
#define USBCSOURCE_REG_VBUS_ENABLE_STATUS   0x27
 
#define USBCSOURCE_REG_VBUS_MONITORING_CTRL   0x2E
 
#define USBCSOURCE_REG_SRC_PDO1   0x71
 
#define USBCSOURCE_REG_SRC_PDO2   0x75
 
#define USBCSOURCE_REG_SRC_PDO3   0x79
 
#define USBCSOURCE_REG_SRC_PDO4   0x7D
 
#define USBCSOURCE_REG_SRC_PDO5   0x81
 
#define USBCSOURCE_SEL_PDO1   0x01
 USB-C Source description setting.
 
#define USBCSOURCE_SEL_PDO2   0x02
 
#define USBCSOURCE_SEL_PDO3   0x03
 
#define USBCSOURCE_SEL_PDO4   0x04
 
#define USBCSOURCE_SEL_PDO5   0x05
 
#define USBCSOURCE_PDO_NVM_VOLT_CFG_9_V   0x00
 USB-C PDO NVM voltage configuration.
 
#define USBCSOURCE_PDO_NVM_VOLT_CFG_15_V   0x01
 
#define USBCSOURCE_PDO_NVM_VOLT_CFG_FLEX_V1   0x02
 
#define USBCSOURCE_PDO_NVM_VOLT_CFG_FLEX_V2   0x03
 
#define USBCSOURCE_PDO_NVM_CUR_FLEX_I   0x00
 USB-C PDO NVM current configuration.
 
#define USBCSOURCE_PDO_NVM_CUR_1_50_A   0x01
 
#define USBCSOURCE_PDO_NVM_CUR_1_75_A   0x02
 
#define USBCSOURCE_PDO_NVM_CUR_2_00_A   0x03
 
#define USBCSOURCE_PDO_NVM_CUR_2_25_A   0x04
 
#define USBCSOURCE_PDO_NVM_CUR_2_50_A   0x05
 
#define USBCSOURCE_PDO_NVM_CUR_2_75_A   0x06
 
#define USBCSOURCE_PDO_NVM_CUR_3_00_A   0x07
 
#define USBCSOURCE_PDO_NVM_CUR_3_25_A   0x08
 
#define USBCSOURCE_PDO_NVM_CUR_3_50_A   0x09
 
#define USBCSOURCE_PDO_NVM_CUR_3_75_A   0x0A
 
#define USBCSOURCE_PDO_NVM_CUR_4_00_A   0x0B
 
#define USBCSOURCE_PDO_NVM_CUR_4_25_A   0x0C
 
#define USBCSOURCE_PDO_NVM_CUR_4_50_A   0x0D
 
#define USBCSOURCE_PDO_NVM_CUR_4_75_A   0x0E
 
#define USBCSOURCE_PDO_NVM_CUR_5_00_A   0x0F
 
#define USBCSOURCE_RESET_DIS   0x00
 USB-C software reset.
 
#define USBCSOURCE_RESET_EN   0x01
 
#define USBCSOURCE_ALERT_STAT_HARD_RESET_AL   0x80
 USB-C alert state.
 
#define USBCSOURCE_ALERT_STAT_PORT_STAT_AL   0x40
 
#define USBCSOURCE_ALERT_STAT_TYPEC_MON_AL   0x20
 
#define USBCSOURCE_ALERT_STAT_CC_HW_FAULT_AL   0x10
 
#define USBCSOURCE_ALERT_STAT_DPM_STAT_AL   0x08
 
#define USBCSOURCE_ALERT_STAT_PE_STAT_AL   0x04
 
#define USBCSOURCE_ALERT_STAT_PRT_STAT_AL   0x02
 
#define USBCSOURCE_ALERT_STAT_PHY_STAT_AL   0x01
 
#define USBCSOURCE_ATTACHED_DEVICE_NONE_ATT   0x00
 USB-C attached device.
 
#define USBCSOURCE_ATTACHED_DEVICE_SNK_ATT   0x01
 
#define USBCSOURCE_ATTACHED_DEVICE_SRC_ATT   0x02
 
#define USBCSOURCE_ATTACHED_DEVICE_DBG_ATT   0x03
 
#define USBCSOURCE_ATTACHED_DEVICE_AUD_ATT   0x04
 
#define USBCSOURCE_ATTACHED_DEVICE_POW_ACC_ATT   0x05
 
#define USBCSOURCE_LOW_POWER_STANDBY_OFF   0x00
 USB-C low power standby.
 
#define USBCSOURCE_LOW_POWER_STANDBY_ON   0x01
 
#define USBCSOURCE_POWER_MODE_SNK   0x00
 USB-C power mode.
 
#define USBCSOURCE_POWER_MODE_SRC   0x01
 
#define USBCSOURCE_DATA_MODE_UFP   0x00
 USB-C data mode.
 
#define USBCSOURCE_DATA_MODE_DFP   0x01
 
#define USBCSOURCE_CONN_UNATTACHED   0x00
 USB-C connection attach.
 
#define USBCSOURCE_CONN_ATTACHED   0x01
 
#define USBCSOURCE_VBUS_READY_DISCONNECTED   0x00
 USB-C VBUS settings.
 
#define USBCSOURCE_VBUS_READY_CONNECTED   0x01
 
#define USBCSOURCE_VBUS_VSAFE0V_0_8V_HIGHER   0x00
 
#define USBCSOURCE_VBUS_VSAFE0V_0_8V_LOWER   0x01
 
#define USBCSOURCE_VBUS_VALID_3_9V_LOWER   0x00
 
#define USBCSOURCE_VBUS_VALID_3_9V_HIGHER   0x01
 
#define USBCSOURCE_STATUS_ERROR   0x00
 USB-C status.
 
#define USBCSOURCE_STATUS_SUCCESS   0x01
 
#define USBCSOURCE_I2C_SLAVE_ADR_GND   0x28
 USB-C Source device address setting.
 
#define USBCSOURCE_I2C_SLAVE_ADR_VCC   0x29
 
#define USBCSOURCE_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  usbcsource_return_value_t { USBCSOURCE_OK = 0 , USBCSOURCE_ERROR = -1 }
 USB-C Source Click return value data. More...
 

Functions

void usbcsource_cfg_setup (usbcsource_cfg_t *cfg)
 USB-C Source configuration object setup function.
 
err_t usbcsource_init (usbcsource_t *ctx, usbcsource_cfg_t *cfg)
 USB-C Source initialization function.
 
err_t usbcsource_generic_write (usbcsource_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 USB-C Source I2C writing function.
 
err_t usbcsource_generic_read (usbcsource_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 USB-C Source I2C reading function.
 
void usbcsource_write_byte (usbcsource_t *ctx, uint8_t reg, uint8_t tx_data)
 Generic write function.
 
uint8_t usbcsource_read_byte (usbcsource_t *ctx, uint8_t reg)
 Generic read function.
 
void usbcsource_hw_reset (usbcsource_t *ctx)
 HW reset function.
 
uint8_t usbcsource_int_pin_state (usbcsource_t *ctx)
 Get INT pin state function.
 
void usbcsource_get_alert_status (usbcsource_t *ctx, alert_status_t *alert_status_data)
 Get alert status function.
 
void usbcsource_set_alert_status (usbcsource_t *ctx, alert_status_t alert_status_data)
 Set alert status function.
 
uint8_t usbcsource_check_attach_trans (usbcsource_t *ctx)
 Check attach trans function.
 
void usbcsource_get_port_status (usbcsource_t *ctx, port_status_t *port_status_data)
 Get port status function.
 
void usbcsource_get_monitoring_status (usbcsource_t *ctx, monitor_status_t *monitor_status_data)
 Get monitoring status function.
 
void usbcsource_get_connection_status (usbcsource_t *ctx, connection_status_t *conn_data)
 Get connection status function.
 
void usbcsource_get_fault_status (usbcsource_t *ctx, fault_status_t *fault_data)
 Get fault status function.
 
void usbcsource_sw_reset (usbcsource_t *ctx)
 SW reset function.
 
uint8_t usbcsource_set_pdo_config (usbcsource_t *ctx, pdo_config_t pdo_cfg_data)
 Set PDO configuration function.
 
uint8_t usbcsource_get_pdo_config (usbcsource_t *ctx, uint8_t pdo_numb, pdo_config_t *pdo_cfg_data)
 Get PDO configuration function.
 
void usbcsource_default_config (usbcsource_t *ctx)
 Default configuration function.
 

Detailed Description

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

Enumeration Type Documentation

◆ usbcsource_return_value_t

USB-C Source Click return value data.

Predefined enum values for driver return values.

Enumerator
USBCSOURCE_OK 
USBCSOURCE_ERROR