Skip to content

Commit

Permalink
Fix SET_CSR timeout handling (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored Apr 4, 2019
1 parent a10213d commit 1d5572b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions at91lib/usb/device/core/USBD_UDP.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void USBD_InterruptHandler(void) RAMFUNC;
/// \page "UDP_CSR register access"
///
/// This page lists the macroes to access UDP CSR register.
/// UDP_CSR register requires 3 UDPCK clocks and 5 peripheral clocks of wait
/// after setting value. Assuming that `if((CSR & flags) == flags)` consumes 3 clocks.
/// The timeout of register value check means that we had another high priority
/// interrupts between register writing and reading; we can keep going without problems.
///
/// !Macros
/// - CLEAR_CSR
Expand All @@ -125,11 +129,7 @@ void USBD_InterruptHandler(void) RAMFUNC;
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) == (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) == (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) == (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) == (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) == (flags) ) break; \
TRACE_ERROR("SET_CSR Timeout (%x)\n\r", flags); \
} while (0);
//while ( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) != (flags));

/// Sets the specified bit(s) in the UDP_CSR register.
/// \param endpoint The endpoint number of the CSR to process.
Expand All @@ -144,11 +144,7 @@ void USBD_InterruptHandler(void) RAMFUNC;
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) != (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) != (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) != (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) != (flags) ) break; \
if( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) != (flags) ) break; \
TRACE_ERROR("CLEAR_CSR Timedout (%x)\n\r", flags); \
} while (0);
//while ( (AT91C_BASE_UDP->UDP_CSR[endpoint] & (flags)) == (flags));
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 1d5572b

Please sign in to comment.