Skip to content

Commit

Permalink
v2: default to ask for power (sink mode) unless source attached
Browse files Browse the repository at this point in the history
  • Loading branch information
greenaddress authored and JamieDriver committed Nov 1, 2024
1 parent ecfe49c commit c1756ff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main/power/jadev20.inc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void usb_detection_task(void* param)
if (usb_type == SGM7220_REG_TYPE_SOURCE) {
// set to source mode
I2C_LOG_ANY_ERROR(_power_write_command(PMIC_ADDR, PMIC_REG_OTG, 0x01));
} else if (usb_type == SGM7220_REG_TYPE_SINK) {
} else {
// set to sink mode
I2C_LOG_ANY_ERROR(_power_write_command(PMIC_ADDR, PMIC_REG_OTG, 0x00));
}
Expand Down Expand Up @@ -121,6 +121,9 @@ esp_err_t power_init(void)
I2C_LOG_ANY_ERROR(_power_master_read_slave(PMIC_ADDR, PMIC_REG_FW_VERSION, &data, 1));
JADE_LOGI("PMIC fw version: %u", data);

// set to sink mode by default
I2C_LOG_ANY_ERROR(_power_write_command(PMIC_ADDR, PMIC_REG_OTG, 0x00));

// Do usb detection for power boost
gpio_set_intr_type(USB_INT_PIN, GPIO_INTR_NEGEDGE);
I2C_CHECK_RET(gpio_install_isr_service(0));
Expand Down Expand Up @@ -297,7 +300,7 @@ bool usb_connected(void)
I2C_LOG_ANY_ERROR(_power_write_command(SGM7220_ADDR, SGM7220_REG_TYPE, (usb_type | (0x1 << 4))));
JADE_SEMAPHORE_GIVE(i2c_mutex);

// Check we are connected to a usb sink
// Check we are connected as a usb sink
usb_type >>= SGM7220_REG_TYPE_SHIFT;
return usb_type == SGM7220_REG_TYPE_SINK;
#else
Expand Down

0 comments on commit c1756ff

Please sign in to comment.