#include typedef struct { uint32_t hbitclkdiv: 6; // 0 Division ratio for producing half-bit clock The bitfield determines the division ratio (the bitfield value plus one) of a ucpd_clk divider producing half-bit clock (hbit_clk). uint32_t ifrgap : 5; // 6 Division ratio for producing inter-frame gap timer clock The bitfield determines the division ratio (the bitfield value minus one) of a ucpd_clk divider producing inter-frame gap timer clock (tInterFrameGap). The division ratio 15 is to apply for Tx clock at the USB PD 2.0 specification nominal value. The division ratios below 15 are to apply for Tx clock below nominal, and the division ratios above 15 for Tx clock above nominal. uint32_t transwin : 5; // 11 Transition window duration The bitfield determines the division ratio (the bitfield value minus one) of a hbit_clk divider producing tTransitionWindow interval. Set a value that produces an interval of 12 to 20 us, taking into account the ucpd_clk frequency and the HBITCLKDIV[5:0] bitfield setting. uint32_t reserve0 : 1; // 16 Reserve uint32_t psc_usbpdclk: 3; // 17 Pre-scaler division ratio for generating ucpd_clk The bitfield determines the division ratio of a kernel clock pre-scaler producing UCPD peripheral clock (ucpd_clk). It is recommended to use the pre-scaler so as to set the ucpd_clk frequency in the range from 6 to 9 MHz. uint32_t rxordseten: 9; // 20 Receiver ordered set enable The bitfield determines the types of ordered sets that the receiver must detect. When set/cleared, each bit enables/disables a specific function: 0bxxxxxxxx1: SOP detect enabled 0bxxxxxxx1x: SOP' detect enabled 0bxxxxxx1xx: SOP'' detect enabled 0bxxxxx1xxx: Hard Reset detect enabled 0bxxxx1xxxx: Cable Detect reset enabled 0bxxx1xxxxx: SOP'_Debug enabled 0bxx1xxxxxx: SOP''_Debug enabled 0bx1xxxxxxx: SOP extension#1 enabled 0b1xxxxxxxx: SOP extension#2 enabled uint32_t txdmaen : 1; // 29 Transmission DMA mode enable When set, the bit enables DMA mode for transmission. uint32_t rxdmaen : 1; // 30 Reception DMA mode enable When set, the bit enables DMA mode for reception. uint32_t ucpden : 1; // 31 UCPD peripheral enable General enable of the UCPD peripheral. Upon disabling, the peripheral instantly quits any ongoing activity and all control bits and bitfields default to their reset values. They must be set to their desired values each time the peripheral transits from disabled to enabled state. } reg_ucpd_cfgr1_t; typedef struct { uint32_t rxfiltdis : 1; // 0 BMC decoder Rx pre-filter enable The sampling clock is that of the receiver (that is, after pre-scaler). uint32_t rxfilt2n3 : 1; // 1 BMC decoder Rx pre-filter sampling method Number of consistent consecutive samples before confirming a new value. uint32_t forceclk : 1; // 2 Force ClkReq clock request uint32_t wupen : 1; // 3 Wakeup from Stop mode enable Setting the bit enables the UCPD_ASYNC_INT signal. uint32_t reserve0 : 28; // 4 Reserve } reg_ucpd_cfgr2_t; typedef struct { uint32_t trim1_ng_ccrpd: 4; // 0 SW trim value for RPD resistors on the CC1 line uint32_t reserve0 : 5; // 4 Reserve uint32_t trim1_ng_cc3a0: 4; // 9 SW trim value for Iref on the CC1 line uint32_t reserve1 : 3; // 13 Reserve uint32_t trim2_ng_ccrpd: 4; // 16 SW trim value for RPD resistors on the CC2 line uint32_t reserve2 : 5; // 20 Reserve uint32_t trim2_ng_cc3a0: 4; // 25 SW trim value for Iref on the CC2 line uint32_t reserve3 : 3; // 29 Reserve } reg_ucpd_cfgr3_t; typedef struct { uint32_t txmode : 2; // 0 Type of Tx packet Writing the bitfield triggers the action as follows, depending on the value: Others: invalid From V1.1 of the USB PD specification, there is a counter defined for the duration of the BIST Carrier Mode 2. To quit this mode correctly (after the "tBISTContMode" delay), disable the peripheral (UCPDEN = 0). uint32_t txsend : 1; // 2 Command to send a Tx packet The bit is cleared by hardware as soon as the packet transmission begins or is discarded. uint32_t txhrst : 1; // 3 Command to send a Tx Hard Reset The bit is cleared by hardware as soon as the message transmission begins or is discarded. uint32_t rxmode : 1; // 4 Receiver mode Determines the mode of the receiver. When the bit is set, RXORDSET behaves normally, RXDR no longer receives bytes yet the CRC checking still proceeds as for a normal message. uint32_t phyrxen : 1; // 5 USB Power Delivery receiver enable Both CC1 and CC2 receivers are disabled when the bit is cleared. Only the CC receiver selected via the PHYCCSEL bit is enabled when the bit is set. uint32_t phyccsel : 1; // 6 CC1/CC2 line selector for USB Power Delivery signaling The selection depends on the cable orientation as discovered at attach. uint32_t anasubmode: 2; // 7 Analog PHY sub-mode Refer to TYPEC_VSTATE_CCx for the effect of this bitfield. uint32_t anamode : 1; // 9 Analog PHY operating mode The use of CC1 and CC2 depends on CCENABLE. Refer to ANAMODE, ANASUBMODE and link with TYPEC_VSTATE_CCx for the effect of this bitfield in conjunction with ANASUBMODE[1:0]. uint32_t ccenable : 2; // 10 CC line enable This bitfield enables CC1 and CC2 line analog PHYs (pull-ups and pull-downs) according to ANAMODE and ANASUBMODE[1:0] setting. A single line PHY can be enabled when, for example, the other line is driven by VCONN via an external VCONN switch. Enabling both PHYs is the normal usage for sink/source. uint32_t reserve0 : 1; // 12 Reserve uint32_t cc1vconnen: 1; // 13 VCONN switch enable for CC1 uint32_t cc2vconnen: 1; // 14 VCONN switch enable for CC2 uint32_t reserve1 : 1; // 15 Reserve uint32_t frsrxen : 1; // 16 FRS event detection enable Setting the bit enables FRS Rx event (FRSEVT) detection on the CC line selected through the PHYCCSEL bit. 0: Disable Clear the bit when the device is attached to an FRS-incapable source/sink. uint32_t frstx : 1; // 17 FRS Tx signaling enable. Setting the bit enables FRS Tx signaling. The bit is cleared by hardware after a delay respecting the USB Power Delivery specification Revision 3.0. uint32_t rdch : 1; // 18 Rdch condition drive The bit drives Rdch condition on the CC line selected through the PHYCCSEL bit (thus associated with VCONN), by remaining set during the source-only UnattachedWait.SRC state, to respect the Type-C state. Refer to "USB Type-C ECN for Source VCONN Discharge". The CCENABLE[1:0] bitfield must be set accordingly, too. uint32_t reserve2 : 1; // 19 Reserve uint32_t cc1tcdis : 1; // 20 CC1 Type-C detector disable The bit disables the Type-C detector on the CC1 line. When enabled, the Type-C detector for CC1 is configured through ANAMODE and ANASUBMODE[1:0]. uint32_t cc2tcdis : 1; // 21 CC2 Type-C detector disable The bit disables the Type-C detector on the CC2 line. When enabled, the Type-C detector for CC2 is configured through ANAMODE and ANASUBMODE[1:0]. uint32_t reserve3 : 10; // 22 Reserve } reg_ucpd_cr_t; typedef struct { uint32_t txisie : 1; // 0 TXIS interrupt enable uint32_t txmsgdiscie: 1; // 1 TXMSGDISC interrupt enable uint32_t txmsgsentie: 1; // 2 TXMSGSENT interrupt enable uint32_t txmsgabtie: 1; // 3 TXMSGABT interrupt enable uint32_t hrstdiscie: 1; // 4 HRSTDISC interrupt enable uint32_t hrstsentie: 1; // 5 HRSTSENT interrupt enable uint32_t txundie : 1; // 6 TXUND interrupt enable uint32_t reserve0 : 1; // 7 Reserve uint32_t rxneie : 1; // 8 RXNE interrupt enable uint32_t rxorddetie: 1; // 9 RXORDDET interrupt enable uint32_t rxhrstdetie: 1; // 10 RXHRSTDET interrupt enable uint32_t rxovrie : 1; // 11 RXOVR interrupt enable uint32_t rxmsgendie: 1; // 12 RXMSGEND interrupt enable uint32_t reserve1 : 1; // 13 Reserve uint32_t typecevt1ie: 1; // 14 TYPECEVT1 interrupt enable uint32_t typecevt2ie: 1; // 15 TYPECEVT2 interrupt enable uint32_t reserve2 : 4; // 16 Reserve uint32_t frsevtie : 1; // 20 FRSEVT interrupt enable uint32_t reserve3 : 11; // 21 Reserve } reg_ucpd_imr_t; typedef struct { uint32_t txis : 1; // 0 Transmit interrupt status The flag indicates that the UCPD_TXDR register is empty and new data write is required (as the amount of data sent has not reached the payload size defined in the TXPAYSZ bitfield). The flag is cleared with the data write into the UCPD_TXDR register. uint32_t txmsgdisc : 1; // 1 Message transmission discarded The flag indicates that a message transmission was dropped. The flag is cleared by setting the TXMSGDISCCF bit. Transmission of a message can be dropped if there is a concurrent receive in progress or at excessive noise on the line. After a Tx message is discarded, the flag is only raised when the CC line becomes idle. uint32_t txmsgsent : 1; // 2 Message transmission completed The flag indicates the completion of packet transmission. It is cleared by setting the TXMSGSENTCF bit. In the event of a message transmission interrupted by a Hard Reset, the flag is not raised. uint32_t txmsgabt : 1; // 3 Transmit message abort The flag indicates that a Tx message is aborted due to a subsequent Hard Reset message send request taking priority during transmit. It is cleared by setting the TXMSGABTCF bit. uint32_t hrstdisc : 1; // 4 Hard Reset discarded The flag indicates that the Hard Reset message is discarded. The flag is cleared by setting the HRSTDISCCF bit. uint32_t hrstsent : 1; // 5 Hard Reset message sent The flag indicates that the Hard Reset message is sent. The flag is cleared by setting the HRSTSENTCF bit. uint32_t txund : 1; // 6 Tx data underrun detection The flag indicates that the Tx data register (UCPD_TXDR) was not written in time for a transmit message to execute normally. It is cleared by setting the TXUNDCF bit. uint32_t reserve0 : 1; // 7 Reserve uint32_t rxne : 1; // 8 Receive data register not empty detection The flag indicates that the UCPD_RXDR register is not empty. It is automatically cleared upon reading UCPD_RXDR. uint32_t rxorddet : 1; // 9 Rx ordered set (4 K-codes) detection The flag indicates the detection of an ordered set. The relevant information is stored in the RXORDSET[2:0] bitfield of the UCPD_RX_ORDSET register. It is cleared by setting the RXORDDETCF bit. uint32_t rxhrstdet : 1; // 10 Rx Hard Reset receipt detection The flag indicates the receipt of valid Hard Reset message. It is cleared by setting the RXHRSTDETCF bit. uint32_t rxovr : 1; // 11 Rx data overflow detection The flag indicates Rx data buffer overflow. It is cleared by setting the RXOVRCF bit. The buffer overflow can occur if the received data are not read fast enough. uint32_t rxmsgend : 1; // 12 Rx message received The flag indicates whether a message (except Hard Reset message) has been received, regardless the CRC value. The flag is cleared by setting the RXMSGENDCF bit. The RXERR flag set when the RXMSGEND flag goes high indicates errors in the last-received message. uint32_t rxerr : 1; // 13 Receive message error The flag indicates errors of the last Rx message declared (via RXMSGEND), such as incorrect CRC or truncated message (a line becoming static before EOP is met). It is asserted whenever the RXMSGEND flag is set. uint32_t typecevt1 : 1; // 14 Type-C voltage level event on CC1 line The flag indicates a change of the TYPEC_VSTATE_CC1[1:0] bitfield value, which corresponds to a new Type-C event. It is cleared by setting the TYPECEVT2CF bit. uint32_t typecevt2 : 1; // 15 Type-C voltage level event on CC2 line The flag indicates a change of the TYPEC_VSTATE_CC2[1:0] bitfield value, which corresponds to a new Type-C event. It is cleared by setting the TYPECEVT2CF bit. uint32_t typec_vstate_cc1: 2; // 16 The status bitfield indicates the voltage level on the CC1 line in its steady state. The voltage variation on the CC1 line during USB PD messages due to the BMC PHY modulation does not impact the bitfield value. uint32_t typec_vstate_cc2: 2; // 18 CC2 line voltage level The status bitfield indicates the voltage level on the CC2 line in its steady state. The voltage variation on the CC2 line during USB PD messages due to the BMC PHY modulation does not impact the bitfield value. uint32_t frsevt : 1; // 20 FRS detection event The flag is cleared by setting the FRSEVTCF bit. uint32_t reserve1 : 11; // 21 Reserve } reg_ucpd_sr_t; typedef struct { uint32_t reserve0 : 1; // 0 Reserve uint32_t txmsgdisccf: 1; // 1 Tx message discard flag (TXMSGDISC) clear Setting the bit clears the TXMSGDISC flag in the UCPD_SR register. uint32_t txmsgsentcf: 1; // 2 Tx message send flag (TXMSGSENT) clear Setting the bit clears the TXMSGSENT flag in the UCPD_SR register. uint32_t txmsgabtcf: 1; // 3 Tx message abort flag (TXMSGABT) clear Setting the bit clears the TXMSGABT flag in the UCPD_SR register. uint32_t hrstdisccf: 1; // 4 Hard reset discard flag (HRSTDISC) clear Setting the bit clears the HRSTDISC flag in the UCPD_SR register. uint32_t hrstsentcf: 1; // 5 Hard reset send flag (HRSTSENT) clear Setting the bit clears the HRSTSENT flag in the UCPD_SR register. uint32_t txundcf : 1; // 6 Tx underflow flag (TXUND) clear Setting the bit clears the TXUND flag in the UCPD_SR register. uint32_t reserve1 : 2; // 7 Reserve uint32_t rxorddetcf: 1; // 9 Rx ordered set detect flag (RXORDDET) clear Setting the bit clears the RXORDDET flag in the UCPD_SR register. uint32_t rxhrstdetcf: 1; // 10 Rx Hard Reset detect flag (RXHRSTDET) clear Setting the bit clears the RXHRSTDET flag in the UCPD_SR register. uint32_t rxovrcf : 1; // 11 Rx overflow flag (RXOVR) clear Setting the bit clears the RXOVR flag in the UCPD_SR register. uint32_t rxmsgendcf: 1; // 12 Rx message received flag (RXMSGEND) clear Setting the bit clears the RXMSGEND flag in the UCPD_SR register. uint32_t reserve2 : 1; // 13 Reserve uint32_t typecevt1cf: 1; // 14 Type-C CC1 event flag (TYPECEVT1) clear Setting the bit clears the TYPECEVT1 flag in the UCPD_SR register uint32_t typecevt2cf: 1; // 15 Type-C CC2 line event flag (TYPECEVT2) clear Setting the bit clears the TYPECEVT2 flag in the UCPD_SR register uint32_t reserve3 : 4; // 16 Reserve uint32_t frsevtcf : 1; // 20 FRS event flag (FRSEVT) clear Setting the bit clears the FRSEVT flag in the UCPD_SR register. uint32_t reserve4 : 11; // 21 Reserve } reg_ucpd_icr_t; typedef struct { uint32_t txordset : 20; // 0 Ordered set to transmit The bitfield determines a full 20-bit sequence to transmit, consisting of four K-codes, each of five bits, defining the packet to transmit. The bit 0 (bit 0 of K-code1) is the first, the bit 19 (bit 4 of K‑code4) the last. uint32_t reserve0 : 12; // 20 Reserve } reg_ucpd_tx_ordsetr_t; typedef struct { uint32_t txpaysz : 10; // 0 Payload size yet to transmit The bitfield is modified by software and by hardware. It contains the number of bytes of a payload (including header but excluding CRC) yet to transmit: each time a data byte is written into the UCPD_TXDR register, the bitfield value decrements and the TXIS bit is set, except when the bitfield value reaches zero. The enumerated values are standard payload sizes before the start of transmission. uint32_t reserve0 : 22; // 10 Reserve } reg_ucpd_tx_payszr_t; typedef struct { uint32_t txdata : 8; // 0 Data byte to transmit uint32_t reserve0 : 24; // 8 Reserve } reg_ucpd_txdr_t; typedef struct { uint32_t rxordset : 3; // 0 Rx ordered set code detected uint32_t rxsop3of4 : 1; // 3 The bit indicates the number of correct K‑codes. For debug purposes only. uint32_t rxsopkinvalid: 3; // 4 The bitfield is for debug purposes only. Others: Invalid uint32_t reserve0 : 25; // 7 Reserve } reg_ucpd_rx_ordsetr_t; typedef struct { uint32_t rxpaysz : 10; // 0 Rx payload size received This bitfield contains the number of bytes of a payload (including header but excluding CRC) received: each time a new data byte is received in the UCPD_RXDR register, the bitfield value increments and the RXMSGEND flag is set (and an interrupt generated if enabled). The bitfield may return a spurious value when a byte reception is ongoing (the RXMSGEND flag is low). uint32_t reserve0 : 22; // 10 Reserve } reg_ucpd_rx_payszr_t; typedef struct { uint32_t rxdata : 8; // 0 Data byte received uint32_t reserve0 : 24; // 8 Reserve } reg_ucpd_rxdr_t; typedef struct { uint32_t rxsopx1 : 20; // 0 Ordered set 1 received The bitfield contains a full 20-bit sequence received, consisting of four K‑codes, each of five bits. The bit 0 (bit 0 of K‑code1) is receive first, the bit 19 (bit 4 of K‑code4) last. uint32_t reserve0 : 12; // 20 Reserve } reg_ucpd_rx_ordextr1_t; typedef struct { uint32_t rxsopx2 : 20; // 0 Ordered set 2 received The bitfield contains a full 20-bit sequence received, consisting of four K‑codes, each of five bits. The bit 0 (bit 0 of K‑code1) is receive first, the bit 19 (bit 4 of K‑code4) last. uint32_t reserve0 : 12; // 20 Reserve } reg_ucpd_rx_ordextr2_t; typedef struct { volatile reg_ucpd_cfgr1_t cfgr1; volatile reg_ucpd_cfgr2_t cfgr2; volatile reg_ucpd_cfgr3_t cfgr3; volatile reg_ucpd_cr_t cr; volatile reg_ucpd_imr_t imr; volatile reg_ucpd_sr_t sr; volatile reg_ucpd_icr_t icr; volatile reg_ucpd_tx_ordsetr_t tx_ordsetr; volatile reg_ucpd_tx_payszr_t tx_payszr; volatile reg_ucpd_txdr_t txdr; volatile reg_ucpd_rx_ordsetr_t rx_ordsetr; volatile reg_ucpd_rx_payszr_t rx_payszr; volatile reg_ucpd_rxdr_t rxdr; volatile reg_ucpd_rx_ordextr1_t rx_ordextr1; volatile reg_ucpd_rx_ordextr2_t rx_ordextr2; } reg_ucpd_t;