Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define USBCSOURCE_REG_ALERT_STATUS_REG 0x0B
70 #define USBCSOURCE_REG_ALERT_STATUS_MASK_CTRL 0x0C
71 #define USBCSOURCE_REG_CC_CONNECTION_STATUS_TRANS 0x0D
72 #define USBCSOURCE_REG_CC_CONNECTION_STATUS_1 0x0E
73 #define USBCSOURCE_REG_MONITORING_STATUS_TRANS 0x0F
74 #define USBCSOURCE_REG_MONITORING_STATUS 0x10
75 #define USBCSOURCE_REG_CC_CONNECTION_STATUS_2 0x11
76 #define USBCSOURCE_REG_HW_FAULT_STATUS_TRANS 0x12
77 #define USBCSOURCE_REG_HW_FAULT_STATUS 0x13
78 #define USBCSOURCE_REG_CC_CAPABILITY_CTRL 0x18
79 #define USBCSOURCE_REG_RESET_CTRL 0x23
80 #define USBCSOURCE_REG_VBUS_DISCHARGE_TIME_CTRL 0x25
81 #define USBCSOURCE_REG_VBUS_DISCHARGE_STATUS 0x26
82 #define USBCSOURCE_REG_VBUS_ENABLE_STATUS 0x27
83 #define USBCSOURCE_REG_VBUS_MONITORING_CTRL 0x2E
85 #define USBCSOURCE_REG_SRC_PDO1 0x71
86 #define USBCSOURCE_REG_SRC_PDO2 0x75
87 #define USBCSOURCE_REG_SRC_PDO3 0x79
88 #define USBCSOURCE_REG_SRC_PDO4 0x7D
89 #define USBCSOURCE_REG_SRC_PDO5 0x81
112 #define USBCSOURCE_SEL_PDO1 0x01
113 #define USBCSOURCE_SEL_PDO2 0x02
114 #define USBCSOURCE_SEL_PDO3 0x03
115 #define USBCSOURCE_SEL_PDO4 0x04
116 #define USBCSOURCE_SEL_PDO5 0x05
122 #define USBCSOURCE_PDO_NVM_VOLT_CFG_9_V 0x00
123 #define USBCSOURCE_PDO_NVM_VOLT_CFG_15_V 0x01
124 #define USBCSOURCE_PDO_NVM_VOLT_CFG_FLEX_V1 0x02
125 #define USBCSOURCE_PDO_NVM_VOLT_CFG_FLEX_V2 0x03
131 #define USBCSOURCE_PDO_NVM_CUR_FLEX_I 0x00
132 #define USBCSOURCE_PDO_NVM_CUR_1_50_A 0x01
133 #define USBCSOURCE_PDO_NVM_CUR_1_75_A 0x02
134 #define USBCSOURCE_PDO_NVM_CUR_2_00_A 0x03
135 #define USBCSOURCE_PDO_NVM_CUR_2_25_A 0x04
136 #define USBCSOURCE_PDO_NVM_CUR_2_50_A 0x05
137 #define USBCSOURCE_PDO_NVM_CUR_2_75_A 0x06
138 #define USBCSOURCE_PDO_NVM_CUR_3_00_A 0x07
139 #define USBCSOURCE_PDO_NVM_CUR_3_25_A 0x08
140 #define USBCSOURCE_PDO_NVM_CUR_3_50_A 0x09
141 #define USBCSOURCE_PDO_NVM_CUR_3_75_A 0x0A
142 #define USBCSOURCE_PDO_NVM_CUR_4_00_A 0x0B
143 #define USBCSOURCE_PDO_NVM_CUR_4_25_A 0x0C
144 #define USBCSOURCE_PDO_NVM_CUR_4_50_A 0x0D
145 #define USBCSOURCE_PDO_NVM_CUR_4_75_A 0x0E
146 #define USBCSOURCE_PDO_NVM_CUR_5_00_A 0x0F
152 #define USBCSOURCE_RESET_DIS 0x00
153 #define USBCSOURCE_RESET_EN 0x01
159 #define USBCSOURCE_ALERT_STAT_HARD_RESET_AL 0x80
160 #define USBCSOURCE_ALERT_STAT_PORT_STAT_AL 0x40
161 #define USBCSOURCE_ALERT_STAT_TYPEC_MON_AL 0x20
162 #define USBCSOURCE_ALERT_STAT_CC_HW_FAULT_AL 0x10
163 #define USBCSOURCE_ALERT_STAT_DPM_STAT_AL 0x08
164 #define USBCSOURCE_ALERT_STAT_PE_STAT_AL 0x04
165 #define USBCSOURCE_ALERT_STAT_PRT_STAT_AL 0x02
166 #define USBCSOURCE_ALERT_STAT_PHY_STAT_AL 0x01
172 #define USBCSOURCE_ATTACHED_DEVICE_NONE_ATT 0x00
173 #define USBCSOURCE_ATTACHED_DEVICE_SNK_ATT 0x01
174 #define USBCSOURCE_ATTACHED_DEVICE_SRC_ATT 0x02
175 #define USBCSOURCE_ATTACHED_DEVICE_DBG_ATT 0x03
176 #define USBCSOURCE_ATTACHED_DEVICE_AUD_ATT 0x04
177 #define USBCSOURCE_ATTACHED_DEVICE_POW_ACC_ATT 0x05
183 #define USBCSOURCE_LOW_POWER_STANDBY_OFF 0x00
184 #define USBCSOURCE_LOW_POWER_STANDBY_ON 0x01
190 #define USBCSOURCE_POWER_MODE_SNK 0x00
191 #define USBCSOURCE_POWER_MODE_SRC 0x01
197 #define USBCSOURCE_DATA_MODE_UFP 0x00
198 #define USBCSOURCE_DATA_MODE_DFP 0x01
204 #define USBCSOURCE_CONN_UNATTACHED 0x00
205 #define USBCSOURCE_CONN_ATTACHED 0x01
211 #define USBCSOURCE_VBUS_READY_DISCONNECTED 0x00
212 #define USBCSOURCE_VBUS_READY_CONNECTED 0x01
214 #define USBCSOURCE_VBUS_VSAFE0V_0_8V_HIGHER 0x00
215 #define USBCSOURCE_VBUS_VSAFE0V_0_8V_LOWER 0x01
217 #define USBCSOURCE_VBUS_VALID_3_9V_LOWER 0x00
218 #define USBCSOURCE_VBUS_VALID_3_9V_HIGHER 0x01
224 #define USBCSOURCE_STATUS_ERROR 0x00
225 #define USBCSOURCE_STATUS_SUCCESS 0x01
232 #define USBCSOURCE_I2C_SLAVE_ADR_GND 0x28
233 #define USBCSOURCE_I2C_SLAVE_ADR_VCC 0x29
251 #define USBCSOURCE_MAP_MIKROBUS( cfg, mikrobus ) \
252 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
253 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
254 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
255 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
676 #endif // USBCSOURCE_H
uint8_t vconn_sw_ocp_fault_cc1
Definition: usbcsource.h:365
void usbcsource_default_config(usbcsource_t *ctx)
Default configuration function.
uint8_t vconn_valid
Definition: usbcsource.h:335
void usbcsource_get_port_status(usbcsource_t *ctx, port_status_t *port_status_data)
Get port status function.
USB-C Source Click context object.
Definition: usbcsource.h:265
uint8_t attached_device
Definition: usbcsource.h:317
digital_in_t int_pin
Definition: usbcsource.h:270
uint8_t vbus_vsafe0v
Definition: usbcsource.h:333
uint8_t vconn_sw_ovp_fault_trans
Definition: usbcsource.h:360
uint8_t unch_exd_mesg_support
Definition: usbcsource.h:384
uint8_t snk_power_level
Definition: usbcsource.h:345
uint8_t port_status_al
Definition: usbcsource.h:304
uint8_t pd_typec_hand_check
Definition: usbcsource.h:331
uint8_t typec_fsm_state
Definition: usbcsource.h:346
uint8_t vconn_sw_ovp_fault_cc1
Definition: usbcsource.h:367
uint8_t phy_status_al
Definition: usbcsource.h:308
float vtg_data
Definition: usbcsource.h:386
USB-C Source Click fault status object.
Definition: usbcsource.h:354
uint8_t vconn_sw_ovp_fault_cc2
Definition: usbcsource.h:368
uint8_t low_power_standby
Definition: usbcsource.h:318
void usbcsource_hw_reset(usbcsource_t *ctx)
HW reset function.
uint8_t peak_current
Definition: usbcsource.h:385
uint8_t vconn_sw_rvp_fault_cc1
Definition: usbcsource.h:363
err_t usbcsource_init(usbcsource_t *ctx, usbcsource_cfg_t *cfg)
USB-C Source initialization function.
pin_name_t int_pin
Definition: usbcsource.h:290
uint8_t power_mode
Definition: usbcsource.h:319
void usbcsource_write_byte(usbcsource_t *ctx, uint8_t reg, uint8_t tx_data)
Generic write function.
uint8_t vbus_valid
Definition: usbcsource.h:334
uint8_t usb_commun_capable
Definition: usbcsource.h:382
uint8_t vpu_valid_trans
Definition: usbcsource.h:357
uint8_t pdo_number
Definition: usbcsource.h:377
uint8_t typec_monitoring_status_al
Definition: usbcsource.h:305
uint8_t vconn_sw_ocp_fault_trans
Definition: usbcsource.h:359
uint8_t vpu_valid
Definition: usbcsource.h:362
uint8_t attach
Definition: usbcsource.h:322
USB-C Source Click monitor status object.
Definition: usbcsource.h:330
USB-C Source Click alert status object.
Definition: usbcsource.h:302
pin_name_t rst
Definition: usbcsource.h:289
void usbcsource_sw_reset(usbcsource_t *ctx)
SW reset function.
uint8_t vbus_ready
Definition: usbcsource.h:332
uint8_t data_mode
Definition: usbcsource.h:320
float curr_data
Definition: usbcsource.h:387
USB-C Source Click port status object.
Definition: usbcsource.h:316
uint8_t usbcsource_check_attach_trans(usbcsource_t *ctx)
Check attach trans function.
uint8_t prt_status_al
Definition: usbcsource.h:307
@ USBCSOURCE_ERROR
Definition: usbcsource.h:397
uint8_t cc_hw_fault_status_al
Definition: usbcsource.h:306
uint8_t i2c_address
Definition: usbcsource.h:293
i2c_master_t i2c
Definition: usbcsource.h:273
uint8_t usbcsource_get_pdo_config(usbcsource_t *ctx, uint8_t pdo_numb, pdo_config_t *pdo_cfg_data)
Get PDO configuration function.
uint8_t vpu_ovp_fault_trans
Definition: usbcsource.h:356
uint8_t vconn_mode
Definition: usbcsource.h:321
uint8_t th_145_status
Definition: usbcsource.h:355
void usbcsource_get_alert_status(usbcsource_t *ctx, alert_status_t *alert_status_data)
Get alert status function.
pin_name_t scl
Definition: usbcsource.h:286
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.
uint8_t dual_role_data
Definition: usbcsource.h:383
uint8_t usb_suspend_support
Definition: usbcsource.h:380
uint8_t vpu_ovp_fault
Definition: usbcsource.h:361
uint8_t usbcsource_set_pdo_config(usbcsource_t *ctx, pdo_config_t pdo_cfg_data)
Set PDO configuration function.
uint8_t usbcsource_int_pin_state(usbcsource_t *ctx)
Get INT pin state function.
uint32_t i2c_speed
Definition: usbcsource.h:292
USB-C Source Click PDO config object.
Definition: usbcsource.h:376
uint8_t slave_address
Definition: usbcsource.h:276
@ USBCSOURCE_OK
Definition: usbcsource.h:396
void usbcsource_get_monitoring_status(usbcsource_t *ctx, monitor_status_t *monitor_status_data)
Get monitoring status function.
void usbcsource_set_alert_status(usbcsource_t *ctx, alert_status_t alert_status_data)
Set alert status 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.
uint8_t dual_role_power
Definition: usbcsource.h:379
uint8_t usbcsource_read_byte(usbcsource_t *ctx, uint8_t reg)
Generic read function.
uint8_t vconn_sw_ocp_fault_cc2
Definition: usbcsource.h:366
usbcsource_return_value_t
USB-C Source Click return value data.
Definition: usbcsource.h:395
uint8_t vconn_sw_rvp_fault_cc2
Definition: usbcsource.h:364
uint8_t hard_reset_al
Definition: usbcsource.h:303
void usbcsource_cfg_setup(usbcsource_cfg_t *cfg)
USB-C Source configuration object setup function.
void usbcsource_get_fault_status(usbcsource_t *ctx, fault_status_t *fault_data)
Get fault status function.
uint8_t cc_reverse
Definition: usbcsource.h:344
digital_out_t rst
Definition: usbcsource.h:267
uint8_t unconstr_power
Definition: usbcsource.h:381
uint8_t vconn_sw_rvp_fault_trans
Definition: usbcsource.h:358
void usbcsource_get_connection_status(usbcsource_t *ctx, connection_status_t *conn_data)
Get connection status function.
pin_name_t sda
Definition: usbcsource.h:287
USB-C Source Click connection status object.
Definition: usbcsource.h:343
uint8_t fixed_supply
Definition: usbcsource.h:378
USB-C Source Click configuration object.
Definition: usbcsource.h:285