Lack of documentation and inconsistency in STUSB4500Q code example Hello,I'm implementing the sink side of a usb-c PD system based on STUSB4500Q.I had a look to documentation and to the example code.It looks that the code was written by a first year intern. The ~25 global variables,inconsistency in variable / constants casing, globals that are in fact locals, static locals that are in fact locals and an odd general architecture make It not very easy to understand.As an example, I can read this:if (Alert_Status.b.CC_DETECTION_STATUS_AL != 0) {
connection_flag[Usb_Port] = 1;
Status = I2C_Read_USB_PD(STUSB45DeviceConf[Usb_Port].I2cBus, STUSB45DeviceConf[Usb_Port].I2cDeviceID_7bit, PORT_STATUS_TRANS, &DataRW[0], 2);
PD_status[Usb_Port].Port_Status.d8 = DataRW[1];
if (PD_status[Usb_Port].Port_Status.b.CC_ATTACH_STATE != 0) {
Status = I2C_Read_USB_PD(STUSB45DeviceConf[Usb_Port].I2cBus, STUSB45DeviceConf[Usb_Port].I2cDeviceID_7bit, CC_STATUS, &PD_status[Usb_Port].CC_status.d8, 1);
} else /* Detached detected */
{
connection_flag[Usb_Port] = 1