@@ -172,13 +172,12 @@ uint32_t USB_Write(Usb *pUsb, const char *pData, uint32_t length, uint8_t ep_num
172172 /* Set the multi packet size as zero for multi-packet transfers where length > ep size */
173173 usb_endpoint_table [ep_num ].DeviceDescBank [1 ].PCKSIZE .bit .MULTI_PACKET_SIZE = 0 ;
174174 /* Clear the transfer complete flag */
175- //pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.bit.TRCPT1 = true;
176- pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .bit .TRCPT |= (1 <<1 );
175+ pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .reg = USB_DEVICE_EPINTFLAG_TRCPT1 ;
177176 /* Set the bank as ready */
178177 pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPSTATUSSET .bit .BK1RDY = true;
179178
180179 /* Wait for transfer to complete */
181- while ( (pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .bit .TRCPT & ( 1 << 1 ) ) == 0 );
180+ while ( (pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .bit .TRCPT1 ) == 0 );
182181
183182 return length ;
184183}
@@ -205,15 +204,14 @@ uint32_t USB_Read(Usb *pUsb, char *pData, uint32_t length)
205204 }
206205
207206 /* Check for Transfer Complete 0 flag */
208- if ( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT & ( 1 << 0 ) )
207+ if ( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT0 )
209208 {
210209 /* Set packet size */
211210 packetSize = SAM_BA_MIN (usb_endpoint_table [USB_EP_OUT ].DeviceDescBank [0 ].PCKSIZE .bit .BYTE_COUNT , length );
212211 /* Copy read data to user buffer */
213212 memcpy (pData , udd_ep_out_cache_buffer [USB_EP_OUT - 1 ], packetSize );
214213 /* Clear the Transfer Complete 0 flag */
215- //pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 = true;
216- pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT |= (1 << 0 );
214+ pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .reg = USB_DEVICE_EPINTFLAG_TRCPT0 ;
217215 /* Clear the user flag */
218216 read_job = false;
219217 }
@@ -240,10 +238,9 @@ uint32_t USB_Read_blocking(Usb *pUsb, char *pData, uint32_t length)
240238 /* Clear the bank 0 ready flag */
241239 pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPSTATUSCLR .bit .BK0RDY = true;
242240 /* Wait for transfer to complete */
243- while (!( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT & ( 1 << 0 ) ));
241+ while (!( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT0 ));
244242 /* Clear Transfer complete 0 flag */
245- //pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 = true;
246- pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT |= (1 << 0 );
243+ pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .reg = USB_DEVICE_EPINTFLAG_TRCPT0 ;
247244
248245 return length ;
249246}
@@ -259,7 +256,7 @@ uint8_t USB_IsConfigured(P_USB_CDC pCdc)
259256 if (pUsb -> DEVICE .INTFLAG .reg & USB_DEVICE_INTFLAG_EORST )
260257 {
261258 /* Clear the flag */
262- pUsb -> DEVICE .INTFLAG .bit . EORST = true ;
259+ pUsb -> DEVICE .INTFLAG .reg = USB_DEVICE_INTFLAG_EORST ;
263260 /* Set Device address as 0 */
264261 pUsb -> DEVICE .DADD .reg = USB_DEVICE_DADD_ADDEN | 0 ;
265262 /* Configure endpoint 0 */
@@ -303,14 +300,12 @@ void USB_SendStall(Usb *pUsb, bool direction_in)
303300 if (direction_in )
304301 {
305302 /* Set STALL request on IN direction */
306- //pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
307- pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .STALLRQ = (1 <<1 );
303+ pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .STALLRQ1 = 1 ;
308304 }
309305 else
310306 {
311307 /* Set STALL request on OUT direction */
312- //pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
313- pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .STALLRQ = (1 <<0 );
308+ pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .STALLRQ0 = 1 ;
314309 }
315310}
316311
@@ -322,12 +317,11 @@ void USB_SendZlp(Usb *pUsb)
322317 /* Set the byte count as zero */
323318 usb_endpoint_table [0 ].DeviceDescBank [1 ].PCKSIZE .bit .BYTE_COUNT = 0 ;
324319 /* Clear the transfer complete flag */
325- //pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.TRCPT1 = true;
326- pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .bit .TRCPT |= (1 << 1 );
320+ pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .reg = USB_DEVICE_EPINTFLAG_TRCPT1 ;
327321 /* Set the bank as ready */
328322 pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .BK1RDY = true;
329323 /* Wait for transfer to complete */
330- while (!( pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .bit .TRCPT & ( 1 << 1 ) ));
324+ while (!( pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .bit .TRCPT1 ));
331325}
332326
333327/*----------------------------------------------------------------------------
0 commit comments