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