Skip to content

Commit

Permalink
Adding port swap delay increase to main firmware
Browse files Browse the repository at this point in the history
- For K-Type and Gemini Dusk/Dawn
- For each swap add 1/4 of the delay time
- This should help computers that are slow to recognize USB devices (may
flash the LEDs a few times)
  • Loading branch information
haata committed Dec 7, 2019
1 parent 951d271 commit b748839
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Scan/Devices/PortSwap/port_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void cliFunc_portUSB ( char* args );
// ----- Variables -----

uint32_t Port_lastcheck_ms;
uint32_t Port_attempt;

// GPIOs used for swapping
#if Port_SwapMode_define == USBSwap || Port_SwapMode_define == USBInterSwap
Expand Down Expand Up @@ -185,6 +186,7 @@ inline void Port_setup()

// Starting point for automatic port swapping
Port_lastcheck_ms = systick_millis_count;
Port_attempt = 0;

// Allocate latency measurement resource
portLatencyResource = Latency_add_resource("PortSwap", LatencyOption_Ticks);
Expand All @@ -202,7 +204,7 @@ inline uint8_t Port_scan()
// Wait 1000 ms before checking
// Only check for swapping after delay
uint32_t wait_ms = systick_millis_count - Port_lastcheck_ms;
if ( wait_ms > USBPortSwapDelay_ms )
if ( wait_ms > USBPortSwapDelay_ms + Port_attempt * USBPortSwapDelay_ms / 4 )
{
// Update timeout
Port_lastcheck_ms = systick_millis_count;
Expand All @@ -211,6 +213,7 @@ inline uint8_t Port_scan()
if ( !usb_configured() )
{
Port_usb_swap();
Port_attempt++;
}
}

Expand Down

0 comments on commit b748839

Please sign in to comment.