Skip to content

Changed VBUS pin en handling #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions libraries/Portenta_Video/anx7625.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//#include <device/i2c_simple.h>
#include <Arduino.h>
#include <drivers/DigitalOut.h>
#include <drivers/DigitalInOut.h>
//#include <gpio.h>
//#include <timer.h>
#include <string.h>
Expand All @@ -33,9 +34,9 @@
#define ANXDEBUG(format, ...) \
printk(BIOS_DEBUG, "%s: " format, __func__, ##__VA_ARGS__)

mbed::DigitalOut video_on(PK_2);
mbed::DigitalOut video_rst(PJ_3);
mbed::DigitalOut otg_on(PJ_6);
mbed::DigitalOut video_on(PK_2, 0);
mbed::DigitalOut video_rst(PJ_3, 0);
mbed::DigitalInOut otg_on(PJ_6, PIN_INPUT, PullUp, 0);
mbed::I2C i2cx(I2C_SDA_INTERNAL , I2C_SCL_INTERNAL);

int i2c_writeb(uint8_t bus, uint8_t saddr, uint8_t offset, uint8_t val) {
Expand Down Expand Up @@ -1318,24 +1319,20 @@ int anx7625_init(uint8_t bus)
int retry_power_on = 3;

ANXINFO("OTG_ON = 1 -> VBUS OFF\n");
otg_on = 1;
if (otg_on != 0) {
otg_on.output();
otg_on = 1;
} else {
ANXERROR("Cannot disable VBUS, someone is actively driving OTG_ON (PJ_6, USB_HS ID Pin)\n");
}
mdelay(1000); // @TODO: wait for VBUS to discharge (VBUS is activated during bootloader, can be removed when fixed)

mdelay(1000);
ANXINFO("Powering on anx7625...\n");
video_on = 1;
mdelay(10);
video_rst = 1;
mdelay(10);

video_on = 0;
mdelay(10);
video_rst = 0;
mdelay(100);

ANXINFO("Powering on anx7625...\n");
video_on = 1;
mdelay(100);
video_rst = 1;

while (--retry_power_on) {
if (anx7625_power_on_init(bus) == 0)
break;
Expand All @@ -1349,7 +1346,7 @@ int anx7625_init(uint8_t bus)

if(anx7625_is_power_provider(0)) {
ANXINFO("OTG_ON = 0 -> VBUS ON\n");
otg_on = 0;
otg_on = 0; // If the pin is still input this has not effect
mdelay(1000); // Wait for powered device to be stable
}

Expand Down Expand Up @@ -1391,7 +1388,7 @@ int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status)
default:
ANXDEBUG("anx: CC1: Reserved\n");
}
switch (*cc_status & 0xF0) {
switch ((*cc_status >> 4) & 0x0F) {
case 0:
ANXDEBUG("anx: CC2: SRC.Open\n"); break;
case 1:
Expand Down