|
@@ -217,7 +217,7 @@ extern "C" {
|
217
|
217
|
#define udd_raise_msof() (UOTGHS->UOTGHS_DEVIFR = UOTGHS_DEVIFR_MSOFS)
|
218
|
218
|
#define Is_udd_msof() (Tst_bits(UOTGHS->UOTGHS_DEVISR, UOTGHS_DEVISR_MSOF))
|
219
|
219
|
#define udd_micro_frame_number() \
|
220
|
|
- (Rd_bitfield(UOTGHS->UOTGHS_DEVFNUM, (UOTGHS_DEVFNUM_FNUM_Msk|UOTGHS_DEVFNUM_MFNUM_Msk)))
|
|
220
|
+ (Rd_bitfield(UOTGHS->UOTGHS_DEVFNUM, (UOTGHS_DEVFNUM_FNUM_Msk|UOTGHS_DEVFNUM_MFNUM_Msk)))
|
221
|
221
|
//! @}
|
222
|
222
|
|
223
|
223
|
//! Manage suspend event
|
|
@@ -266,10 +266,10 @@ extern "C" {
|
266
|
266
|
#define Is_udd_endpoint_enabled(ep) (Tst_bits(UOTGHS->UOTGHS_DEVEPT, UOTGHS_DEVEPT_EPEN0 << (ep)))
|
267
|
267
|
//! resets the selected endpoint
|
268
|
268
|
#define udd_reset_endpoint(ep) \
|
269
|
|
- do { \
|
270
|
|
- Set_bits(UOTGHS->UOTGHS_DEVEPT, UOTGHS_DEVEPT_EPRST0 << (ep)); \
|
271
|
|
- Clr_bits(UOTGHS->UOTGHS_DEVEPT, UOTGHS_DEVEPT_EPRST0 << (ep)); \
|
272
|
|
- } while (0)
|
|
269
|
+ do { \
|
|
270
|
+ Set_bits(UOTGHS->UOTGHS_DEVEPT, UOTGHS_DEVEPT_EPRST0 << (ep)); \
|
|
271
|
+ Clr_bits(UOTGHS->UOTGHS_DEVEPT, UOTGHS_DEVEPT_EPRST0 << (ep)); \
|
|
272
|
+ } while (0)
|
273
|
273
|
//! Tests if the selected endpoint is being reset
|
274
|
274
|
#define Is_udd_resetting_endpoint(ep) (Tst_bits(UOTGHS->UOTGHS_DEVEPT, UOTGHS_DEVEPT_EPRST0 << (ep)))
|
275
|
275
|
|
|
@@ -290,6 +290,7 @@ extern "C" {
|
290
|
290
|
//! Bounds given integer size to allowed range and rounds it up to the nearest
|
291
|
291
|
//! available greater size, then applies register format of UOTGHS controller
|
292
|
292
|
//! for endpoint size bit-field.
|
|
293
|
+#undef udd_format_endpoint_size
|
293
|
294
|
#define udd_format_endpoint_size(size) (32 - clz(((uint32_t)MIN(MAX(size, 8), 1024) << 1) - 1) - 1 - 3)
|
294
|
295
|
//! Configures the selected endpoint size
|
295
|
296
|
#define udd_configure_endpoint_size(ep, size) (Wr_bitfield(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPSIZE_Msk, udd_format_endpoint_size(size)))
|
|
@@ -307,14 +308,14 @@ extern "C" {
|
307
|
308
|
|
308
|
309
|
//! Configures selected endpoint in one step
|
309
|
310
|
#define udd_configure_endpoint(ep, type, dir, size, bank) (\
|
310
|
|
- Wr_bits(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPTYPE_Msk |\
|
311
|
|
- UOTGHS_DEVEPTCFG_EPDIR |\
|
312
|
|
- UOTGHS_DEVEPTCFG_EPSIZE_Msk |\
|
313
|
|
- UOTGHS_DEVEPTCFG_EPBK_Msk , \
|
314
|
|
- (((uint32_t)(type) << UOTGHS_DEVEPTCFG_EPTYPE_Pos) & UOTGHS_DEVEPTCFG_EPTYPE_Msk) |\
|
315
|
|
- (((uint32_t)(dir ) << UOTGHS_DEVEPTCFG_EPDIR_Pos ) & UOTGHS_DEVEPTCFG_EPDIR) |\
|
316
|
|
- ( (uint32_t)udd_format_endpoint_size(size) << UOTGHS_DEVEPTCFG_EPSIZE_Pos) |\
|
317
|
|
- (((uint32_t)(bank) << UOTGHS_DEVEPTCFG_EPBK_Pos) & UOTGHS_DEVEPTCFG_EPBK_Msk))\
|
|
311
|
+ Wr_bits(UOTGHS_ARRAY(UOTGHS_DEVEPTCFG[0], ep), UOTGHS_DEVEPTCFG_EPTYPE_Msk |\
|
|
312
|
+ UOTGHS_DEVEPTCFG_EPDIR |\
|
|
313
|
+ UOTGHS_DEVEPTCFG_EPSIZE_Msk |\
|
|
314
|
+ UOTGHS_DEVEPTCFG_EPBK_Msk , \
|
|
315
|
+ (((uint32_t)(type) << UOTGHS_DEVEPTCFG_EPTYPE_Pos) & UOTGHS_DEVEPTCFG_EPTYPE_Msk) |\
|
|
316
|
+ (((uint32_t)(dir ) << UOTGHS_DEVEPTCFG_EPDIR_Pos ) & UOTGHS_DEVEPTCFG_EPDIR) |\
|
|
317
|
+ ( (uint32_t)udd_format_endpoint_size(size) << UOTGHS_DEVEPTCFG_EPSIZE_Pos) |\
|
|
318
|
+ (((uint32_t)(bank) << UOTGHS_DEVEPTCFG_EPBK_Pos) & UOTGHS_DEVEPTCFG_EPBK_Msk))\
|
318
|
319
|
)
|
319
|
320
|
//! Tests if current endpoint is configured
|
320
|
321
|
#define Is_udd_endpoint_configured(ep) (Tst_bits(UOTGHS_ARRAY(UOTGHS_DEVEPTISR[0], ep), UOTGHS_DEVEPTISR_CFGOK))
|
|
@@ -540,7 +541,7 @@ extern "C" {
|
540
|
541
|
//! @warning It is up to the user of this macro to make sure that used HSB
|
541
|
542
|
//! addresses are identical to the DPRAM internal pointer modulo 32 bits.
|
542
|
543
|
#define udd_get_endpoint_fifo_access(ep, scale) \
|
543
|
|
- (((volatile TPASTE2(U, scale) (*)[0x8000 / ((scale) / 8)])UOTGHS_RAM_ADDR)[(ep)])
|
|
544
|
+ (((volatile TPASTE2(U, scale) (*)[0x8000 / ((scale) / 8)])UOTGHS_RAM_ADDR)[(ep)])
|
544
|
545
|
|
545
|
546
|
//! @name UOTGHS endpoint DMA drivers
|
546
|
547
|
//! These macros manage the common features of the endpoint DMA channels.
|
|
@@ -572,60 +573,60 @@ extern "C" {
|
572
|
573
|
//! @{
|
573
|
574
|
//! Structure for DMA next descriptor register
|
574
|
575
|
typedef struct {
|
575
|
|
- uint32_t *NXT_DSC_ADD;
|
|
576
|
+ uint32_t *NXT_DSC_ADD;
|
576
|
577
|
} uotghs_dma_nextdesc_t;
|
577
|
578
|
//! Structure for DMA control register
|
578
|
579
|
typedef struct {
|
579
|
|
- uint32_t CHANN_ENB:1,
|
580
|
|
- LDNXT_DSC:1,
|
581
|
|
- END_TR_EN:1,
|
582
|
|
- END_B_EN:1,
|
583
|
|
- END_TR_IT:1,
|
584
|
|
- END_BUFFIT:1,
|
585
|
|
- DESC_LD_IT:1,
|
586
|
|
- BUST_LCK:1,
|
587
|
|
- reserved:8,
|
588
|
|
- BUFF_LENGTH:16;
|
|
580
|
+ uint32_t CHANN_ENB:1,
|
|
581
|
+ LDNXT_DSC:1,
|
|
582
|
+ END_TR_EN:1,
|
|
583
|
+ END_B_EN:1,
|
|
584
|
+ END_TR_IT:1,
|
|
585
|
+ END_BUFFIT:1,
|
|
586
|
+ DESC_LD_IT:1,
|
|
587
|
+ BUST_LCK:1,
|
|
588
|
+ reserved:8,
|
|
589
|
+ BUFF_LENGTH:16;
|
589
|
590
|
} uotghs_dma_control_t;
|
590
|
591
|
//! Structure for DMA status register
|
591
|
592
|
typedef struct {
|
592
|
|
- uint32_t CHANN_ENB:1,
|
593
|
|
- CHANN_ACT:1,
|
594
|
|
- reserved0:2,
|
595
|
|
- END_TR_ST:1,
|
596
|
|
- END_BF_ST:1,
|
597
|
|
- DESC_LDST:1,
|
598
|
|
- reserved1:9,
|
599
|
|
- BUFF_COUNT:16;
|
|
593
|
+ uint32_t CHANN_ENB:1,
|
|
594
|
+ CHANN_ACT:1,
|
|
595
|
+ reserved0:2,
|
|
596
|
+ END_TR_ST:1,
|
|
597
|
+ END_BF_ST:1,
|
|
598
|
+ DESC_LDST:1,
|
|
599
|
+ reserved1:9,
|
|
600
|
+ BUFF_COUNT:16;
|
600
|
601
|
} uotghs_dma_status_t;
|
601
|
602
|
//! Structure for DMA descriptor
|
602
|
603
|
typedef struct {
|
603
|
|
- union {
|
604
|
|
- uint32_t nextdesc;
|
605
|
|
- uotghs_dma_nextdesc_t NEXTDESC;
|
606
|
|
- };
|
607
|
|
- uint32_t addr;
|
608
|
|
- union {
|
609
|
|
- uint32_t control;
|
610
|
|
- uotghs_dma_control_t CONTROL;
|
611
|
|
- };
|
612
|
|
- uint32_t reserved;
|
|
604
|
+ union {
|
|
605
|
+ uint32_t nextdesc;
|
|
606
|
+ uotghs_dma_nextdesc_t NEXTDESC;
|
|
607
|
+ };
|
|
608
|
+ uint32_t addr;
|
|
609
|
+ union {
|
|
610
|
+ uint32_t control;
|
|
611
|
+ uotghs_dma_control_t CONTROL;
|
|
612
|
+ };
|
|
613
|
+ uint32_t reserved;
|
613
|
614
|
} sam_uotghs_dmadesc_t, uotghs_dmadesc_t;
|
614
|
615
|
//! Structure for DMA registers in a channel
|
615
|
616
|
typedef struct {
|
616
|
|
- union {
|
617
|
|
- uint32_t nextdesc;
|
618
|
|
- uotghs_dma_nextdesc_t NEXTDESC;
|
619
|
|
- };
|
620
|
|
- uint32_t addr;
|
621
|
|
- union {
|
622
|
|
- uint32_t control;
|
623
|
|
- uotghs_dma_control_t CONTROL;
|
624
|
|
- };
|
625
|
|
- union {
|
626
|
|
- unsigned long status;
|
627
|
|
- uotghs_dma_status_t STATUS;
|
628
|
|
- };
|
|
617
|
+ union {
|
|
618
|
+ uint32_t nextdesc;
|
|
619
|
+ uotghs_dma_nextdesc_t NEXTDESC;
|
|
620
|
+ };
|
|
621
|
+ uint32_t addr;
|
|
622
|
+ union {
|
|
623
|
+ uint32_t control;
|
|
624
|
+ uotghs_dma_control_t CONTROL;
|
|
625
|
+ };
|
|
626
|
+ union {
|
|
627
|
+ unsigned long status;
|
|
628
|
+ uotghs_dma_status_t STATUS;
|
|
629
|
+ };
|
629
|
630
|
} sam_uotghs_dmach_t, uotghs_dmach_t;
|
630
|
631
|
//! DMA channel control command
|
631
|
632
|
#define UDD_ENDPOINT_DMA_STOP_NOW (0)
|