@@ -276,7 +276,7 @@ void AT91F_InitUSB(void)
276
276
/* Set the descriptor address */
277
277
USB -> HOST .DESCADD .reg = (uint32_t )(& usb_endpoint_table [0 ]);
278
278
/* Set speed configuration to Full speed */
279
- USB -> DEVICE .CTRLB .bit .SPDCONF = USB_DEVICE_CTRLB_SPDCONF_0_Val ;
279
+ USB -> DEVICE .CTRLB .bit .SPDCONF = USB_DEVICE_CTRLB_SPDCONF_FS_Val ;
280
280
/* Attach to the USB host */
281
281
USB -> DEVICE .CTRLB .reg &= ~USB_DEVICE_CTRLB_DETACH ;
282
282
@@ -367,13 +367,14 @@ static uint32_t USB_Read(P_USB_CDC pCdc, char *pData, uint32_t length)
367
367
}
368
368
369
369
/* Check for Transfer Complete 0 flag */
370
- if ( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_TRCPT0 ) {
370
+ if ( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit . TRCPT & ( 1 << 0 ) ) {
371
371
/* Set packet size */
372
372
packetSize = MIN (usb_endpoint_table [USB_EP_OUT ].DeviceDescBank [0 ].PCKSIZE .bit .BYTE_COUNT , length );
373
373
/* Copy read data to user buffer */
374
374
memcpy (pData , udd_ep_out_cache_buffer [USB_EP_OUT - 1 ], packetSize );
375
375
/* Clear the Transfer Complete 0 flag */
376
- pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT0 = true;
376
+ //pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 = true;
377
+ pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT |= (1 << 0 );
377
378
/* Clear the user flag */
378
379
read_job = false;
379
380
}
@@ -401,9 +402,10 @@ static uint32_t USB_Read_blocking(P_USB_CDC pCdc, char *pData, uint32_t length)
401
402
/* Clear the bank 0 ready flag */
402
403
pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPSTATUSCLR .bit .BK0RDY = true;
403
404
/* Wait for transfer to complete */
404
- while (!( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_TRCPT0 ));
405
+ while (!( pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit . TRCPT & ( 1 << 0 ) ));
405
406
/* Clear Transfer complete 0 flag */
406
- pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT0 = true;
407
+ //pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0 = true;
408
+ pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit .TRCPT |= (1 << 0 );
407
409
408
410
return length ;
409
411
@@ -439,12 +441,13 @@ static uint32_t USB_Write(P_USB_CDC pCdc, const char *pData, uint32_t length, ui
439
441
/* Set the multi packet size as zero for multi-packet transfers where length > ep size */
440
442
usb_endpoint_table [ep_num ].DeviceDescBank [1 ].PCKSIZE .bit .MULTI_PACKET_SIZE = 0 ;
441
443
/* Clear the transfer complete flag */
442
- pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .bit .TRCPT1 = true;
444
+ //pUsb->DEVICE.DeviceEndpoint[ep_num].EPINTFLAG.bit.TRCPT1 = true;
445
+ pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .bit .TRCPT |= (1 << 1 );
443
446
/* Set the bank as ready */
444
447
pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPSTATUSSET .bit .BK1RDY = true;
445
448
446
449
/* Wait for transfer to complete */
447
- while (!( pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_TRCPT1 ));
450
+ while (!( pUsb -> DEVICE .DeviceEndpoint [ep_num ].EPINTFLAG .bit . TRCPT & ( 1 << 1 ) ));
448
451
449
452
return length ;
450
453
}
@@ -468,11 +471,12 @@ void AT91F_USB_SendZlp(Usb *pUsb)
468
471
/* Set the byte count as zero */
469
472
usb_endpoint_table [0 ].DeviceDescBank [1 ].PCKSIZE .bit .BYTE_COUNT = 0 ;
470
473
/* Clear the transfer complete flag */
471
- pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .bit .TRCPT1 = true;
474
+ //pUsb->DEVICE.DeviceEndpoint[0].EPINTFLAG.bit.TRCPT1 = true;
475
+ pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .bit .TRCPT |= (1 << 1 );
472
476
/* Set the bank as ready */
473
477
pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .BK1RDY = true;
474
478
/* Wait for transfer to complete */
475
- while (!( pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_TRCPT1 ));
479
+ while (!( pUsb -> DEVICE .DeviceEndpoint [0 ].EPINTFLAG .bit . TRCPT & ( 1 << 1 ) ));
476
480
}
477
481
478
482
//*----------------------------------------------------------------------------
@@ -484,10 +488,12 @@ void AT91F_USB_SendStall(Usb *pUsb, bool direction_in)
484
488
/* Check the direction */
485
489
if (direction_in ) {
486
490
/* Set STALL request on IN direction */
487
- pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .reg = USB_DEVICE_EPSTATUSSET_STALLRQ1 ;
491
+ //pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
492
+ pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .STALLRQ = (1 <<1 );
488
493
} else {
489
494
/* Set STALL request on OUT direction */
490
- pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .reg = USB_DEVICE_EPSTATUSSET_STALLRQ0 ;
495
+ //pUsb->DEVICE.DeviceEndpoint[0].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
496
+ pUsb -> DEVICE .DeviceEndpoint [0 ].EPSTATUSSET .bit .STALLRQ = (1 <<0 );
491
497
}
492
498
}
493
499
@@ -579,9 +585,11 @@ void AT91F_CDC_Enumerate(P_USB_CDC pCdc)
579
585
wIndex &= 0x0F ;
580
586
if (wIndex <= 3 ) {
581
587
if (dir ) {
582
- wStatus = (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .reg & USB_DEVICE_EPSTATUSSET_STALLRQ1 ) ? 1 : 0 ;
588
+ //wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.reg & USB_DEVICE_EPSTATUSSET_STALLRQ1) ? 1 : 0;
589
+ wStatus = (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .bit .STALLRQ & (1 <<1 )) ? 1 : 0 ;
583
590
} else {
584
- wStatus = (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .reg & USB_DEVICE_EPSTATUSSET_STALLRQ0 ) ? 1 : 0 ;
591
+ //wStatus = (pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUS.reg & USB_DEVICE_EPSTATUSSET_STALLRQ0) ? 1 : 0;
592
+ wStatus = (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .bit .STALLRQ & (1 <<0 )) ? 1 : 0 ;
585
593
}
586
594
/* Return current status of endpoint */
587
595
AT91F_USB_SendData (pCdc , (char * ) & wStatus , sizeof (wStatus ));
@@ -604,9 +612,11 @@ void AT91F_CDC_Enumerate(P_USB_CDC pCdc)
604
612
if ((wValue == 0 ) && wIndex && (wIndex <= 3 )) {
605
613
/* Set STALL request for the endpoint */
606
614
if (dir ) {
607
- pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSSET .reg = USB_DEVICE_EPSTATUSSET_STALLRQ1 ;
615
+ //pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
616
+ pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSSET .bit .STALLRQ = (1 <<1 );
608
617
} else {
609
- pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSSET .reg = USB_DEVICE_EPSTATUSSET_STALLRQ0 ;
618
+ //pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
619
+ pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSSET .bit .STALLRQ = (1 <<0 );
610
620
}
611
621
/* Send ZLP */
612
622
AT91F_USB_SendZlp (pUsb );
@@ -628,21 +638,23 @@ void AT91F_CDC_Enumerate(P_USB_CDC pCdc)
628
638
wIndex &= 0x0F ;
629
639
if ((wValue == 0 ) && wIndex && (wIndex <= 3 )) {
630
640
if (dir ) {
631
- if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .reg & USB_DEVICE_EPSTATUSSET_STALLRQ1 ) {
641
+ if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .bit . STALLRQ & ( 1 << 1 ) ) {
632
642
// Remove stall request
633
- pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSCLR .reg = USB_DEVICE_EPSTATUSCLR_STALLRQ1 ;
634
- if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_STALL1 ) {
635
- pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .reg = USB_DEVICE_EPINTFLAG_STALL1 ;
643
+ //pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_STALLRQ1;
644
+ pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSCLR .bit .STALLRQ = (1 <<1 );
645
+ if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .bit .STALL & (1 <<1 )) {
646
+ pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .bit .STALL = (1 <<1 );
636
647
// The Stall has occurred, then reset data toggle
637
648
pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSCLR .reg = USB_DEVICE_EPSTATUSSET_DTGLIN ;
638
649
}
639
650
}
640
651
} else {
641
- if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .reg & USB_DEVICE_EPSTATUSSET_STALLRQ0 ) {
652
+ if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUS .bit . STALLRQ & ( 1 << 0 ) ) {
642
653
// Remove stall request
643
- pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSCLR .reg = USB_DEVICE_EPSTATUSCLR_STALLRQ0 ;
644
- if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_STALL0 ) {
645
- pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .reg = USB_DEVICE_EPINTFLAG_STALL0 ;
654
+ //pUsb->DEVICE.DeviceEndpoint[wIndex].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_STALLRQ0;
655
+ pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSCLR .bit .STALLRQ = (1 <<0 );
656
+ if (pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .bit .STALL & (1 <<0 )) {
657
+ pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPINTFLAG .bit .STALL = (1 <<0 );
646
658
// The Stall has occurred, then reset data toggle
647
659
pUsb -> DEVICE .DeviceEndpoint [wIndex ].EPSTATUSCLR .reg = USB_DEVICE_EPSTATUSSET_DTGLOUT ;
648
660
}
@@ -711,7 +723,7 @@ bool cdc_is_rx_ready(void)
711
723
return 0 ;
712
724
713
725
/* Return transfer complete 0 flag status */
714
- return (pCdc .pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .reg & USB_DEVICE_EPINTFLAG_TRCPT0 );
726
+ return (pCdc .pUsb -> DEVICE .DeviceEndpoint [USB_EP_OUT ].EPINTFLAG .bit . TRCPT & ( 1 << 0 ) );
715
727
}
716
728
717
729
uint32_t cdc_write_buf (void const * data , uint32_t length )
0 commit comments