2525#include "USB/samd21_device.h"
2626#include "sam.h"
2727
28+ #ifdef __cplusplus
29+ extern "C" {
30+ #endif // __cplusplus
31+
32+ #ifdef SAMD_SERIES
33+
2834//#define TRACE_DEVICE(x) x
2935#define TRACE_DEVICE (x )
3036
31- __attribute__((__aligned__ (4 ))) __attribute__((__section__ (".bss_hram0" ))) uint8_t udd_ep_out_cache_buffer [4 ][64 ];
32- __attribute__((__aligned__ (4 ))) __attribute__((__section__ (".bss_hram0" ))) uint8_t udd_ep_in_cache_buffer [4 ][128 ];
37+ __attribute__((__aligned__ (4 ))) /* __attribute__((__section__(".bss_hram0")))*/ uint8_t udd_ep_out_cache_buffer [4 ][64 ];
38+ __attribute__((__aligned__ (4 ))) /* __attribute__((__section__(".bss_hram0")))*/ uint8_t udd_ep_in_cache_buffer [4 ][128 ];
3339
3440/**
3541 * USB SRAM data containing pipe descriptor table
@@ -264,6 +270,7 @@ uint8_t UDD_Recv_data(uint32_t ep, uint32_t len)
264270{
265271 TRACE_DEVICE (printf ("=> UDD_Recvdata : ep=%d\r\n" , (char )ep );)
266272
273+ if (len > 64 ) len = 64 ;
267274 usb_endpoint_table [ep ].DeviceDescBank [0 ].ADDR .reg = (uint32_t )& udd_ep_out_cache_buffer [ep ];
268275 usb_endpoint_table [ep ].DeviceDescBank [0 ].PCKSIZE .bit .MULTI_PACKET_SIZE = len ;
269276 usb_endpoint_table [ep ].DeviceDescBank [0 ].PCKSIZE .bit .BYTE_COUNT = 0 ;
@@ -273,7 +280,7 @@ uint8_t UDD_Recv_data(uint32_t ep, uint32_t len)
273280 /* Wait for transfer to complete */
274281 while (!udd_is_OUT_transf_cplt (ep ));
275282 /* Clear Transfer complete 0 flag */
276- // udd_clear_OUT_transf_cplt(ep);
283+ udd_clear_OUT_transf_cplt (ep );
277284
278285 return udd_ep_out_cache_buffer [ep ][0 ];
279286}
@@ -302,7 +309,7 @@ void UDD_ReleaseRX(uint32_t ep)
302309 // The RAM Buffer is empty: we can receive data
303310 udd_OUT_transfer_allowed (ep );
304311 /* Clear Transfer complete 0 flag */
305- // udd_clear_OUT_transf_cplt(ep);
312+ udd_clear_OUT_transf_cplt (ep );
306313}
307314
308315void UDD_ReleaseTX (uint32_t ep )
@@ -311,7 +318,7 @@ void UDD_ReleaseTX(uint32_t ep)
311318 // The RAM Buffer is full: we can send data
312319 udd_IN_transfer_allowed (ep );
313320 /* Clear the transfer complete flag */
314- // udd_clear_IN_transf_cplt(ep);
321+ udd_clear_IN_transf_cplt (ep );
315322}
316323
317324void UDD_SetAddress (uint32_t addr )
@@ -335,3 +342,10 @@ uint32_t UDD_GetFrameNumber(void)
335342{
336343 return udd_frame_number ();
337344}
345+
346+ #ifdef __cplusplus
347+ }
348+ #endif
349+
350+ #endif /* SAMD_SERIES */
351+
0 commit comments