CAT2 Peripheral Driver Library

Macros

#define CY_USBPD_GET_MAX(a, b)   (((a) > (b)) ? (a) : (b))
 Get the maximum from among two numbers. More...
 
#define CY_USBPD_GET_MIN(a, b)   (((a) > (b)) ? (b) : (a))
 Get the minimum from among two numbers. More...
 
#define CY_USBPD_DIV_ROUND_UP(x, y)   (((x) + ((y) - 1)) / (y))
 Integer division - round up to next integer. More...
 
#define CY_USBPD_DIV_ROUND_NEAREST(x, y)   (((x) + ((y) / 2u)) / (y))
 Integer division - round to nearest integer. More...
 
#define CY_USBPD_MAKE_WORD(hi, lo)   (((uint16_t)(hi) << 8) | ((uint16_t)(lo)))
 Combine two bytes to create one 16-bit WORD. More...
 
#define CY_USBPD_MAKE_DWORD(b3, b2, b1, b0)
 Combine four bytes to create one 32-bit DWORD. More...
 
#define CY_USBPD_MAKE_DWORD_FROM_WORD(hi, lo)   (((uint32_t)(hi) << 16) | ((uint32_t)(lo)))
 Combine two WORDs to create one DWORD. More...
 
#define CY_USBPD_WORD_GET_MSB(w)   ((uint8_t)((w) >> 8))
 Retrieve the MSB from a WORD. More...
 
#define CY_USBPD_WORD_GET_LSB(w)   ((uint8_t)((w) & 0xFF))
 Retrieve the LSB from a WORD. More...
 
#define CY_USBPD_BYTE_GET_UPPER_NIBBLE(w)   ((uint8_t)(((w) >> 4) & 0xF))
 Retrieve the Upper nibble from a BYTE. More...
 
#define CY_USBPD_BYTE_GET_LOWER_NIBBLE(w)   ((uint8_t)((w) & 0xF))
 Retrieve the Lower nibble from a BYTE. More...
 
#define CY_USBPD_DWORD_GET_BYTE0(dw)   ((uint8_t)((dw) & 0xFFUL))
 Retrieve the LSB from a DWORD. More...
 
#define CY_USBPD_DWORD_GET_BYTE1(dw)   ((uint8_t)(((dw) >> 8) & 0xFFUL))
 Retrieve the bits 15-8 from a DWORD. More...
 
#define CY_USBPD_DWORD_GET_BYTE2(dw)   ((uint8_t)(((dw) >> 16) & 0xFFUL))
 Retrieve the bits 23-16 from a DWORD. More...
 
#define CY_USBPD_DWORD_GET_BYTE3(dw)   ((uint8_t)(((dw) >> 24) & 0xFFUL))
 Retrieve the MSB from a DWORD. More...
 
#define CCG_FLASH_ROW_SHIFT_NUM   (6u)
 Flash row shift number. More...
 
#define CY_USBPD_REV_BYTE_ORDER(b, i)
 Macro to combine 4 bytes in reverse order to make a 32-bit integer. More...
 
#define CY_USBPD_REG_FIELD_UPDATE(reg, field, value)   ((reg) = (((reg) & ~(field##_MASK)) | ((value) << (field##_POS))))
 Update a single field in a register. More...
 
#define CY_USBPD_REG_FIELD_UPDATE_MTB(reg, field, value)   ((reg) = (((reg) & ~(field##_Msk)) | ((value) << (field##_Pos))))
 Update a single field in a register. More...
 
#define CY_USBPD_REG_FIELD_GET(reg, field)   (((reg) & field##_MASK) >> field##_POS)
 Retrieve a specific field from a register. More...
 
#define LSCSA_DEF_RSENSE_P0   (50u)
 Default RSENSE value is 5mOhm. More...
 
#define LSCSA_DEF_RSENSE_P1   (50u)
 Default RSENSE value is 5mOhm. More...
 
#define CY_PD_VSAFE_5V_FRS_SWAP_RX_MARGIN   (10)
 VSafe5V margin for Fast Role Swap. More...
 
#define TYPEC_PORT_0_IDX   (0u)
 USB-C port number 0. More...
 
#define TYPEC_PORT_1_IDX   (1u)
 USB-C port number 1. More...
 
#define NO_OF_TYPEC_PORTS   (1u)
 CYPD8229_52LQXI part and CYPD8229_52LQXIT part has the same silicon ID. More...
 
#define PMG1_PD_DUALPORT_ENABLE   (0u)
 Single USB-C port supported. More...
 
#define CY_PD_MAX_EXTD_PKT_WORDS   (65u)
 Maximum extended message 32-bit words. More...
 
#define CY_PD_VSAFE_0V   (800u)
 Vbus voltage = 0.8 V.
 
