diff --git a/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/common/usb0_function_lib.c b/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/common/usb0_function_lib.c index f546acb6d3..e3d318b984 100644 --- a/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/common/usb0_function_lib.c +++ b/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/common/usb0_function_lib.c @@ -1869,33 +1869,35 @@ uint16_t usb0_function_get_inbuf (uint16_t pipe) * Arguments : uint8_t level ;interrupt level * Return Value : none *******************************************************************************/ +#if 0 void usb0_function_setting_interrupt (uint8_t level) { - IRQn_Type d0fifo_dmaintid; - IRQn_Type d1fifo_dmaintid; + uint16_t d0fifo_dmaintid; + uint16_t d1fifo_dmaintid; - InterruptHandlerRegister(USBI0_IRQn, usb0_function_interrupt); - GIC_SetPriority(USBI0_IRQn, level); - GIC_EnableIRQ(USBI0_IRQn); + R_INTC_RegistIntFunc(INTC_ID_USBI0, usb0_function_interrupt); + R_INTC_SetPriority(INTC_ID_USBI0, level); + R_INTC_Enable(INTC_ID_USBI0); d0fifo_dmaintid = Userdef_USB_usb0_function_d0fifo_dmaintid(); if (d0fifo_dmaintid != 0xFFFF) { - InterruptHandlerRegister(d0fifo_dmaintid, usb0_function_dma_interrupt_d0fifo); - GIC_SetPriority(d0fifo_dmaintid, level); - GIC_EnableIRQ(d0fifo_dmaintid); + R_INTC_RegistIntFunc(d0fifo_dmaintid, usb0_function_dma_interrupt_d0fifo); + R_INTC_SetPriority(d0fifo_dmaintid, level); + R_INTC_Enable(d0fifo_dmaintid); } d1fifo_dmaintid = Userdef_USB_usb0_function_d1fifo_dmaintid(); if (d1fifo_dmaintid != 0xFFFF) { - InterruptHandlerRegister(d1fifo_dmaintid, usb0_function_dma_interrupt_d1fifo); - GIC_SetPriority(d1fifo_dmaintid, level); - GIC_EnableIRQ(d1fifo_dmaintid); + R_INTC_RegistIntFunc(d1fifo_dmaintid, usb0_function_dma_interrupt_d1fifo); + R_INTC_SetPriority(d1fifo_dmaintid, level); + R_INTC_Enable(d1fifo_dmaintid); } } +#endif /******************************************************************************* * Function Name: usb0_function_reset_module diff --git a/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/function/usb0_function_api.c b/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/function/usb0_function_api.c index 3a64af6118..369b2bea60 100644 --- a/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/function/usb0_function_api.c +++ b/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/src/function/usb0_function_api.c @@ -77,6 +77,7 @@ Private global variables and functions * : ; 12MHz ; USBFCLOCK_EXTAL_12MHZ * Return Value : none *******************************************************************************/ +#if 0 void usb0_api_function_init (uint8_t int_level, uint16_t mode, uint16_t clockmode) { volatile uint8_t dummy_buf; @@ -94,6 +95,7 @@ void usb0_api_function_init (uint8_t int_level, uint16_t mode, uint16_t clockmod usb0_function_InitModule(mode); /* select USB Function and Interrupt Enable */ /* Detect USB Device to attach or detach */ } +#endif /******************************************************************************* * Function Name: usb0_api_function_IsConfigured diff --git a/libraries/USBDevice/USBDevice/USBHAL.h b/libraries/USBDevice/USBDevice/USBHAL.h index 732e15ce86..32564ad927 100644 --- a/libraries/USBDevice/USBDevice/USBHAL.h +++ b/libraries/USBDevice/USBDevice/USBHAL.h @@ -67,11 +67,6 @@ public: bool getEndpointStallState(unsigned char endpoint); uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer); -#if defined(TARGET_RZ_A1H) - static USBHAL * instance; - static void _usbisr(void); -#endif - #ifdef TARGET_RZ_A1H uint32_t EP2PIPE(uint8_t endpoint); void usb0_function_save_request(void); @@ -126,10 +121,8 @@ protected: private: void usbisr(void); -#if !defined(TARGET_RZ_A1H) static void _usbisr(void); static USBHAL * instance; -#endif #ifdef TARGET_RZ_A1H IRQn_Type int_id; /* interrupt ID */ diff --git a/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.cpp b/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.cpp index d2bba0eeb4..0eb7830661 100644 --- a/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.cpp +++ b/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.cpp @@ -30,6 +30,7 @@ extern "C" #include "iodefine.h" } #include "USBHAL.h" +#include "usb0_function.h" //#include "USBRegs_RZ_A1H.h" @@ -144,15 +145,6 @@ static uint8_t recv_buffer[MAX_PACKET_SIZE_EPBULK]; volatile static uint16_t recv_error; -/*************************************************************************/ -extern "C" -{ - void usb0_function_interrupt(uint32_t int_sense) - { - USBHAL::instance->_usbisr(); - } -} - /*************************************************************************/ /*EP2PIPE converter is for pipe1, pipe3 and pipe6 only.*/ @@ -178,12 +170,6 @@ USBHAL::USBHAL(void) /* ---- P4_1 : P4_1 (USB0_EN for GR-PEACH) ---- */ usb0_en = new DigitalOut(P4_1, 1); -#if 0 /* This setting is same as a routine in usb0_api_function_init */ - CPG.STBCR7 &= ~(1u<<0u); - volatile uint8_t dummy8; - dummy8 = CPG.STBCR7; -#endif - /* some constants */ int_id = USBI0_IRQn; int_level = ( 2 << 3 ); @@ -233,8 +219,60 @@ USBHAL::USBHAL(void) /* Clear pipe table */ usb0_function_clear_pipe_tbl(); - /* Initialize USB IP */ - usb0_api_function_init(int_level, mode, clock_mode); +/****************************************************************************** + * Function Name: usb0_api_function_init + * Description : Initializes the USB module in the USB function mode. + *****************************************************************************/ + /* The clock of USB0 modules is permitted */ + CPG.STBCR7 &= ~(CPG_STBCR7_MSTP71); + volatile uint8_t dummy8; + dummy8 = CPG.STBCR7; + + { +/****************************************************************************** + * Function Name: usb0_function_setting_interrupt + * Description : Sets the USB module interrupt level. + *****************************************************************************/ +#if 0 /*DMA is not supported*/ + IRQn_Type d0fifo_dmaintid; + IRQn_Type d1fifo_dmaintid; +#endif + + InterruptHandlerRegister(int_id, &_usbisr); + GIC_SetPriority(int_id, int_level); + GIC_EnableIRQ(int_id); + +#if 0 /*DMA is not supported*/ + d0fifo_dmaintid = Userdef_USB_usb0_function_d0fifo_dmaintid(); + if (d0fifo_dmaintid != 0xFFFF) + { + InterruptHandlerRegister(d0fifo_dmaintid, usb0_function_dma_interrupt_d0fifo); + GIC_SetPriority(d0fifo_dmaintid, int_level); + GIC_EnableIRQ(d0fifo_dmaintid); + } +#endif + +#if 0 /*DMA is not supported*/ + d1fifo_dmaintid = Userdef_USB_usb0_function_d1fifo_dmaintid(); + if (d1fifo_dmaintid != 0xFFFF) + { + InterruptHandlerRegister(d1fifo_dmaintid, usb0_function_dma_interrupt_d1fifo); + GIC_SetPriority(d1fifo_dmaintid, int_level); + GIC_EnableIRQ(d1fifo_dmaintid); + } +#endif +/*****************************************************************************/ + } + + /* reset USB module with setting tranciever and HSE=1 */ + usb0_function_reset_module(clock_mode); + + /* clear variables */ + usb0_function_init_status(); + + /* select USB Function and Interrupt Enable */ + /* Detect USB Device to attach or detach */ + usb0_function_InitModule(mode); { uint16_t buf;