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 USBCSINK4_REG_DEVICE_MODE 0x0000u
70 #define USBCSINK4_REG_SILICON_ID 0x0002u
71 #define USBCSINK4_REG_INTERRUPT 0x0006u
72 #define USBCSINK4_REG_TYPE_C_STATUS 0x100Cu
73 #define USBCSINK4_REG_BUS_VOLTAGE 0x100Du
74 #define USBCSINK4_REG_BUS_CURRENT 0x1058u
75 #define USBCSINK4_REG_EVENT_STATUS 0x1034u
76 #define USBCSINK4_REG_CHARGING_MODE_STATUS 0x1095u
77 #define USBCSINK4_REG_RESET 0x0008u
78 #define USBCSINK4_REG_EVENT_MASK 0x1024u
79 #define USBCSINK4_REG_FAULT_PIN_MASK 0x1080u
80 #define USBCSINK4_REG_OVP_CONFIG 0x1088u
81 #define USBCSINK4_REG_SNK_FET_DISABLE 0x1084u
82 #define USBCSINK4_REG_SNK_FET_CONTROL 0x1085u
83 #define USBCSINK4_REG_SAFE_PWR_CONTROL 0x1086u
84 #define USBCSINK4_REG_CHARGING_MODE_DISABLE 0x1094u
85 #define USBCSINK4_REG_DEV_RESPONSE 0x007Eu
86 #define USBCSINK4_REG_PD_RESPONSE 0x1400u
87 #define USBCSINK4_REG_READ_DATA_MEMORY_START 0x1404u
88 #define USBCSINK4_REG_READ_DATA_MEMORY_STOP 0x150Bu
89 #define USBCSINK4_REG_WRITE_DATA_MEMORY_START 0x1800u
90 #define USBCSINK4_REG_WRITE_DATA_MEMORY_STOP 0x19FFu
108 #define USBCSINK4_TYPE_C_ST_PORT_DISCONN 0x00
109 #define USBCSINK4_TYPE_C_ST_PORT_CONN 0x01
110 #define USBCSINK4_TYPE_C_ST_PORT_BITMAKS 0x01
111 #define USBCSINK4_TYPE_C_ST_CC_1 0x00
112 #define USBCSINK4_TYPE_C_ST_CC_2 0x01
113 #define USBCSINK4_TYPE_C_ST_CC_BITMAKS 0x01
114 #define USBCSINK4_TYPE_C_ST_ATT_NTH 0x00
115 #define USBCSINK4_TYPE_C_ST_ATT_SRC 0x02
116 #define USBCSINK4_TYPE_C_ST_ATT_DEBUG 0x03
117 #define USBCSINK4_TYPE_C_ST_ATT_BITMAKS 0x07
118 #define USBCSINK4_TYPE_C_ST_CURR_0_9A 0x00
119 #define USBCSINK4_TYPE_C_ST_CURR_1A 0x01
120 #define USBCSINK4_TYPE_C_ST_CURR_3A 0x02
121 #define USBCSINK4_TYPE_C_ST_CURR_BITMAKS 0x03
127 #define USBCSINK4_CHARGING_MODE_ENABLE 0x00
128 #define USBCSINK4_CHARGING_MODE_DISABLE 0x01
129 #define USBCSINK4_CHG_MODE_STATUS_CLEAR 0xFF
135 #define USBCSINK4_CHG_MODE_STATUS_NO_LGC 0x00
136 #define USBCSINK4_CHG_MODE_STATUS_BC1_2DCP_CDC 0x01
137 #define USBCSINK4_CHG_MODE_STATUS_QC2_1 0x02
138 #define USBCSINK4_CHG_MODE_STATUS_AFC 0x04
139 #define USBCSINK4_CHG_MODE_STATUS_APPLE 0x05
145 #define USBCSINK4_INTERRUPT_RESPONSE_NO 0x00
146 #define USBCSINK4_INTERRUPT_RESPONSE_DEV 0x01
147 #define USBCSINK4_INTERRUPT_RESPONSE_PD 0x02
153 #define USBCSINK4_VOLTAGE_SENS 0.1f
154 #define USBCSINK4_CURRENT_SENS 0.05f
160 #define USBCSINK4_OVP_CONFIG_SIG_DISABLE 'D'
161 #define USBCSINK4_OVP_CONFIG_SIG_RE_ENABLE 'C'
162 #define USBCSINK4_OVP_CONFIG_THOLD_DEFAULT 0x28
163 #define USBCSINK4_OVP_CONFIG_DBNC_DEFAULT 0x0A
169 #define USBCSINK4_SIG_RESET 'R'
170 #define USBCSINK4_RESET_I2C 0x00
171 #define USBCSINK4_RESET_DEVICE 0x01
177 #define USBCSINK4_DEV_RSP_CMD_REG_WRITE 0x00
178 #define USBCSINK4_DEV_RSP_ASYNC_EVENT 0x80
179 #define USBCSINK4_DEV_RSP_CODE_NO_RSP 0x00
180 #define USBCSINK4_DEV_RSP_CODE_SUCCESS 0x02
181 #define USBCSINK4_DEV_RSP_CODE_INVALID 0x05
182 #define USBCSINK4_DEV_RSP_CODE_UNEXPECTED 0x09
183 #define USBCSINK4_DEV_RSP_CODE_NOT_SUPPORTED 0x0A
184 #define USBCSINK4_DEV_RSP_CODE_TXN_FAILED 0x0C
185 #define USBCSINK4_DEV_RSP_CODE_PD_CMD_FAILED 0x0D
186 #define USBCSINK4_DEV_RSP_CODE_PORT_BUSY 0x12
187 #define USBCSINK4_DEV_RSP_CODE_RST_CPLT 0x80
188 #define USBCSINK4_DEV_RSP_CODE_MSG_QUEUE_OVF 0x81
189 #define USBCSINK4_DEV_RSP_CODE_OVC 0x82
190 #define USBCSINK4_DEV_RSP_CODE_OVV 0x83
191 #define USBCSINK4_DEV_RSP_CODE_PORT_CONN 0x84
192 #define USBCSINK4_DEV_RSP_CODE_PORT_DISCONN 0x85
193 #define USBCSINK4_DEV_RSP_CODE_PD_NEG_CPLT 0x86
194 #define USBCSINK4_DEV_RSP_CODE_SWAP_CPLT 0x87
195 #define USBCSINK4_DEV_RSP_CODE_PS_RDY 0x8A
196 #define USBCSINK4_DEV_RSP_CODE_GOTOMIN 0x8B
197 #define USBCSINK4_DEV_RSP_CODE_ACCEPT 0x8C
198 #define USBCSINK4_DEV_RSP_CODE_REJECT 0x8D
199 #define USBCSINK4_DEV_RSP_CODE_WAIT 0x8E
200 #define USBCSINK4_DEV_RSP_CODE_HARD_RST 0x8F
201 #define USBCSINK4_DEV_RSP_CODE_VDM_REC 0x90
202 #define USBCSINK4_DEV_RSP_CODE_SRC_CAPB 0x91
203 #define USBCSINK4_DEV_RSP_CODE_SINK_CAPB 0x92
204 #define USBCSINK4_DEV_RSP_CODE_HARD_RST_SENT 0x9A
205 #define USBCSINK4_DEV_RSP_CODE_SOFT_RST_SENT 0x9B
206 #define USBCSINK4_DEV_RSP_CODE_SRC_DIS 0x9D
207 #define USBCSINK4_DEV_RSP_CODE_NO_VDM_RES_REC 0x9F
213 #define USBCSINK4_SILICON_ID_BCR_LITE 0x20A2u
220 #define USBCSINK4_DEVICE_ADDRESS 0x08
238 #define USBCSINK4_MAP_MIKROBUS( cfg, mikrobus ) \
239 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
240 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
241 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_AN ); \
242 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
560 #endif // USBCSINK4_H
err_t usbcsink4_get_silicon_id(usbcsink4_t *ctx, uint16_t *silicon_id)
USB-C Sink 4 get Silicon ID function.
uint8_t hw_rst_rec
Definition: usbcsink4.h:307
uint8_t curr_lvl
Definition: usbcsink4.h:291
uint8_t vbus_vtg_ovr
Definition: usbcsink4.h:313
@ USBCSINK4_OK
Definition: usbcsink4.h:325
uint8_t vbus_err
Definition: usbcsink4.h:312
USB-C Sink 4 Click configuration object.
Definition: usbcsink4.h:270
uint8_t dev_disc
Definition: usbcsink4.h:302
uint8_t vbus_curr_ovr
Definition: usbcsink4.h:314
err_t usbcsink4_get_chrg_mode(usbcsink4_t *ctx, uint8_t *chrg_mode)
USB-C Sink 4 get charging mode function.
uint8_t cc_pol
Definition: usbcsink4.h:289
err_t usbcsink4_get_bus_voltage(usbcsink4_t *ctx, float *vbus_v)
USB-C Sink 4 get VBUS function.
digital_in_t int_pin
Definition: usbcsink4.h:255
err_t usbcsink4_reset_device(usbcsink4_t *ctx)
USB-C Sink 4 reset the device function.
pin_name_t flt
Definition: usbcsink4.h:274
pin_name_t int_pin
Definition: usbcsink4.h:275
err_t usbcsink4_default_cfg(usbcsink4_t *ctx)
USB-C Sink 4 default configuration function.
uint8_t err_rcvy
Definition: usbcsink4.h:311
uint8_t usbcsink4_get_interrupt(usbcsink4_t *ctx)
USB-C Sink 4 get interrupt function.
uint8_t hw_rst_sent
Definition: usbcsink4.h:308
@ USBCSINK4_ERROR
Definition: usbcsink4.h:326
pin_name_t scl
Definition: usbcsink4.h:271
uint32_t i2c_speed
Definition: usbcsink4.h:277
uint8_t pd_cn_comp
Definition: usbcsink4.h:303
USB-C Sink 4 Click status of the event.
Definition: usbcsink4.h:300
err_t usbcsink4_init(usbcsink4_t *ctx, usbcsink4_cfg_t *cfg)
USB-C Sink 4 initialization function.
uint8_t pwr_role
Definition: usbcsink4.h:304
uint8_t vconn
Definition: usbcsink4.h:306
USB-C Sink 4 Click status of the Type-C port.
Definition: usbcsink4.h:287
uint8_t dev_att
Definition: usbcsink4.h:301
uint8_t cable_rst_sent
Definition: usbcsink4.h:310
err_t usbcsink4_get_event_status(usbcsink4_t *ctx, usbcsink4_event_status_t *event_status)
USB-C Sink 4 get event status function.
uint8_t data_role
Definition: usbcsink4.h:305
uint8_t i2c_address
Definition: usbcsink4.h:278
void usbcsink4_cfg_setup(usbcsink4_cfg_t *cfg)
USB-C Sink 4 configuration object setup function.
i2c_master_t i2c
Definition: usbcsink4.h:258
uint8_t usbcsink4_get_fault_condition(usbcsink4_t *ctx)
USB-C Sink 4 get fault indicator function.
uint8_t soft_rst_sent
Definition: usbcsink4.h:309
usbcsink4_return_value_t
USB-C Sink 4 Click return value data.
Definition: usbcsink4.h:324
USB-C Sink 4 Click context object.
Definition: usbcsink4.h:252
uint8_t slave_address
Definition: usbcsink4.h:261
err_t usbcsink4_generic_write(usbcsink4_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len)
USB-C Sink 4 I2C writing function.
err_t usbcsink4_generic_read(usbcsink4_t *ctx, uint16_t reg, uint8_t *data_out, uint8_t len)
USB-C Sink 4 I2C reading function.
err_t usbcsink4_get_bus_current(usbcsink4_t *ctx, float *vbus_c)
USB-C Sink 4 get VBUS current function.
err_t usbcsink4_get_response(usbcsink4_t *ctx, uint8_t *rsp_code)
USB-C Sink 4 get response function.
digital_in_t flt
Definition: usbcsink4.h:254
uint8_t att_dev_type
Definition: usbcsink4.h:290
uint8_t port_par_cxn
Definition: usbcsink4.h:288
err_t usbcsink4_get_type_c_status(usbcsink4_t *ctx, usbcsink4_type_c_status_t *type_c_status)
USB-C Sink 4 get Type-C status function.
err_t usbcsink4_reset_i2c(usbcsink4_t *ctx)
USB-C Sink 4 reset the I2C block function.
pin_name_t sda
Definition: usbcsink4.h:272