#define CY_PD_VSAFE_3_6V   (3600u)
 Vbus voltage = 3.6 V.
 
#define CY_PD_VSAFE_5V   (5000u)
 Vbus voltage = 5.0 V.
 
#define CY_PD_VSAFE_9V   (9000u)
 Vbus voltage = 9.0 V.
 
#define CY_PD_VSAFE_12V   (12000u)
 Vbus voltage = 12.0 V.
 
#define CY_PD_VSAFE_13V   (13000u)
 Vbus voltage = 13.0 V.
 
#define CY_PD_VSAFE_15V   (15000u)
 Vbus voltage = 15.0 V.
 
#define CY_PD_VSAFE_19V   (19000u)
 Vbus voltage = 19.0 V.
 
#define CY_PD_VSAFE_20V   (20000u)
 Vbus voltage = 20.0 V.
 
#define CY_PD_VSAFE_28V   (28000u)
 Vbus voltage = 28.0 V.
 
#define CY_PD_VSAFE_36V   (36000u)
 Vbus voltage = 36.0 V.
 
#define CY_PD_VSAFE_48V   (48000u)
 Vbus voltage = 48.0 V.
 
#define CY_PD_EPR_MIN_WATT   (100u)
 PDP 100 W.
 
#define CY_PD_EPR_MAX_28V_WATT   (140u)
 PDP 140 W.
 
#define CY_PD_EPR_MAX_36V_WATT   (180u)
 PDP 180 W.
 
#define CY_PD_EPR_MAX_48V_WATT   (240u)
 PDP 240 W.
 
#define ROUND_UP(x, y)   ( ( ( (x) + ((y) - 1) ) / y ) * y)
 Round Up.
 
#define ROUND_DOWN(x, y)   ( ( (x) / y ) * y)
 Round Down.
 
#define CY_PD_CC_CHANNEL_1   (0u)
 Reference to CC_1 pin in the Type-C connector. More...
 
#define CY_PD_CC_CHANNEL_2   (1u)
 Reference to CC_2 pin in the Type-C connector. More...
 
#define CY_PD_DR_PR_ROLE(dataRole, pwrRole)   (((pwrRole) << 8) | ((dataRole) << 5))
 Macro to update DR and PR role in PD header. More...
 

Detailed Description

Macro Definition Documentation

◆ CY_USBPD_GET_MAX

#define CY_USBPD_GET_MAX (   a,
 
)    (((a) > (b)) ? (a) : (b))

Get the maximum from among two numbers.

◆ CY_USBPD_GET_MIN

#define CY_USBPD_GET_MIN (   a,
 
)    (((a) > (b)) ? (b) : (a))

Get the minimum from among two numbers.

◆ CY_USBPD_DIV_ROUND_UP

#define CY_USBPD_DIV_ROUND_UP (   x,
 
)    (((x) + ((y) - 1)) / (y))

Integer division - round up to next integer.

◆ CY_USBPD_DIV_ROUND_NEAREST

#define CY_USBPD_DIV_ROUND_NEAREST (   x,
 
)    (((x) + ((y) / 2u)) / (y))

Integer division - round to nearest integer.

◆ CY_USBPD_MAKE_WORD

#define CY_USBPD_MAKE_WORD (   hi,
  lo 
)    (((uint16_t)(hi) << 8) | ((uint16_t)(lo)))

Combine two bytes to create one 16-bit WORD.

◆ CY_USBPD_MAKE_DWORD

#define CY_USBPD_MAKE_DWORD (   b3,
  b2,
  b1,
  b0 
)
Value:
(((uint32_t)(b3) << 24) | ((uint32_t)(b2) << 16) | \
((uint32_t)(b1) << 8) | ((uint32_t)(b0)))

Combine four bytes to create one 32-bit DWORD.

◆ CY_USBPD_MAKE_DWORD_FROM_WORD

#define CY_USBPD_MAKE_DWORD_FROM_WORD (   hi,
  lo 
)    (((uint32_t)(hi) << 16) | ((uint32_t)(lo)))

Combine two WORDs to create one DWORD.

◆ CY_USBPD_WORD_GET_MSB

#define CY_USBPD_WORD_GET_MSB (   w)    ((uint8_t)((w) >> 8))

Retrieve the MSB from a WORD.

◆ CY_USBPD_WORD_GET_LSB

#define CY_USBPD_WORD_GET_LSB (   w)    ((uint8_t)((w) & 0xFF))

Retrieve the LSB from a WORD.

◆ CY_USBPD_BYTE_GET_UPPER_NIBBLE

#define CY_USBPD_BYTE_GET_UPPER_NIBBLE (   w)    ((uint8_t)(((w) >> 4) & 0xF))

Retrieve the Upper nibble from a BYTE.

◆ CY_USBPD_BYTE_GET_LOWER_NIBBLE

