Skip to content

Commit 04f1a34

Browse files
committed
add rusb2_common.c for dynami irq
1 parent 40833b5 commit 04f1a34

File tree

7 files changed

+65
-18
lines changed

7 files changed

+65
-18
lines changed

hw/bsp/ra/family.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function(family_configure_example TARGET RTOS)
116116
target_sources(${TARGET}-tinyusb PUBLIC
117117
${TOP}/src/portable/renesas/rusb2/dcd_rusb2.c
118118
${TOP}/src/portable/renesas/rusb2/hcd_rusb2.c
119+
${TOP}/src/portable/renesas/rusb2/rusb2_common.c
119120
)
120121
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
121122

hw/bsp/ra/family.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ endif
3434
SRC_C += \
3535
src/portable/renesas/rusb2/dcd_rusb2.c \
3636
src/portable/renesas/rusb2/hcd_rusb2.c \
37+
src/portable/renesas/rusb2/rusb2_common.c \
3738
$(FSP_RA)/src/bsp/cmsis/Device/RENESAS/Source/startup.c \
3839
$(FSP_RA)/src/bsp/cmsis/Device/RENESAS/Source/system.c \
3940
$(FSP_RA)/src/bsp/mcu/all/bsp_clocks.c \

src/portable/renesas/rusb2/dcd_rusb2.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
#define D0FIFOCTR_b CFIFOCTR_b
5151
#endif
5252

53-
// Application API for setting IRQ number
54-
void tud_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum) {
55-
rusb2_controller[rhport].irqnum = irqnum;
56-
}
57-
5853
#else
5954
#error "Unsupported MCU"
6055
#endif

src/portable/renesas/rusb2/hcd_rusb2.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,8 @@
3434

3535
#if TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
3636
#include "rusb2_rx.h"
37-
3837
#elif TU_CHECK_MCU(OPT_MCU_RAXXX)
3938
#include "rusb2_ra.h"
40-
41-
// void osal_task_delay(uint32_t msec) {
42-
// R_BSP_SoftwareDelay(msec, BSP_DELAY_UNITS_MILLISECONDS);
43-
// }
44-
4539
#else
4640
#error "Unsupported MCU"
4741
#endif
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2023 Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#include "tusb_option.h"
28+
29+
#if defined(TUP_USBIP_RUSB2) && (CFG_TUH_ENABLED || CFG_TUD_ENABLED)
30+
31+
#include "rusb2_type.h"
32+
33+
#if TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
34+
#include "rusb2_rx.h"
35+
36+
#elif TU_CHECK_MCU(OPT_MCU_RAXXX)
37+
#include "rusb2_ra.h"
38+
39+
// USBFS_INT_IRQn and USBHS_USB_INT_RESUME_IRQn are generated by FSP
40+
rusb2_controller_t rusb2_controller[] = {
41+
{ .reg_base = R_USB_FS0_BASE, .irqnum = USBFS_INT_IRQn },
42+
#ifdef RUSB2_SUPPORT_HIGHSPEED
43+
{ .reg_base = R_USB_HS0_BASE, .irqnum = USBHS_USB_INT_RESUME_IRQn },
44+
#endif
45+
};
46+
47+
// Application API for setting IRQ number. May throw warnings for missing prototypes.
48+
void tusb_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum) {
49+
rusb2_controller[rhport].irqnum = irqnum;
50+
}
51+
52+
// void osal_task_delay(uint32_t msec) {
53+
// R_BSP_SoftwareDelay(msec, BSP_DELAY_UNITS_MILLISECONDS);
54+
// }
55+
56+
#else
57+
#error "Unsupported MCU"
58+
#endif
59+
60+
61+
#endif

src/portable/renesas/rusb2/rusb2_ra.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ typedef struct {
7474
#define rusb2_is_highspeed_reg(_reg) (false)
7575
#endif
7676

77-
// USBFS_INT_IRQn and USBHS_USB_INT_RESUME_IRQn are generated by FSP
78-
static rusb2_controller_t rusb2_controller[] = {
79-
{ .reg_base = R_USB_FS0_BASE, .irqnum = USBFS_INT_IRQn },
80-
#ifdef RUSB2_SUPPORT_HIGHSPEED
81-
{ .reg_base = R_USB_HS0_BASE, .irqnum = USBHS_USB_INT_RESUME_IRQn },
82-
#endif
83-
};
77+
extern rusb2_controller_t rusb2_controller[];
8478

8579
#define RUSB2_REG(_p) ((rusb2_reg_t*) rusb2_controller[_p].reg_base)
8680

src/portable/renesas/rusb2/rusb2_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define _TUSB_RUSB2_TYPE_H_
2929

3030
#include <stdint.h>
31+
#include <stddef.h>
3132

3233
#ifdef __cplusplus
3334
extern "C" {

0 commit comments

Comments
 (0)