Skip to content

Commit 9dee216

Browse files
Rbb666facchinm
authored andcommitted
Add renesas ra8 support.
1 parent 906c84d commit 9dee216

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/common/tusb_mcu.h

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
#elif TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N, OPT_MCU_RAXXX)
370370
#define TUP_USBIP_RUSB2
371371
#define TUP_DCD_ENDPOINT_MAX 10
372+
#define TUP_RHPORT_HIGHSPEED 1
372373

373374
//--------------------------------------------------------------------+
374375
// GigaDevice

src/portable/renesas/rusb2/dcd_rusb2.c

+31-2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ static void pipe_write_packet(rusb2_reg_t * rusb, void *buf, volatile void *fifo
171171

172172
volatile uint16_t *ff16;
173173
volatile uint8_t *ff8;
174+
175+
// flush cache
176+
#ifdef __DCACHE_PRESENT
177+
SCB_CleanInvalidateDCache_by_Addr(&_dcd, sizeof(dcd_data_t));
178+
#endif
174179

175180
// Highspeed FIFO is 32-bit
176181
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
219224
uint16_t rem = total_len - count;
220225
if (rem) {
221226
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
222230
pipe_write_packet(rusb, info.ptr_wrap, fifo, rem);
223231
count += rem;
224232
}
@@ -506,6 +514,11 @@ static bool process_pipe_xfer(rusb2_reg_t* rusb, int buffer_type, uint8_t ep_add
506514
static bool process_edpt_xfer(rusb2_reg_t* rusb, int buffer_type, uint8_t ep_addr, void* buffer, uint16_t total_bytes)
507515
{
508516
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+
509522
if (0 == epn) {
510523
return process_pipe0_xfer(rusb, buffer_type, ep_addr, buffer, total_bytes);
511524
} else {
@@ -659,6 +672,8 @@ static void enable_interrupt(uint32_t pswi)
659672

660673
void dcd_init(uint8_t rhport)
661674
{
675+
tu_memclr(&_dcd, sizeof(dcd_data_t));
676+
662677
rusb2_reg_t* rusb = RUSB2_REG(rhport);
663678
rusb2_module_start(rhport, true);
664679

@@ -671,10 +686,18 @@ _dcd.sof_enabled = false;
671686
rusb->SYSCFG_b.HSE = 1;
672687

673688
// 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
675692
// Power and reset UTMI Phy
676693
uint16_t physet = (rusb->PHYSET | RUSB2_PHYSET_PLLRESET_Msk) & ~RUSB2_PHYSET_DIRPD_Msk;
677694
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+
678701
R_BSP_SoftwareDelay((uint32_t) 1, BSP_DELAY_UNITS_MILLISECONDS);
679702
rusb->PHYSET_b.PLLRESET = 0;
680703

@@ -823,6 +846,9 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
823846
*ctr = RUSB2_PIPE_CTR_PID_BUF;
824847
}
825848

849+
#ifdef __DCACHE_PRESENT
850+
SCB_CleanInvalidateDCache_by_Addr((uint32_t*) &_dcd, sizeof(dcd_data_t));
851+
#endif
826852
// TU_LOG1("O %d %x %x\r\n", rusb->PIPESEL, rusb->PIPECFG, rusb->PIPEMAXP);
827853
dcd_int_enable(rhport);
828854

@@ -995,6 +1021,9 @@ void dcd_int_handler(uint8_t rhport)
9951021

9961022
// Control transfer stage changes
9971023
if ( is0 & RUSB2_INTSTS0_CTRT_Msk ) {
1024+
#ifdef __DCACHE_PRESENT
1025+
SCB_CleanInvalidateDCache_by_Addr((uint32_t*) &_dcd, sizeof(dcd_data_t));
1026+
#endif
9981027
if ( is0 & RUSB2_INTSTS0_CTSQ_CTRL_RDATA ) {
9991028
/* A setup packet has been received. */
10001029
process_setup_packet(rhport);
@@ -1027,4 +1056,4 @@ void dcd_int_handler(uint8_t rhport)
10271056
}
10281057
}
10291058

1030-
#endif
1059+
#endif

src/portable/renesas/rusb2/rusb2_type.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern "C" {
4848
/* Start of definition of packed structs (used by the CCRX toolchain) */
4949
TU_ATTR_PACKED_BEGIN
5050
TU_ATTR_BIT_FIELD_ORDER_BEGIN
51+
#pragma pack(2)
5152

5253
// TODO same as RUSB2_PIPE_TR_t
5354
typedef struct TU_ATTR_PACKED _ccrx_evenaccess {

0 commit comments

Comments
 (0)