#ifndef USB2517_H_ #define USB2517_H_ // Device Address #define USB2517_I2C_ADDR (0x58u) // For use with UNSHIFTED address type, 0b0101.100W, where W is the read/write bit // Register Addresses #define USB2517_REG_VID_LSB (0x00u) // Vendor ID, least significant byte #define USB2517_REG_VID_MSB (0x01u) // Vendor ID, most significant byte #define USB2517_REG_PID_LSB (0x02u) // Product ID #define USB2517_REG_PID_MSB (0x03u) // Product ID #define USB2517_REG_DID_LSB (0x04u) // Device ID #define USB2517_REG_DID_MSB (0x05u) // Device ID #define USB2517_REG_CFG1 (0x06u) // Config Byte 1 #define USB2517_REG_CFG2 (0x07u) // Config Byte 2 #define USB2517_REG_CFG3 (0x08u) // Config Byte 3 #define USB2517_REG_NONREMOVDEV (0x09u) // Non removable devices #define USB2517_REG_PORTDIS_SELF (0x0Au) // Port disable in self-powered configuration #define USB2517_REG_PORTDIS_BUS (0x0Bu) // Port disable in bus-powered #define USB2517_REG_MAX_POWER_SELF (0x0Cu) // Maximum power (mA) in self-powered #define USB2517_REG_MAX_POWER_BUS (0x0Du) // Max power in bus-powered #define USB2517_REG_MAX_CURR_SELF (0x0Eu) // Hub controller max current (mA) in self-powered #define USB2517_REG_MAX_CURR_BUS (0x0Fu) // Hub controller max current in bus-powered #define USB2517_REG_POWER_ON_TIME (0x10u) // Length of time between power-on sequence and power is stable #define USB2517_REG_LANG_ID_H (0x11u) // USB language ID high byte #define USB2517_REG_LANG_ID_L (0x12u) // Language low byte #define USB2517_REG_MFR_STR_LEN (0x13u) // Length of manufacturer string in bytes (maximum 31 characters / 62 bytes) #define USB2517_REG_PRD_STR_LEN (0x14u) // Length of product string in bytes (maximum 31 characters) #define USB2517_REG_SER_STR_LEN (0x15u) // Length of serial string in bytes (maximum 31 characters) // Strings. These are starting addresses of the string memory #define USB2517_REG_MFR_STR (0x16u) // Stored in Unicode UTF-16LE. LSB first. #define USB2517_REG_PRD_STR (0x54u) #define USB2517_REG_SER_STR (0x92u) // More single byte registers #define USB2517_REG_BOOST_UP (0xF6u) // Signal drive boost strength for upstream port #define USB2517_REG_BOOST_7_5 (0xF7u) // boost strength for downstream 5, 6, and 7 #define USB2517_REG_BOOST_4_0 (0xF8u) // boost strength for downstream 1, 2, 3, and 4 #define USB2517_REG_PORT_SWAP (0xFAu) // Swap D+/D- pins of any port (upstream / 7x downstream) #define USB2517_REG_PORT_REMAP_12 (0xFBu) // Mapping logical ports (1-7) to physical ports 1 and 2 #define USB2517_REG_PORT_REMAP_34 (0xFCu) // Mapping logical ports (1-7) to physical ports 3 and 4 #define USB2517_REG_PORT_REMAP_56 (0xFDu) // Mapping logical ports (1-7) to physical ports 5 and 6 #define USB2517_REG_PORT_REMAP_7 (0xFEu) // Mapping logical ports (1-7) to physical port 7 #define USB2517_REG_STATUS_CMD (0xFFu) // Power down SMBUS, register reset, and USB attach (which locks 0x00-0xFE) // Bit definitions #define USB2517_CFG1_PORT_PWR (0x01u) // 0-ganged power switching, 1-individual port by port switching #define USB2517_CFG1_CURRENT_SENS_GANGED (0x00u) // All ports sensed together #define USB2517_CFG1_CURRENT_SENS_INDIV (0x02u) // Individual port current sensing #define USB2517_CFG1_CURRENT_SENS_DISABLE (0x06u) // Port current sensing disabled #define USB2517_CFG1_EOP_DISABLE (0x08u) // 0-EOP generation is normal, 1-EOP disabled in FS for EOF1 #define USB2517_CFG1_MTT_ENABLE (0x10u) // 0-single TT for all ports, 1-multi TT, one per port #define USB2517_CFG1_HS_DISABLE (0x20u) // 0-High/Full speed, 1-Full speed only #define USB2517_CFG1_SELF_BUS_PWR (0x80u) // 0-Bus-powered, 1-Self-powered #define USB2517_CFG2_COMPOUND (0x08u) // 0-not a compound device, 1-compound device, non-removable must be defined too #define USB2517_CFG2_OC_TIMER_0_1ms (0x00u) // overcurrent timer delay = 0.1ms #define USB2517_CFG2_OC_TIMER_4ms (0x10u) // overcurrent timer delay = 4ms #define USB2517_CFG2_OC_TIMER_8ms (0x20u) // overcurrent timer delay = 8ms #define USB2517_CFG2_OC_TIMER_16ms (0x30u) // overcurrent timer delay = 16ms #define USB2517_CFG2_DYNAMIC (0x80u) // 0-no dynamic switching, set by CFG1 SELF BUS PWR, 1-dynamic switching, set by LOCAL_PWR pin #define USB2517_CFG3_STRING_EN (0x01u) // 0-no strings in descriptors, 1-string support enabled #define USB2517_CFG3_LED_MODE_USB (0x00u) // LED pins in USB mode (also 0x04, 0x06 will set the same as USB mode) #define USB2517_CFG3_LED_MODE_SPEED (0x02u) // LED pins in Speed indication mode #define USB2517_CFG3_PRTMAP_EN (0x08u) // 0-standard mode, 1-port remap mode // For registers 0x09-0x0B (Non-removable devices, port disable self-powered, port disable bus-powered), // bits 1-7 correspond to ports 1-7. Bit 0 is reserved. // Boost settings in registers 0xF6, 0xF7, 0xF8 #define USB2517_BOOST_DRIVE_NORMAL (0x00u) // No boost #define USB2517_BOOST_DRIVE_LOW (0x01u) // Approx 4% boost #define USB2517_BOOST_DRIVE_MEDIUM (0x02u) // 8% boost #define USB2517_BOOST_DRIVE_HIGH (0x03u) // 12% boost #define USB2517_BOOST_UP(boost_amt) ((boost_amt) << 0u) // Reg 0xF6, bits 1:0 #define USB2517_BOOST_7(boost_amt) ((boost_amt) << 4u) // Reg 0xF7, bits 5:4 #define USB2517_BOOST_6(boost_amt) ((boost_amt) << 2u) // Reg 0xF7, bits 3:2 #define USB2517_BOOST_5(boost_amt) ((boost_amt) << 0u) // Reg 0xF7, bits 1:0 #define USB2517_BOOST_4(boost_amt) ((boost_amt) << 6u) // Reg 0xF8, bits 7:6 #define USB2517_BOOST_3(boost_amt) ((boost_amt) << 4u) // Reg 0xF8, bits 5:4 #define USB2517_BOOST_2(boost_amt) ((boost_amt) << 2u) // Reg 0xF8, bits 3:2 #define USB2517_BOOST_1(boost_amt) ((boost_amt) << 0u) // Reg 0xF8, bits 1:0 // Reg 0xFA, Port swap: bits 1-7 are downstream ports 1-7, bit 0 is upstream port. // Setting 0- no swap of DP/DM. 1- Swap DP/DM. // Logical ports are allowed to be 1 through 7. Setting logical port=0 or >7 disables the physical port #define USB2517_REMAP_2(logical_port) ((logical_port) << 4u) // Reg 0xFB, bits 7:4 #define USB2517_REMAP_1(logical_port) ((logical_port) << 0u) // Reg 0xFB, bits 3:0 #define USB2517_REMAP_4(logical_port) ((logical_port) << 4u) // Reg 0xFC, bits 7:4 #define USB2517_REMAP_3(logical_port) ((logical_port) << 0u) // Reg 0xFC, bits 3:0 #define USB2517_REMAP_6(logical_port) ((logical_port) << 4u) // Reg 0xFD, bits 7:4 #define USB2517_REMAP_5(logical_port) ((logical_port) << 0u) // Reg 0xFD, bits 3:0 #define USB2517_REMAP_7(logical_port) ((logical_port) << 4u) // Reg 0xFE, bits 7:4 #define USB2517_STATUS_USB_ATTACH (0x01u) // After setting 1, hub will attach to an upstream host and lock registers 0x00 - 0xFE #define USB2517_STATUS_RESET (0x02u) // 1 will reset all registers to default state #define USB2517_STATUS_INF_PW_DN (0x04u) // 1 will disable the SMbus interface after the ACK completes for this write cycle uint8_t usb2517_init(I2C_Handle* hi2c); bool usb2517_is_initialized(void); bool usb2517_check_if_present(I2C_Handle* hi2c); #endif // USB2517_H_