#ifndef USB3803_H_
#define USB3803_H_

typedef enum {
	USB_HUB_1,
	USB_HUB_2
} HUB_Select_T;

// Device Address
#define USB3803_I2C_ADDR    (0x10u) // For use with UNSHIFTED address type, 0b0001.000W, where W is the read/write bit
#define USB3803_2ND_I2C_ADDR	(0x12u) // second USB3803 hub on the board has a different address

// Register Addresses
#define USB3803_SP_ILOCK (0xE7u) // Serial port interlock
#define USB3803_CFG1 (0x06u) // Config 1, controls bus vs self powered
#define USB3803_MAXPS (0x0Cu) // max power (self)
#define USB3803_MAXPB (0x0Du) // max power (bus)
#define USB3803_HCMCS (0x0Eu) // hub controller max current (self)
#define USB3803_HCMCB (0x0Fu) // hub controller max current (bus)
#define USB3803_BOOST_UP3	(0xF6u) // Sets signaling boost strength (for 480Mbps only) for upstream port and downstream port 3
#define USB3803_BOOST_21	(0xF8u) // Sets signaling boost strength (for 480Mbps only) for downstream ports 2 and 1

// Register bit defines
#define USB3803_ILOCK_CONFIG    (0x01u) // set to halt in configuration stage, clear to resume
#define USB3803_CFG1_SELFBUS    (0x80u) // set for self powered, clear for bus powered
#define USB3803_BOOST_NONE					(0x00u) // Signaling strength is default (no boost)
#define USB3803_BOOST_MINUS_5_PCT			(0x01u) // USB 2.0 signaling current reduced by 5%
#define USB3803_BOOST_10_PCT				(0x02u)	// USB 2.0 signaling current increased by 10%
#define USB3803_BOOST_5_PCT					(0x03u) // and...
#define USB3803_BOOST_20_PCT				(0x04u) // so...
#define USB3803_BOOST_15_PCT				(0x05u) // on...
#define USB3803_BOOST_30_PCT				(0x06u) // ...
#define USB3803_BOOST_25_PCT				(0x07u) // ...

uint8_t usb3803_init(I2C_Handle* hi2c);
bool usb3803_is_initialized(HUB_Select_T hubsel);


#endif // USB3803_H_
