@@ -82,7 +82,7 @@ void usb_detection_task(void* param)
82
82
if (usb_type == SGM7220_REG_TYPE_SOURCE) {
83
83
// set to source mode
84
84
I2C_LOG_ANY_ERROR (_power_write_command (PMIC_ADDR, PMIC_REG_OTG, 0x01 ));
85
- } else if (usb_type == SGM7220_REG_TYPE_SINK) {
85
+ } else {
86
86
// set to sink mode
87
87
I2C_LOG_ANY_ERROR (_power_write_command (PMIC_ADDR, PMIC_REG_OTG, 0x00 ));
88
88
}
@@ -121,6 +121,9 @@ esp_err_t power_init(void)
121
121
I2C_LOG_ANY_ERROR (_power_master_read_slave (PMIC_ADDR, PMIC_REG_FW_VERSION, &data, 1 ));
122
122
JADE_LOGI (" PMIC fw version: %u" , data);
123
123
124
+ // set to sink mode by default
125
+ I2C_LOG_ANY_ERROR (_power_write_command (PMIC_ADDR, PMIC_REG_OTG, 0x00 ));
126
+
124
127
// Do usb detection for power boost
125
128
gpio_set_intr_type (USB_INT_PIN, GPIO_INTR_NEGEDGE);
126
129
I2C_CHECK_RET (gpio_install_isr_service (0 ));
@@ -297,7 +300,7 @@ bool usb_connected(void)
297
300
I2C_LOG_ANY_ERROR (_power_write_command (SGM7220_ADDR, SGM7220_REG_TYPE, (usb_type | (0x1 << 4 ))));
298
301
JADE_SEMAPHORE_GIVE (i2c_mutex);
299
302
300
- // Check we are connected to a usb sink
303
+ // Check we are connected as a usb sink
301
304
usb_type >>= SGM7220_REG_TYPE_SHIFT;
302
305
return usb_type == SGM7220_REG_TYPE_SINK;
303
306
#else
0 commit comments