From ac96eed5dd084a69e06c1b59351dea413ff95eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 27 Mar 2018 14:38:31 +0200 Subject: [PATCH] [usb] Default poll timeout of 1ms for GetStatus. Change-Id: Ic25219d04ea3c5d0a3c84872da2a94aae4342b32 --- ion/src/device/usb/dfu_interface.cpp | 2 +- ion/src/device/usb/dfu_interface.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ion/src/device/usb/dfu_interface.cpp b/ion/src/device/usb/dfu_interface.cpp index af4e8cdeb..44d7fbefd 100644 --- a/ion/src/device/usb/dfu_interface.cpp +++ b/ion/src/device/usb/dfu_interface.cpp @@ -55,7 +55,7 @@ bool DFUInterface::getStatus(SetupPacket * request, uint8_t * transferBuffer, ui actionsAfterStatus = true; } // Copy the status on the TxFifo - *transferBufferLength = StatusData(m_status, k_pollTimeout, m_state).copy(transferBuffer, transferBufferMaxLength); + *transferBufferLength = StatusData(m_status, m_state).copy(transferBuffer, transferBufferMaxLength); // Additional actions if needed if (actionsAfterStatus) { if (m_largeBufferLength != 0) { diff --git a/ion/src/device/usb/dfu_interface.h b/ion/src/device/usb/dfu_interface.h index 0a4d5ff7e..a540b258e 100644 --- a/ion/src/device/usb/dfu_interface.h +++ b/ion/src/device/usb/dfu_interface.h @@ -93,7 +93,9 @@ private: class StatusData : public Streamable { public: - StatusData(Status status, uint32_t pollTimeout, State state) : + StatusData(Status status, State state, uint32_t pollTimeout = 1) : + /* We put a default pollTimeout value of 1ms: if the device is busy, the + * host has to wait 1ms before sending a getStatus Request. */ m_bStatus((uint8_t)status), m_bwPollTimeout{uint8_t((pollTimeout>>16) & 0xFF), uint8_t((pollTimeout>>8) & 0xFF), uint8_t(pollTimeout & 0xFF)}, m_bState((uint8_t)state), @@ -118,7 +120,6 @@ private: uint8_t m_bState; // Current state of the device }; - constexpr static uint32_t k_pollTimeout = 1; // TODO: needed? value ? constexpr static uint8_t k_flashMemorySectorsCount = 12; constexpr static uint16_t k_maxTransferSize = 2048;