ST Managing USB-C port status Programming Manual
広告
広告
PM0265
Programming manual
Managing USB-C port status with the STUSB4500L
Introduction
This document describes how to read USB-C port status by executing a few I 2 C commands on top of the STUSB4500L from an application processor. Open source software is available to speed up the application software development. The code is available as an example only.
Table 1. Minimal configuration
STSW-STUSB007
EVAL-SCS002V1
NUCLEO-F072RB
IAR 8.x
Software library including the STUSB4500L hardware abstraction layers, drivers and Code example
STUSB4500L evaluation board and reference design
STM32 Nucleo-64 development board with ARM Cortex M0
C code compiler
Figure 1. STUSB4500L software library
PM0265 - Rev 1 - February 2020
For further information contact your local STMicroelectronics sales office.
www.st.com
1
PM0265
Hardware configuration
Hardware configuration
The SCL, SDA and GND signals from the EVAL-SCS002V1 board (or custom application board) must be connected to their counterpart signals from the NUCLEO-F072RB board (see connections below).
Figure 2. NUCLEO-F072RB
Note: The EVAL-SCS002V1 board is automatically powered by VBUS when a SOURCE is attached.
The proposed software assumes that a dedicated pull-up of 4.7 kOhms is externally implemented on SDA/SCL lines. Take care that without dedicated pull-up resistors, max. bandwidth on I²C bus is limited.
PM0265 - Rev 1 page 2/24
2 Main files
•
•
The library is composed of the following files:
• USB_PD_defines_STUSB-GEN1S.h
USB_PD_core.h
USB_PD_core.c
• Main.c
USB_PD_defines_STUSB-GEN1S.h
• Contains register definition of the STUSB4500L
USB_PD_core.h
• Contains main structures used to handle the STUSB4500L configuration
USB_PD_core.c
• Contains generic functions to be used to build applications
Main.c
• Illustrates how to use the functions and build applications
PM0265
Main files
PM0265 - Rev 1 page 3/24
3
3.4
3.5
3.1
3.2
3.3
PM0265
Drivers
Drivers
Here is the list of available functions developed for the STUSB4500L software functions: void usb_pd_init(uint8_t Port); void ALARM_MANAGEMENT(uint8_t Port); void HW_Reset_state(uint8_t Port); void SW_reset_by_Reg(uint8_t Port); void Print_Type_C_Only_Status(uint8_t Usb_Port); usb_pd_init(Port)
This function clears all interrupts and unmasks the useful interrupts
ALARM_MANAGEMENT(Port)
This is the device interrupt handler.
HW_Reset_state(Port)
This function asserts and de-asserts the STUSB4500L hardware reset pin if connected to the appropriate MCU
GPIO.
SW_Reset_by_Reg(Port)
This function resets the STUSB4500L type-C state machine. It also clears any ALERT.
Print_Type_C_Only_Status (Port)
This function prints the USB-C information received by the STUSB4500L, such as CC pin orientation and Rp value from source:
• CC pin information is useful for USB3.x data signal routing (SSTX/SSRX)
• Rp value information is useful to limit application consumption and/or to set application charging current accordingly
Figure 3. USB port
PM0265 - Rev 1 page 4/24
4
PM0265
How to read the USB-C connection STATUS?
How to read the USB-C connection STATUS?
Connection status can be known by accessing the two registers below:
• PORT_STATUS_1 (@0x0E)
• CC_STATUS (@0x11)
It is possible to report the following information to the application processor:
1.
the plug orientation (CC pin attached to CC1 or CC2)
2.
the USB-C source current (Rp resistor value)
For further details, see function: Print_Type_C_Only_Status
PM0265 - Rev 1 page 5/24
5 Register map
Offset Register name
0x06 BCD_TYPEC_REV_LOW
0x07 BCD_TYPEC_REV_HIGH
0x08 reserved
0x09 reserved
0x0A reserved
0x0B ALERT_STATUS_1
0x0C ALERT_STATUS_1_MASK
0x0D PORT_STATUS_0
0x0E PORT_STATUS_1
0x0F TYPEC_MONITORING_STATUS_0
0x10 TYPEC_MONITORING_STATUS_1
0x11 CC_STATUS
0x12 CC_HW_FAULT_STATUS_0
0x13 CC_HW_FAULT_STATUS_1
0x14 reserved
0x15 TYPEC_STATUS
0x16 to
0x1F reserved
0x20 MONITORING_CTRL_0
0x21 reserved
0x22 MONITORING_CTRL_2
0x23 RESET_CTRL
0x24 to
0x1C reserved
0x2D GPIO_SW_GPIO
Description
BCD_TYPEC_REV_LOW register
BCD_TYPEC_REV_HIGH register reserved reserved reserved
ALERT_STATUS_1 register
ALERT_STATUS_1_MASK register
PORT_STATUS_0 register
PORT_STATUS_1 register
TYPEC_MONITORING_STATUS_0 register
TYPEC_MONITORING_STATUS_1 register
CC_STATUS register
CC_HW_FAULT_STATUS_0 register
CC_HW_FAULT_STATUS_1 register reserved
TYPEC_STATUS register reserved
MONITORING_CTRL_0 register reserved
MONITORING_CTRL_2 register
RESET_CTRL register reserved
GPIO_SW_GPIO register
PM0265
Register map
PM0265 - Rev 1 page 6/24
5.1
5.2
BCD_TYPEC_REV_LOW register
Address : STUSB_BLOCKBaseAddress + 0x06
Type : R
Reset : 0x12
7 6 5 4 3
BCD_TYPEC_REV_7_0
R
2
[7:0] BCD_TYPEC_REV_7_0 : Defined Type-C release supported by the device
BCD_TYPEC_REV_HIGH register
Address : STUSB_BLOCKBaseAddress + 0x07
Type : R
Reset : 0x00
7 6 5 4 3
BCD_TYPEC_REV_15_8
R
2
[7:0] BCD_TYPEC_REV_15_8 : Defined Type-C release supported by the device
PM0265
BCD_TYPEC_REV_LOW register
1 0
1 0
PM0265 - Rev 1 page 7/24
PM0265
ALERT_STATUS_1 register
5.3
ALERT_STATUS_1 register
Address : STUSB_BLOCKBaseAddress + 0x0B
Type : R
Reset : 0x00
7 6 5 4 3 2 1 0
R R R
[3]
[2]
[1]
[0]
[7]
[6]
[5]
[4] reserved
PORT_STATUS_AL
TYPEC_MONITORING_STATUS_AL
CC_HW_FAULT_STATUS_AL reserved reserved reserved reserved
R R R R R
PM0265 - Rev 1 page 8/24
PM0265
ALERT_STATUS_1_MASK register
5.4
ALERT_STATUS_1_MASK register
Address : STUSB_BLOCKBaseAddress + 0x0C
Type : R/W
Reset : 0xFB (initialized by NVM)
7 6 5 4 3 2 1 0
PM0265 - Rev 1
R/W R/W R/W
[7]
[6]
[5]
[4]
[3]
[2]
[1]
[0] reserved
PORT_STATUS_AL
0: (UNMASKED) Interrupt unmasked
1: (MASKED) Interrupt masked
TYPEC_MONITORING_STATUS_AL
0: (UNMASKED) Interrupt unmasked
1: (MASKED) Interrupt masked
CC_HW_FAULT_STATUS_AL
0: (UNMASKED) Interrupt unmasked
1: (MASKED) Interrupt masked reserved
1 reserved
1 reserved
1 reserved
1
R/W R/W R R/W R/W page 9/24
PM0265
PORT_STATUS_0 register
5.5
PORT_STATUS_0 register
Address : STUSB_BLOCKBaseAddress + 0x0D
Type : R
Reset : 0x00
7 6 5 4 3 2 1 0
R
[7:1]
[0] reserved
ATTACH_TRANS :
0: (NO_TRANS) no transition detected in attached states
1: (TRANS) transition detected in attached state
RC
PM0265 - Rev 1 page 10/24
5.6
PM0265
PORT_STATUS_1 register
PORT_STATUS_1 register
Address : STUSB_BLOCKBaseAddress + 0x0E
Type : R
Reset : 0x00
7 6
ATTACHED_DEVICE
R
5 4 reserved
R
3 reserved
R
2 reserved
R
1 reserved
R
0
ATTACH
R
[4]
[3]
[2]
[1]
[7:5]
[0]
ATTACHED_DEVICE :
000: (NONE_ATT) No device connected
001: reserved
010: reserved
011: (DBG_ATT) Debug accessory device connected
100: reserved
101: reserved
Others: do not use reserved reserved reserved reserved
ATTACH :
0: UNATTACHED
1: ATTACHED
PM0265 - Rev 1 page 11/24
PM0265
TYPEC_MONITORING_STATUS_0 register
5.7
TYPEC_MONITORING_STATUS_0 register
Address : STUSB_BLOCKBaseAddress + 0x0F
Type : R
Reset : 0x0F
7 6 5 4 3 2 1 0
R RC RC RC RC RC
[7:6] reserved
[5]
VBUS_HIGH_STATUS : VBUS_HIGH status updated during VBUS_READY transition from HIGH to LOW
0: (VBUS_HIGH_OK) VBUS below high threshold
1: (VBUS_HIGH_KO) VBUS above high threshold (overvoltage condition)
[4]
[3]
VBUS_LOW_STATUS : VBUS_LOW status updated during VBUS_READY transition from HIGH to LOW
0: (VBUS_LOW_OK) VBUS above low threshold
1: (VBUS_LOW_KO) VBUS below low threshold (undervoltage condition)
VBUS_READY_TRANS :
0: (NO_TRANS) status cleared
1: (TRANS_DETECTED) transition detected on VBUS_READY bit
[2]
VBUS_VSAFE0V_TRANS :
0: (NO_TRANS) status cleared
1: (TRANS_DETECTED) Transition detected on VBUS_VSAFE0V bit
[1]
VBUS_VALID_SNK_TRANS :
0: (NO_TRANS) status cleared
1: (TRANS_DETECTED) transition detected on VBUS_VALID_SNK bit
[0] reserved
R
PM0265 - Rev 1 page 12/24
PM0265
TYPEC_MONITORING_STATUS_1 register
5.8
TYPEC_MONITORING_STATUS_1 register
Address : STUSB_BLOCKBaseAddress + 0x10
Type : R
Reset : 0x00
7 6 5 4 3 2 1 0
R R R R R
[7:4] reserved
[3]
[2]
VBUS_READY :
0: (NO_VBUS_READY) VBUS disconnected (Unpowered or vSafe0V)
1: (VBUS_READY) VBUS connected (vSafe5V)
VBUS_VSAFE0V :
0: (NO_VSAFE0V) VBUS is higher than 0.8 V
1: (VSAFE0V) VBUS is lower than 0.8 V
[1]
VBUS_VALID_SNK :
0: (NO_VBUS_VALID_SNK) VBUS is lower than 1.9 V or 3.5 V (depending on VBUS_SNK_DISC_THRESHOLD value)
1: (VBUS_VALID_SNK) VBUS is higher than 1.9 V or 3.5 V (depending on VBUS_SNK_DISC_THRESHOLD value)
[0] reserved
PM0265 - Rev 1 page 13/24
PM0265
CC_STATUS register
5.9
CC_STATUS register
Address : STUSB_BLOCKBaseAddress + 0x11
Type : R
Reset : 0x00
7 6 5 4 3 2 1 0
R R R R R
[7:6] reserved
[5]
LOOKING_4_CONNECTION:
0: (NOT_LOOKING) The device is not actively looking for a connection. A transition from '1' to '0' indicates a potential connection has been found. When the device is in power-up sequence or when TYPE-C FSM is in the following states:
Attached.SNK, DebugAccessory.SNK
1: (LOOKING) The device is looking for a connection
[4]
CONNECT_RESULT:
0: reserved
1: (PRESENT_RD) The device is presenting Rd. When TYPE-C FSM is in the following states: Attached.SNK,
DebugAccessory.SNK
CC2_STATE: (available when CONNECT_result =1)
00: reserved
[3:2]
01: SNK.Default (Above minimum vRd-Connect)
10: SNK.Power1.5 (Above minimum vRd-Connect)
11: SNK.Power3.0 (Above minimum vRd-Connect)
This field returns 00b if (LOOKING_4_CONNECTION=1)
CC1_STATE: (available when CONNECT_result =1)
00: reserved
[1:0]
01: SNK.Default (Above minimum vRd-Connect)
10: SNK.Power1.5 (Above minimum vRd-Connect)
11: SNK.Power3.0 (Above minimum vRd-Connect)
This field returns 00b if (LOOKING_4_CONNECTION=1)
PM0265 - Rev 1 page 14/24
PM0265
CC_HW_FAULT_STATUS_0 register
5.10
CC_HW_FAULT_STATUS_0 register
Address : STUSB_BLOCKBaseAddress + 0x12
Type : R
Reset : 0x10
7 6 5 4 3 2 1 0
R R RC RC R
[7:6] reserved
[5]
VPU_OVP_FAULT_TRANS :
0: (NO_TRANS) cleared
1: (TRANS_DETECTED) transition occurred on VPU_OVP_FAULT bit
[4]
[3]
VPU_VALID_TRANS :
0: (NO_TRANS) cleared
1: (TRANS_DETECTED) transition occurred on VPU_VALID bit reserved
R R R
PM0265 - Rev 1 page 15/24
PM0265
CC_HW_FAULT_STATUS_1 register
5.11
CC_HW_FAULT_STATUS_1 register
Address : STUSB_BLOCKBaseAddress + 0x13
Type : R
Reset : 0x40
7 6 5 4 3 2 1 0
R R R R R R R R
[7]
[6]
VPU_OVP_FAULT:
0: (NO_FAULT) no overvoltage condition on CC pins when in pull-up mode (CC pins voltage is below overvoltage threshold of 6.0 V)
1: (FAULT) overvoltage condition has occurred on CC pins when in pull-up mode (CC pins voltage is above overvoltage threshold of 6.0 V)
VPU_VALID:
0: (NO_VALID) CC pins pull-up voltage is below UVLO threshold of 2.8 V when in pull-up mode
1: (VALID) CC pins pull-up voltage is above UVLO threshold of 2.8 V when in pull-up mode (normal operating condition)
[5] reserved
[4]
VSRC_DISCH_FAULT:
0: (NO_FAULT) No VBUS discharge issue
1: (FAULT) VBUS discharge issue has occurred
[3:0] reserved
PM0265 - Rev 1 page 16/24
PM0265
TYPEC_STATUS register
5.12
TYPEC_STATUS register
Address : STUSB_BLOCKBaseAddress + 0x15
Type : R
Reset : 0x00
7
REVERSE
R
6 reserved
R
5 reserved
R
4 3 2 1
TYPEC_FSM_STATE
R
0
[7]
REVERSE : Connection orientation, indicates CC pin used for PD communication
0: (STRAIGHT_CC1) CC1 is attached
1: (TWISTED_CC2) CC2 is attached
[6:5] reserved
[4:0]
TYPEC_FSM_STATE : Indicates Type-C FSM state
00000: (UNATTACHED_SNK)
00001: (ATTACHWAIT_SNK)
00010: (ATTACHED_SNK)
00011: (DEBUGACCESSORY_SNK)
00100: reserved
00101: reserved
00110: reserved
00111: reserved
01000: reserved
01001: reserved
01010: reserved
01011: reserved
01100: reserved
01101: (UNATTACHED_ACCESSORY)
01110: (ATTACHWAIT_ACCESSORY)
01111: (AUDIOACCESSORY)
10000: reserved
10001: reserved
10010: (UNSUPPORTED_ACCESSORY)
10011: (TYPEC_ERRORRECOVERY)
10100: reserved
10101: reserved
10110: reserved
10111: reserved
11000: reserved
11001: reserved
PM0265 - Rev 1 page 17/24
PM0265
MONITORING_CTRL_0 register
5.13
MONITORING_CTRL_0 register
Address : STUSB_BLOCKBaseAddress + 0x20
Type : R/W
Reset : 0x10
7 6 5 4 3 2 1 0
R R/W R R
5.14
[7:4] reserved
[3]
VBUS_SNK_DISC_THRESHOLD : VBUS threshold for TYPE-C state machine disconnection
0: (SNK_DISC_HIGH) Select a VBUS threshold at 3.5 V - Reset value
1: (SNK_DISC_LOW) Select a VBUS threshold at 1.9 V
[2:0] reserved
MONITORING_CTRL_2 register
Address : STUSB_BLOCKBaseAddress + 0x22
Type : R/W
Reset : 0xFF
7 6
VSHIFT_HIGH
R/W
5 4 3 2 reserved
R/W
1
[7:4]
VSHIFT_HIGH : shift register initialisation high level (set OVP level ) with 1% step.
0000: (default) +5%
0001:+6%
….
1111:+20%
[3:0] reserved
R
0
PM0265 - Rev 1 page 18/24
PM0265
RESET_CTRL register
5.15
RESET_CTRL register
Address : STUSB_BLOCKBaseAddress + 0x23
Type : R/W
Reset : 0x00
7 6 5 4 reserved
R/W
3 2 1
5.16
[7:1]
[0] reserved
RESET_SW_EN : Software reset
0: (SW_RESET_OFF) Software reset disabled
1: (SW_RESET_ON) Software reset enabled
GPIO_SW_GPIO register
Address : STUSB_BLOCKBaseAddress + 0x2D
Type : R/W
Reset : 0x00
7 6 5 4 reserved
R
3 2 1
[7:1]
[0] reserved
GPIO_SW_GPIO : GPIO output value
0: (DISABLE) GPIO value is Hi-Z
1: (ENABLE) GPIO value is 0b
0
RESET_SW_EN
R/W
0
GPIO_SW_GPIO
R/W
PM0265 - Rev 1 page 19/24
Revision history
Date
02-Feb-2020
Version
1
Table 2. Document revision history
Changes
Initial release.
PM0265
PM0265 - Rev 1 page 20/24
PM0265
Contents
Contents
PM0265 - Rev 1 page 21/24
PM0265
List of tables
List of tables
PM0265 - Rev 1 page 22/24
PM0265
List of figures
List of figures
PM0265 - Rev 1 page 23/24
PM0265
IMPORTANT NOTICE – PLEASE READ CAREFULLY
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of
Purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, please refer to www.st.com/trademarks . All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2020 STMicroelectronics – All rights reserved
PM0265 - Rev 1 page 24/24
ダウンロード
広告