@@ -171,6 +171,11 @@ static void pipe_write_packet(rusb2_reg_t * rusb, void *buf, volatile void *fifo
171
171
172
172
volatile uint16_t * ff16 ;
173
173
volatile uint8_t * ff8 ;
174
+
175
+ // flush cache
176
+ #ifdef __DCACHE_PRESENT
177
+ SCB_CleanInvalidateDCache_by_Addr (& _dcd , sizeof (dcd_data_t ));
178
+ #endif
174
179
175
180
// Highspeed FIFO is 32-bit
176
181
if ( rusb2_is_highspeed_reg (rusb ) ) {
@@ -219,6 +224,9 @@ static void pipe_write_packet_ff(rusb2_reg_t * rusb, tu_fifo_t *f, volatile void
219
224
uint16_t rem = total_len - count ;
220
225
if (rem ) {
221
226
rem = tu_min16 (rem , info .len_wrap );
227
+ #ifdef __DCACHE_PRESENT
228
+ SCB_CleanInvalidateDCache_by_Addr ((uint32_t * ) tu_align ((uint32_t ) info .ptr_wrap , 4 ), total_len - info .len_wrap + 31 );
229
+ #endif
222
230
pipe_write_packet (rusb , info .ptr_wrap , fifo , rem );
223
231
count += rem ;
224
232
}
@@ -506,6 +514,11 @@ static bool process_pipe_xfer(rusb2_reg_t* rusb, int buffer_type, uint8_t ep_add
506
514
static bool process_edpt_xfer (rusb2_reg_t * rusb , int buffer_type , uint8_t ep_addr , void * buffer , uint16_t total_bytes )
507
515
{
508
516
const unsigned epn = tu_edpt_number (ep_addr );
517
+
518
+ #ifdef __DCACHE_PRESENT
519
+ SCB_CleanInvalidateDCache_by_Addr ((uint32_t * ) tu_align ((uint32_t ) buffer , 4 ), total_bytes + 31 );
520
+ #endif
521
+
509
522
if (0 == epn ) {
510
523
return process_pipe0_xfer (rusb , buffer_type , ep_addr , buffer , total_bytes );
511
524
} else {
@@ -659,6 +672,8 @@ static void enable_interrupt(uint32_t pswi)
659
672
660
673
void dcd_init (uint8_t rhport )
661
674
{
675
+ tu_memclr (& _dcd , sizeof (dcd_data_t ));
676
+
662
677
rusb2_reg_t * rusb = RUSB2_REG (rhport );
663
678
rusb2_module_start (rhport , true);
664
679
@@ -671,10 +686,18 @@ _dcd.sof_enabled = false;
671
686
rusb -> SYSCFG_b .HSE = 1 ;
672
687
673
688
// leave CLKSEL as default (0x11) 24Mhz
674
-
689
+ #ifdef __DCACHE_PRESENT
690
+ SCB_CleanInvalidateDCache_by_Addr ((uint32_t * ) & _dcd , sizeof (dcd_data_t ));
691
+ #endif
675
692
// Power and reset UTMI Phy
676
693
uint16_t physet = (rusb -> PHYSET | RUSB2_PHYSET_PLLRESET_Msk ) & ~RUSB2_PHYSET_DIRPD_Msk ;
677
694
rusb -> PHYSET = physet ;
695
+
696
+ #if defined(RENESAS_CORTEX_M85 )
697
+ // RA8 PHYSET-CLKSEL need set 20Mhz
698
+ rusb -> PHYSET = (rusb -> PHYSET & ~(1 << 4 )) | (1 << 5 );
699
+ #endif
700
+
678
701
R_BSP_SoftwareDelay ((uint32_t ) 1 , BSP_DELAY_UNITS_MILLISECONDS );
679
702
rusb -> PHYSET_b .PLLRESET = 0 ;
680
703
@@ -823,6 +846,9 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
823
846
* ctr = RUSB2_PIPE_CTR_PID_BUF ;
824
847
}
825
848
849
+ #ifdef __DCACHE_PRESENT
850
+ SCB_CleanInvalidateDCache_by_Addr ((uint32_t * ) & _dcd , sizeof (dcd_data_t ));
851
+ #endif
826
852
// TU_LOG1("O %d %x %x\r\n", rusb->PIPESEL, rusb->PIPECFG, rusb->PIPEMAXP);
827
853
dcd_int_enable (rhport );
828
854
@@ -995,6 +1021,9 @@ void dcd_int_handler(uint8_t rhport)
995
1021
996
1022
// Control transfer stage changes
997
1023
if ( is0 & RUSB2_INTSTS0_CTRT_Msk ) {
1024
+ #ifdef __DCACHE_PRESENT
1025
+ SCB_CleanInvalidateDCache_by_Addr ((uint32_t * ) & _dcd , sizeof (dcd_data_t ));
1026
+ #endif
998
1027
if ( is0 & RUSB2_INTSTS0_CTSQ_CTRL_RDATA ) {
999
1028
/* A setup packet has been received. */
1000
1029
process_setup_packet (rhport );
@@ -1027,4 +1056,4 @@ void dcd_int_handler(uint8_t rhport)
1027
1056
}
1028
1057
}
1029
1058
1030
- #endif
1059
+ #endif
0 commit comments