Skip to content

Commit c1756ff

Browse files
Lawrence NahumJamie C. Driver
authored andcommitted
v2: default to ask for power (sink mode) unless source attached
1 parent ecfe49c commit c1756ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main/power/jadev20.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void usb_detection_task(void* param)
8282
if (usb_type == SGM7220_REG_TYPE_SOURCE) {
8383
// set to source mode
8484
I2C_LOG_ANY_ERROR(_power_write_command(PMIC_ADDR, PMIC_REG_OTG, 0x01));
85-
} else if (usb_type == SGM7220_REG_TYPE_SINK) {
85+
} else {
8686
// set to sink mode
8787
I2C_LOG_ANY_ERROR(_power_write_command(PMIC_ADDR, PMIC_REG_OTG, 0x00));
8888
}
@@ -121,6 +121,9 @@ esp_err_t power_init(void)
121121
I2C_LOG_ANY_ERROR(_power_master_read_slave(PMIC_ADDR, PMIC_REG_FW_VERSION, &data, 1));
122122
JADE_LOGI("PMIC fw version: %u", data);
123123

124+
// set to sink mode by default
125+
I2C_LOG_ANY_ERROR(_power_write_command(PMIC_ADDR, PMIC_REG_OTG, 0x00));
126+
124127
// Do usb detection for power boost
125128
gpio_set_intr_type(USB_INT_PIN, GPIO_INTR_NEGEDGE);
126129
I2C_CHECK_RET(gpio_install_isr_service(0));
@@ -297,7 +300,7 @@ bool usb_connected(void)
297300
I2C_LOG_ANY_ERROR(_power_write_command(SGM7220_ADDR, SGM7220_REG_TYPE, (usb_type | (0x1 << 4))));
298301
JADE_SEMAPHORE_GIVE(i2c_mutex);
299302

300-
// Check we are connected to a usb sink
303+
// Check we are connected as a usb sink
301304
usb_type >>= SGM7220_REG_TYPE_SHIFT;
302305
return usb_type == SGM7220_REG_TYPE_SINK;
303306
#else

0 commit comments

Comments
 (0)