@@ -172,13 +172,12 @@ uint32_t USB_Write(Usb *pUsb, const char *pData, uint32_t length, uint8_t ep_num
172
172
/* Set the multi packet size as zero for multi-packet transfers where length > ep size */
173
173
usb_endpoint_table [ep_num ].DeviceDescBank [1 ].PCKSIZE .bit .MULTI_PACKET_SIZE = 0 ;
174
174
/* 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 ;
177
176
/* Set the bank as ready */
178
177
pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPSTATUSSET .bit .BK1RDY = true;
179
178
180
179
/* 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 );
182
181
183
182
return length ;
184
183
}
@@ -205,15 +204,14 @@ uint32_t USB_Read(Usb *pUsb, char *pData, uint32_t length)
205
204
}
206
205
207
206
/* 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 )
209
208
{
210
209
/* Set packet size */
211
210
packetSize = SAM_BA_MIN (usb_endpoint_table [USB_EP_OUT ].DeviceDescBank [0 ].PCKSIZE .bit .BYTE_COUNT , length );
212
211
/* Copy read data to user buffer */
213
212
memcpy (pData , udd_ep_out_cache_buffer [USB_EP_OUT - 1 ], packetSize );
214
213
/* 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 ;
217
215
/* Clear the user flag */
218
216
read_job = false;
219
217
}
@@ -240,10 +238,9 @@ uint32_t USB_Read_blocking(Usb *pUsb, char *pData, uint32_t length)
240
238
/* Clear the bank 0 ready flag */
241
239
pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPSTATUSCLR .bit .BK0RDY = true;
242
240
/* 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 ));
244
242
/* 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 ;
247
244
248
245
return length ;
249
246
}
@@ -259,7 +256,7 @@ uint8_t USB_IsConfigured(P_USB_CDC pCdc)
259
256
if (pUsb -> DEVICE .INTFLAG .reg & USB_DEVICE_INTFLAG_EORST )
260
257
{
261
258
/* Clear the flag */
262
- pUsb -> DEVICE .INTFLAG .bit . EORST = true ;
259
+ pUsb -> DEVICE .INTFLAG .reg = USB_DEVICE_INTFLAG_EORST ;
263
260
/* Set Device address as 0 */
264
261
pUsb -> DEVICE .DADD .reg = USB_DEVICE_DADD_ADDEN | 0 ;
265
262
/* Configure endpoint 0 */
@@ -303,14 +300,12 @@ void USB_SendStall(Usb *pUsb, bool direction_in)
303
300
if (direction_in )
304
301
{
305
302
/* 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 ;
308
304
}
309
305
else
310
306
{
311
307
/* 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 ;
314
309
}
315
310
}
316
311
@@ -322,12 +317,11 @@ void USB_SendZlp(Usb *pUsb)
322
317
/* Set the byte count as zero */
323
318
usb_endpoint_table [0 ].DeviceDescBank [1 ].PCKSIZE .bit .BYTE_COUNT = 0 ;
324
319
/* 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 ;
327
321
/* Set the bank as ready */
328
322
pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .BK1RDY = true;
329
323
/* 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 ));
331
325
}
332
326
333
327
/*----------------------------------------------------------------------------
0 commit comments