+// Bitmap for all status bits in CSR.\r
+#define REG_NO_EFFECT_1_ALL AT91C_UDP_RX_DATA_BK0 | AT91C_UDP_RX_DATA_BK1 \\r
+ |AT91C_UDP_STALLSENT | AT91C_UDP_RXSETUP \\r
+ |AT91C_UDP_TXCOMP\r
+\r
+// Clear flags in the UDP_CSR register and waits for synchronization\r
+#define UDP_CLEAR_EP_FLAGS(endpoint, flags) { \\r
+ volatile unsigned int reg; \\r
+ reg = pUdp->UDP_CSR[endpoint]; \\r
+ reg |= REG_NO_EFFECT_1_ALL; \\r
+ reg &= ~(flags); \\r
+ pUdp->UDP_CSR[endpoint] = reg; \\r
+ while ( (pUdp->UDP_CSR[endpoint] & (flags)) == (flags)); \\r
+}\r
+\r
+// reset flags in the UDP_CSR register and waits for synchronization\r
+#define UDP_SET_EP_FLAGS(endpoint, flags) { \\r
+ volatile unsigned int reg; \\r
+ reg = pUdp->UDP_CSR[endpoint]; \\r
+ reg |= REG_NO_EFFECT_1_ALL; \\r
+ reg |= (flags); \\r
+ pUdp->UDP_CSR[endpoint] = reg; \\r
+ while ( ( pUdp->UDP_CSR[endpoint] & (flags)) != (flags)); \\r
+}\r