Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ static void control_write(const uint16_t pio, const uint8_t byte, bool poke) {
control.readBatteryStatus = control.setBatteryStatus == BATTERY_DISCHARGED ? 0 : byte & 0x80 ? 0 : 3;
break;
}
/*
* The comparator inputs remain enabled after the battery-level sequence configures port 7.
* TI-OS's USB power check reuses that configuration and only selects the high threshold through
* ports 0 and 9, so update the comparator even without another port 7 write.
*/
if (!control.readBatteryStatus && control.setBatteryStatus != BATTERY_DISCHARGED &&
(control.ports[7] & 0x90) && (control.ports[0] & 0x80) && (byte & 0xA0) == 0xA0) {
control.readBatteryStatus = 1;
}
if ((control.ports[index] & ~byte) >> 2 & 1) {
panel_hw_reset();
}
Expand Down
14 changes: 14 additions & 0 deletions core/usb/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ typedef enum usb_event_type {
USB_INIT_EVENT,
USB_POWER_EVENT,
USB_RESET_EVENT,
USB_SESSION_START_EVENT,
USB_SESSION_END_EVENT,
USB_SESSION_REQUEST_EVENT,
USB_HNP_EVENT,
USB_ROLE_SWITCH_EVENT,
USB_ROLE_SWITCH_READY_EVENT,
USB_ROLE_RESTORE_REQUEST_EVENT,
USB_ROLE_RESTORE_EVENT,
USB_ROLE_RESTORE_READY_EVENT,
USB_TRANSFER_REQUEST_EVENT,
USB_TRANSFER_RESPONSE_EVENT,
USB_TIMER_EVENT,
Expand Down Expand Up @@ -72,6 +81,11 @@ typedef struct usb_event {
usb_progress_handler_t *progress_handler;
void *progress_context, *context;
bool host : 1;
/* Set by an asynchronous peer backend for the current dispatch only. */
bool deferred : 1;
/* Set during initialization by backends which coordinate OTG HNP. */
bool supports_hnp : 1;
bool pending : 1;
uint8_t speed : 2; /* usb_speed_t */
usb_event_type_t type;
union {
Expand Down
3 changes: 3 additions & 0 deletions core/usb/dusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,9 @@ int usb_dusb_device(usb_event_t *event) {
}
event->context = context;
break;
case USB_SESSION_REQUEST_EVENT:
event->type = USB_SESSION_START_EVENT;
return USB_SUCCESS;
case USB_TRANSFER_REQUEST_EVENT:
case USB_TRANSFER_RESPONSE_EVENT:
command = context->command;
Expand Down
3 changes: 3 additions & 0 deletions core/usb/msd.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ int usb_msd_device(usb_event_t *event) {
context->address = 0;
context->configured = false;
break;
case USB_SESSION_START_EVENT:
case USB_SESSION_END_EVENT:
break;
case USB_TRANSFER_REQUEST_EVENT:
event->type = USB_TRANSFER_RESPONSE_EVENT;
if (transfer->address != context->address ||
Expand Down
Loading
Loading