pass event data to usb_acknowledge

add second argument to usb_acknowledge.
it can be used for more appropriate connection tracking that does not
rely on timeout in the future.

Change-Id: I8a44366b7c7a1f944524c4ba8ecd6d9673746a65
This commit is contained in:
mojyack 2026-01-15 16:46:03 +09:00 committed by Solomon Peachy
parent d5506dfa22
commit 1951c17e0b
33 changed files with 54 additions and 46 deletions

View file

@ -470,7 +470,7 @@ void main(void)
case SYS_USB_CONNECTED:
go_active();
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
break;
}
}

View file

@ -123,7 +123,7 @@ static void handle_usb(int connect_timeout)
/* Got the message - wait for disconnect */
printf("Bootloader USB mode");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
while (1)
{

View file

@ -96,7 +96,7 @@ static void usb_mode(int connect_timeout)
adc_init();
/* ack the SYS_USB_CONNECTED polled from the button queue */
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
while(1)
{

View file

@ -129,7 +129,7 @@ static void usb_mode(void)
printf("Bootloader USB mode");
/* Ack the SYS_USB_CONNECTED polled from the button queue */
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
while(1)
{

View file

@ -230,7 +230,7 @@ static int handle_usb(int connect_timeout)
printf("Bootloader USB mode");
usb = USB_HANDLED;
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, ev.data);
#if defined(SANSA_E200) && defined(HAVE_BOOTLOADER_USB_MODE)
/* E200 misses unplug randomly
probably fine for other targets too but needs tested */

View file

@ -75,7 +75,7 @@ static void usb_mode(void)
/* Got the message - wait for disconnect */
show_splash(0, "Bootloader USB mode");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
while (1)
{

View file

@ -196,7 +196,7 @@ static void handle_usb(int connect_timeout)
if (button_get_w_tmo(HZ/2) == SYS_USB_CONNECTED)
{
printf("Bootloader USB mode");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
while (button_get_w_tmo(HZ/2) != SYS_USB_DISCONNECTED)
{
storage_spin();

View file

@ -34,6 +34,7 @@
static bool lcd_inited = false;
extern bool is_usb_connected;
extern intptr_t usb_connection_seqnum;
void clearscreen(void)
{
@ -134,6 +135,7 @@ int get_button(int timeout)
case SYS_USB_CONNECTED:
case SYS_USB_DISCONNECTED:
is_usb_connected = (btn == SYS_USB_CONNECTED);
usb_connection_seqnum = button_get_data();
break;
#ifdef HAVE_SCREENDUMP
case BL_SCREENSHOT:

View file

@ -38,6 +38,7 @@
* Handled by the gui code since that's how events are delivered
* TODO: this is an ugly kludge */
bool is_usb_connected = false;
intptr_t usb_connection_seqnum = 0;
static bool screenshot_enabled = false;
@ -71,7 +72,7 @@ void usb_mode(void)
return;
splashf(0, "USB mode");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, usb_connection_seqnum);
while(is_usb_connected)
get_button(TIMEOUT_BLOCK);

View file

@ -105,7 +105,7 @@ static void usb_mode(void)
/* Got the message - wait for disconnect */
show_splash(0, "Bootloader USB mode");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_acknowledge(SYS_USB_CONNECTED_ACK, button_get_data());
while(1) {
button = button_get_w_tmo(HZ/2);