#define CY_USBPD_BYTE_GET_LOWER_NIBBLE (   w)    ((uint8_t)((w) & 0xF))

Retrieve the Lower nibble from a BYTE.

◆ CY_USBPD_DWORD_GET_BYTE0

#define CY_USBPD_DWORD_GET_BYTE0 (   dw)    ((uint8_t)((dw) & 0xFFUL))

Retrieve the LSB from a DWORD.

◆ CY_USBPD_DWORD_GET_BYTE1

#define CY_USBPD_DWORD_GET_BYTE1 (   dw)    ((uint8_t)(((dw) >> 8) & 0xFFUL))

Retrieve the bits 15-8 from a DWORD.

◆ CY_USBPD_DWORD_GET_BYTE2

#define CY_USBPD_DWORD_GET_BYTE2 (   dw)    ((uint8_t)(((dw) >> 16) & 0xFFUL))

Retrieve the bits 23-16 from a DWORD.

◆ CY_USBPD_DWORD_GET_BYTE3

#define CY_USBPD_DWORD_GET_BYTE3 (   dw)    ((uint8_t)(((dw) >> 24) & 0xFFUL))

Retrieve the MSB from a DWORD.

◆ CCG_FLASH_ROW_SHIFT_NUM

#define CCG_FLASH_ROW_SHIFT_NUM   (6u)

Flash row shift number.

◆ CY_USBPD_REV_BYTE_ORDER

#define CY_USBPD_REV_BYTE_ORDER (   b,
 
)
Value:
( (uint32_t) (b)[(i) ] << 24 ) \
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
| ( (uint32_t) (b)[(i) + 3] ); \

Macro to combine 4 bytes in reverse order to make a 32-bit integer.

Parameters
bInput array of bytes to be combined.
iIndex into the input byte array.

◆ CY_USBPD_REG_FIELD_UPDATE

#define CY_USBPD_REG_FIELD_UPDATE (   reg,
  field,
  value 
)    ((reg) = (((reg) & ~(field##_MASK)) | ((value) << (field##_POS))))

Update a single field in a register.

It first clears the field and then updates the data.

◆ CY_USBPD_REG_FIELD_UPDATE_MTB

#define CY_USBPD_REG_FIELD_UPDATE_MTB (   reg,
  field,
  value 
)    ((reg) = (((reg) & ~(field##_Msk)) | ((value) << (field##_Pos))))

Update a single field in a register.

It first clears the field and then updates the data.

◆ CY_USBPD_REG_FIELD_GET

#define CY_USBPD_REG_FIELD_GET (   reg,
  field 
)    (((reg) & field##_MASK) >> field##_POS)

Retrieve a specific field from a register.

◆ LSCSA_DEF_RSENSE_P0

#define LSCSA_DEF_RSENSE_P0   (50u)

Default RSENSE value is 5mOhm.

◆ LSCSA_DEF_RSENSE_P1

#define LSCSA_DEF_RSENSE_P1   (50u)

Default RSENSE value is 5mOhm.

◆ CY_PD_VSAFE_5V_FRS_SWAP_RX_MARGIN

#define CY_PD_VSAFE_5V_FRS_SWAP_RX_MARGIN   (10)

VSafe5V margin for Fast Role Swap.

◆ TYPEC_PORT_0_IDX

#define TYPEC_PORT_0_IDX   (0u)

USB-C port number 0.

Supported on all PMG1/CCGx devices.

◆ TYPEC_PORT_1_IDX

#define TYPEC_PORT_1_IDX   (1u)

USB-C port number 1.

Supported only on the Dual Port devices.

◆ NO_OF_TYPEC_PORTS

#define NO_OF_TYPEC_PORTS   (1u)

CYPD8229_52LQXI part and CYPD8229_52LQXIT part has the same silicon ID.

Single USB-C port supported.

◆ PMG1_PD_DUALPORT_ENABLE

#define PMG1_PD_DUALPORT_ENABLE   (0u)

Single USB-C port supported.

◆ CY_PD_MAX_EXTD_PKT_WORDS

#define CY_PD_MAX_EXTD_PKT_WORDS   (65u)

Maximum extended message 32-bit words.

Each word is 32 bit.

◆ CY_PD_CC_CHANNEL_1

#define CY_PD_CC_CHANNEL_1   (0u)

Reference to CC_1 pin in the Type-C connector.

◆ CY_PD_CC_CHANNEL_2

#define CY_PD_CC_CHANNEL_2   (1u)

Reference to CC_2 pin in the Type-C connector.

◆ CY_PD_DR_PR_ROLE

#define CY_PD_DR_PR_ROLE (   dataRole,
  pwrRole 
)    (((pwrRole) << 8) | ((dataRole) << 5))

Macro to update DR and PR role in PD header.